Skip to content

Conversation

@sterliakov
Copy link
Collaborator

Supersedes #18504. Fixes #16090. Fixes #8085.

This PR extracts first subset of changes initially submitted in #18504. It is known to make handling of unsupported constructs (property setter overrides and non-adjacent property components handling) worse, those problems will be addressed in a follow-up PR to make this one better scoped.

Please DO NOT MERGE if a release is planned soon, override regressions may be problematic for some users.

@github-actions

This comment has been minimized.

@sterliakov
Copy link
Collaborator Author

OK, the primer matches what I saw in the original PR modulo disappeared errors related to non-adjacent property setters and property setter overrides.

@sterliakov sterliakov marked this pull request as ready for review April 26, 2025 02:03
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

spark (https://github.com/apache/spark)
+ python/pyspark/instrumentation_utils.py:83: error: Unused "type: ignore" comment  [unused-ignore]

ppb-vector (https://github.com/ppb/ppb-vector)
+ tests/utils.py:86: error: Unused "type: ignore" comment  [unused-ignore]

core (https://github.com/home-assistant/core)
+ homeassistant/components/template/update.py:432: error: Unused "type: ignore" comment  [unused-ignore]
+ homeassistant/components/template/update.py:432: error: "None" not callable  [misc]
+ homeassistant/components/template/update.py:432: note: Error code "misc" not covered by "type: ignore" comment
+ homeassistant/components/template/image.py:120: error: Unused "type: ignore" comment  [unused-ignore]
+ homeassistant/components/template/image.py:120: error: "None" not callable  [misc]
+ homeassistant/components/template/image.py:120: note: Error code "misc" not covered by "type: ignore" comment
+ homeassistant/components/template/image.py:162: error: Unused "type: ignore" comment  [unused-ignore]
+ homeassistant/components/template/image.py:162: error: "None" not callable  [misc]
+ homeassistant/components/template/image.py:162: note: Error code "misc" not covered by "type: ignore" comment
+ homeassistant/components/template/image.py:163: error: Unused "type: ignore" comment  [unused-ignore]
+ homeassistant/components/template/image.py:163: error: "None" not callable  [misc]
+ homeassistant/components/template/image.py:163: note: Error code "misc" not covered by "type: ignore" comment
+ homeassistant/components/mqtt/sensor.py:398: error: Unused "type: ignore" comment  [unused-ignore]
+ homeassistant/components/mqtt/sensor.py:398: error: "None" not callable  [misc]
+ homeassistant/components/mqtt/sensor.py:398: note: Error code "misc" not covered by "type: ignore" comment
+ homeassistant/components/mqtt/binary_sensor.py:256: error: Unused "type: ignore" comment  [unused-ignore]
+ homeassistant/components/mqtt/binary_sensor.py:256: error: "None" not callable  [misc]
+ homeassistant/components/mqtt/binary_sensor.py:256: note: Error code "misc" not covered by "type: ignore" comment
+ homeassistant/components/rest/sensor.py:148: error: Unused "type: ignore" comment  [unused-ignore]
+ homeassistant/components/rest/sensor.py:148: error: "None" not callable  [misc]
+ homeassistant/components/rest/sensor.py:148: note: Error code "misc" not covered by "type: ignore" comment
+ homeassistant/components/rest/sensor.py:149: error: Unused "type: ignore" comment  [unused-ignore]
+ homeassistant/components/rest/sensor.py:149: error: "None" not callable  [misc]
+ homeassistant/components/rest/sensor.py:149: note: Error code "misc" not covered by "type: ignore" comment
+ homeassistant/components/rest/binary_sensor.py:141: error: Unused "type: ignore" comment  [unused-ignore]
+ homeassistant/components/rest/binary_sensor.py:141: error: "None" not callable  [misc]
+ homeassistant/components/rest/binary_sensor.py:141: note: Error code "misc" not covered by "type: ignore" comment
+ homeassistant/components/rest/binary_sensor.py:142: error: Unused "type: ignore" comment  [unused-ignore]
+ homeassistant/components/rest/binary_sensor.py:142: error: "None" not callable  [misc]
+ homeassistant/components/rest/binary_sensor.py:142: note: Error code "misc" not covered by "type: ignore" comment
+ homeassistant/components/scrape/sensor.py:226: error: Unused "type: ignore" comment  [unused-ignore]
+ homeassistant/components/scrape/sensor.py:226: error: "None" not callable  [misc]
+ homeassistant/components/scrape/sensor.py:226: note: Error code "misc" not covered by "type: ignore" comment
+ homeassistant/components/scrape/sensor.py:227: error: Unused "type: ignore" comment  [unused-ignore]
+ homeassistant/components/scrape/sensor.py:227: error: "None" not callable  [misc]
+ homeassistant/components/scrape/sensor.py:227: note: Error code "misc" not covered by "type: ignore" comment

egglog-python (https://github.com/egraphs-good/egglog-python)
+ python/tests/test_high_level.py:638: error: "property" not callable  [operator]

pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/groupby/indexing.py:248: error: Argument 1 to "doc" has incompatible type "property"; expected "str | Callable[..., Any] | None"  [arg-type]
+ pandas/core/series.py:359: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas/core/indexing.py:1244: error: Argument 1 to "doc" has incompatible type "property"; expected "str | Callable[..., Any] | None"  [arg-type]
+ pandas/core/indexing.py:1595: error: Argument 1 to "doc" has incompatible type "property"; expected "str | Callable[..., Any] | None"  [arg-type]
+ pandas/core/indexing.py:2559: error: Argument 1 to "doc" has incompatible type "property"; expected "str | Callable[..., Any] | None"  [arg-type]
+ pandas/core/indexing.py:2609: error: Argument 1 to "doc" has incompatible type "property"; expected "str | Callable[..., Any] | None"  [arg-type]
+ pandas/core/indexes/datetimelike.py:138: error: Argument 1 to "doc" has incompatible type "property"; expected "str | Callable[..., Any] | None"  [arg-type]
+ pandas/core/indexes/datetimelike.py:155: error: Argument 1 to "doc" has incompatible type "property"; expected "str | Callable[..., Any] | None"  [arg-type]
+ pandas/core/indexes/datetimelike.py:526: error: Argument 1 to "doc" has incompatible type "property"; expected "str | Callable[..., Any] | None"  [arg-type]
+ pandas/core/indexes/base.py:4972: error: Argument 1 to "doc" has incompatible type "property"; expected "str | Callable[..., Any] | None"  [arg-type]

ibis (https://github.com/ibis-project/ibis)
- ibis/expr/operations/udf.py:155: error: Argument 2 to "type" has incompatible type "tuple[Callable[[_UDF], type[B]]]"; expected "tuple[type, ...]"  [arg-type]
+ ibis/expr/operations/udf.py:155: error: Argument 2 to "type" has incompatible type "tuple[property]"; expected "tuple[type, ...]"  [arg-type]
- ibis/backends/tests/base.py:186: error: "Callable[[BackendTest], Iterable[str]]" has no attribute "__iter__" (not iterable)  [attr-defined]
+ ibis/backends/tests/base.py:186: error: "property" has no attribute "__iter__" (not iterable)  [attr-defined]

discord.py (https://github.com/Rapptz/discord.py)
- discord/member.py:509: error: "Callable[[Member], Status]" has no attribute "setter"  [attr-defined]

pandera (https://github.com/pandera-dev/pandera)
- pandera/engines/pandas_engine.py:1258: error: No overload variant of "list" matches argument type "Callable[[BaseModel], dict[str, FieldInfo]]"  [call-overload]
+ pandera/engines/pandas_engine.py:1258: error: No overload variant of "list" matches argument type "property"  [call-overload]
+ pandera/api/pandas/container.py:19: error: Unused "type: ignore" comment  [unused-ignore]
+ pandera/api/polars/container.py:70: error: Unused "type: ignore" comment  [unused-ignore]
+ pandera/api/ibis/container.py:110: error: Unused "type: ignore" comment  [unused-ignore]

pwndbg (https://github.com/pwndbg/pwndbg)
- pwndbg/aglib/heap/structs.py:177: error: Invalid index type "Any | type[Any] | _CField[Any, Any, Any] | overloaded function" for "dict[type[object], Type]"; expected type "type[object]"  [index]
+ pwndbg/aglib/heap/structs.py:177: error: Invalid index type "Any | type[Any] | _CField[Any, Any, Any] | property" for "dict[type[object], Type]"; expected type "type[object]"  [index]
- pwndbg/aglib/heap/structs.py:179: error: Argument 1 to "array" of "Type" has incompatible type "Any | _CField[Any, Any, Any] | overloaded function"; expected "int"  [arg-type]
+ pwndbg/aglib/heap/structs.py:179: error: Argument 1 to "array" of "Type" has incompatible type "Any | _CField[Any, Any, Any] | property"; expected "int"  [arg-type]
- pwndbg/aglib/heap/structs.py:208: error: Invalid index type "Any | type[Any] | _CField[Any, Any, Any] | overloaded function" for "dict[type[object], Type]"; expected type "type[object]"  [index]
+ pwndbg/aglib/heap/structs.py:208: error: Invalid index type "Any | type[Any] | _CField[Any, Any, Any] | property" for "dict[type[object], Type]"; expected type "type[object]"  [index]
- pwndbg/aglib/heap/structs.py:209: error: Argument 1 to "array" of "Type" has incompatible type "Any | _CField[Any, Any, Any] | overloaded function"; expected "int"  [arg-type]
+ pwndbg/aglib/heap/structs.py:209: error: Argument 1 to "array" of "Type" has incompatible type "Any | _CField[Any, Any, Any] | property"; expected "int"  [arg-type]

xarray (https://github.com/pydata/xarray)
+ xarray/core/variable.py:2777: error: Unused "type: ignore" comment  [unused-ignore]
+ xarray/core/variable.py:2784: error: Unused "type: ignore" comment  [unused-ignore]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

property accessed on class incorrectly understood as function, expected property Attributes of property objects can't be accessed

1 participant