Skip to content

[ty] Fallback to metaclass __getattr__ or __getattribute__#22985

Merged
charliermarsh merged 3 commits intomainfrom
charlie/meta-attr
Jan 30, 2026
Merged

[ty] Fallback to metaclass __getattr__ or __getattribute__#22985
charliermarsh merged 3 commits intomainfrom
charlie/meta-attr

Conversation

@charliermarsh
Copy link
Member

Summary

Closes astral-sh/ty#2677.

@charliermarsh
Copy link
Member Author

(Just want ecosystem and conformance to start.)

@charliermarsh charliermarsh added ty Multi-file analysis & type inference ecosystem-analyzer labels Jan 30, 2026
@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 30, 2026

Typing conformance results

No changes detected ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 30, 2026

mypy_primer results

Changes were detected when running on open source projects
pandera (https://github.com/pandera-dev/pandera)
- tests/io/test_pandas_io.py:1508:17: error[unresolved-attribute] Class `Check` has no attribute `ncols_gt`
- tests/io/test_pandas_io.py:1604:24: error[unresolved-attribute] Class `Check` has no attribute `datetime_check`
- tests/io/test_pandas_io.py:1608:24: error[unresolved-attribute] Class `Check` has no attribute `datetime_check`
- tests/modin/test_schemas_on_modin.py:299:36: error[unresolved-attribute] Class `Check` has no attribute `modin_eq`
- tests/pandas/test_checks.py:487:43: error[unresolved-attribute] Class `Check` has no attribute `raise_an_error_check`
- tests/pandas/test_extensions.py:46:13: error[unresolved-attribute] Class `Check` has no attribute `custom_check`
- tests/pandas/test_extensions.py:57:13: error[unresolved-attribute] Class `Check` has no attribute `custom_check`
- tests/pandas/test_extensions.py:88:13: error[unresolved-attribute] Class `Check` has no attribute `custom_check`
- tests/pandas/test_extensions.py:99:13: error[unresolved-attribute] Class `Check` has no attribute `custom_check`
- tests/pandas/test_extensions.py:146:17: error[unresolved-attribute] Class `Check` has no attribute `custom_check`
- tests/pandas/test_extensions.py:169:16: error[unresolved-attribute] Class `Check` has no attribute `custom_check`
- tests/pandas/test_extensions.py:177:13: error[unresolved-attribute] Class `Check` has no attribute `custom_check`
- tests/pandas/test_extensions.py:231:13: error[unresolved-attribute] Class `Check` has no attribute `custom_ge_check`
- tests/pandas/test_extensions.py:296:9: error[unresolved-attribute] Class `Check` has no attribute `custom_eq`
- tests/pandas/test_extensions.py:305:5: error[unresolved-attribute] Class `Check` has no attribute `custom_eq`
- tests/pandas/test_extensions.py:332:13: error[unresolved-attribute] Class `Check` has no attribute `custom_check`
- tests/pandas/test_schema_statistics.py:761:15: error[unresolved-attribute] Class `Check` has no attribute `no_param_check`
- tests/pyspark/test_pyspark_check.py:1672:21: error[unresolved-attribute] Class `Check` has no attribute `new_pyspark_check`
- tests/pyspark/test_schemas_on_pyspark_pandas.py:533:36: error[unresolved-attribute] Class `Check` has no attribute `pyspark_pandas_eq`
- tests/strategies/test_strategies.py:903:17: error[unresolved-attribute] Class `Check` has no attribute `custom_check_with_strategy`
- Found 1638 diagnostics
+ Found 1618 diagnostics

comtypes (https://github.com/enthought/comtypes)
- comtypes/util.py:131:12: error[unresolved-attribute] Class `PyCArgObject` has no attribute `p`
- Found 483 diagnostics
+ Found 482 diagnostics

prefect (https://github.com/PrefectHQ/prefect)
- src/integrations/prefect-dbt/prefect_dbt/core/settings.py:94:28: error[invalid-assignment] Object of type `dict[Any, Any] | int | dict[str, Any] | ... omitted 4 union elements` is not assignable to `dict[str, Any]`
- src/integrations/prefect-dbt/prefect_dbt/core/settings.py:99:28: error[invalid-assignment] Object of type `int | dict[Any, Any] | float | ... omitted 3 union elements` is not assignable to `dict[str, Any]`
- src/prefect/cli/deploy/_core.py:86:21: error[invalid-assignment] Object of type `dict[Any, Any] | int | dict[str, Any] | ... omitted 4 union elements` is not assignable to `dict[str, Any]`
- src/prefect/cli/deploy/_core.py:87:21: error[invalid-assignment] Object of type `int | dict[Any, Any] | float | ... omitted 3 union elements` is not assignable to `dict[str, Any]`
- src/prefect/deployments/steps/core.py:137:38: error[invalid-argument-type] Argument is incorrect: Argument type `dict[Any, Any] | int | dict[str, Any] | ... omitted 4 union elements` does not satisfy constraints (`str`, `int`, `int | float`, `bool`, `dict[Any, Any]`, `list[Any]`, `None`) of type variable `T`
- src/prefect/utilities/templating.py:320:13: error[invalid-assignment] Invalid subscript assignment with key of type `object` and value of type `Unknown | int | dict[str, Any] | ... omitted 4 union elements` on object of type `dict[str, Any]`
+ src/prefect/utilities/templating.py:320:13: error[invalid-assignment] Invalid subscript assignment with key of type `object` and value of type `Unknown | dict[str, Any]` on object of type `dict[str, Any]`
- src/prefect/utilities/templating.py:323:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_block_document_references | dict[str, Any]`, found `list[Unknown | int | dict[str, Any] | ... omitted 4 union elements]`
+ src/prefect/utilities/templating.py:323:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_block_document_references | dict[str, Any]`, found `list[Unknown | dict[str, Any]]`
- src/prefect/utilities/templating.py:437:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `dict[object, Unknown | int | float | ... omitted 4 union elements]`
+ src/prefect/utilities/templating.py:437:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `dict[object, Unknown]`
- src/prefect/utilities/templating.py:442:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `list[Unknown | int | float | ... omitted 4 union elements]`
+ src/prefect/utilities/templating.py:442:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `list[Unknown]`
+ src/prefect/workers/base.py:232:13: error[invalid-argument-type] Argument is incorrect: Argument type `str | dict[str, Any]` does not satisfy constraints (`str`, `int`, `int | float`, `bool`, `dict[Any, Any]`, `list[Any]`, `None`) of type variable `T`
- src/prefect/workers/base.py:232:13: error[invalid-argument-type] Argument is incorrect: Argument type `str | int | dict[str, Any] | ... omitted 3 union elements` does not satisfy constraints (`str`, `int`, `int | float`, `bool`, `dict[Any, Any]`, `list[Any]`, `None`) of type variable `T`
- src/prefect/workers/base.py:234:22: error[invalid-argument-type] Argument expression after ** must be a mapping type: Found `int | Unknown | float | ... omitted 4 union elements`
- Found 5378 diagnostics
+ Found 5372 diagnostics

scikit-build-core (https://github.com/scikit-build/scikit-build-core)
- src/scikit_build_core/build/wheel.py:99:20: error[no-matching-overload] No overload of bound method `__init__` matches arguments
- Found 47 diagnostics
+ Found 46 diagnostics

pwndbg (https://github.com/pwndbg/pwndbg)
- pwndbg/aglib/heap/structs.py:214:25: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[type[c_char], Type].__getitem__(key: type[c_char], /) -> Type` cannot be called with key of type `type[Union]` on object of type `dict[type[c_char], Type]`
- pwndbg/aglib/heap/structs.py:214:25: error[invalid-argument-type] Method `__getitem__` of type `bound method dict[type[c_char], Type].__getitem__(key: type[c_char], /) -> Type` cannot be called with key of type `type[Structure]` on object of type `dict[type[c_char], Type]`
- Found 1937 diagnostics
+ Found 1935 diagnostics

No memory usage changes detected ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 30, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
unresolved-attribute 0 21 0
invalid-argument-type 2 3 2
invalid-assignment 0 0 3
unused-type-ignore-comment 0 2 0
invalid-return-type 0 0 1
Total 2 26 6

Full report with detailed diff (timing results)

@charliermarsh charliermarsh marked this pull request as ready for review January 30, 2026 18:45
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@charliermarsh charliermarsh enabled auto-merge (squash) January 30, 2026 19:05
@charliermarsh charliermarsh merged commit 47dbe01 into main Jan 30, 2026
47 of 48 checks passed
@charliermarsh charliermarsh deleted the charlie/meta-attr branch January 30, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ecosystem-analyzer ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

__getattr__ and __getattribute__ don't work on metaclasses

2 participants