Skip to content

Limit binder special-casing to imprecise Any - #22050

Open
ilevkivskyi wants to merge 2 commits into
python:masterfrom
ilevkivskyi:better-binder-any
Open

ilevkivskyi wants to merge 2 commits into
python:masterfrom
ilevkivskyi:better-binder-any

Conversation

@ilevkivskyi

@ilevkivskyi ilevkivskyi commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

There is a bunch of special-casing for Any types in binder. The goal of this special-casing is to limit the spread of Any types from legacy code with missing/imprecise types. This special-casing is quite ad-hoc, and thus should be limited only to imprecise kinds of Any.

Note this should help with #22011
cc @JukkaL @hauntsaninja

@github-actions

This comment has been minimized.

@ilevkivskyi

ilevkivskyi commented Sep 25, 2026 •

Copy link
Copy Markdown
Member Author

Mostly expected things, but there are couple weird results in scipy and pymongo, I will investigate later.

In the meantime, I remember last time we tried this, it caused issues for homeassistant, but now the primer is broken for it, see hauntsaninja/mypy_primer#263 cc @hauntsaninja please take a look.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

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

psycopg (https://github.com/psycopg/psycopg)
+ tests/utils.py:143: error: Returning Any from function declared to return "bool"  [no-any-return]

spark (https://github.com/apache/spark)
+ python/pyspark/pandas/groupby.py:357: error: Unused "type: ignore" comment  [unused-ignore]
+ python/pyspark/sql/connect/column.py:90: error: Unused "type: ignore" comment  [unused-ignore]

prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/cli/deploy/_core.py:356: error: Argument 1 to "_initialize_deployment_triggers" has incompatible type "Any | None"; expected "str"  [arg-type]

colour (https://github.com/colour-science/colour)
- colour/appearance/atd95.py:264: error: No overload variant of "__mul__" of "ndarray" matches argument type "Buffer"  [operator]
- colour/appearance/atd95.py:264: note: Possible overload variants:
- colour/appearance/atd95.py:264: note:     def __mul__(self, int | numpy.bool[builtins.bool], /) -> ndarray[tuple[Any, ...], dtype[floating[_16Bit] | floating[_32Bit] | float64]]
- colour/appearance/atd95.py:264: note:     def __mul__(self, _SupportsArray[dtype[numpy.bool[builtins.bool]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool]]]] | builtins.bool | _NestedSequence[builtins.bool], /) -> ndarray[tuple[Any, ...], dtype[floating[_16Bit] | floating[_32Bit] | float64]]
- colour/appearance/atd95.py:264: note:     def __mul__(self, _SupportsArray[dtype[floating[_64Bit]]] | _NestedSequence[_SupportsArray[dtype[floating[_64Bit]]]], /) -> ndarray[tuple[Any, ...], dtype[float64]]
- colour/appearance/atd95.py:264: note:     def __mul__(self, _SupportsArray[dtype[complexfloating[_64Bit, _64Bit]]] | _NestedSequence[_SupportsArray[dtype[complexfloating[_64Bit, _64Bit]]]], /) -> ndarray[tuple[Any, ...], dtype[complex128]]
- colour/appearance/atd95.py:264: note:     def __mul__(self, _SupportsArray[dtype[numpy.bool[builtins.bool] | integer[Any] | floating[Any]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | integer[Any] | floating[Any]]]] | float | _NestedSequence[float], /) -> ndarray[tuple[Any, ...], dtype[floating[Any]]]
- colour/appearance/atd95.py:264: note:     def __mul__(self, _SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, Any]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, Any]]]] | complex | _NestedSequence[complex], /) -> ndarray[tuple[Any, ...], dtype[complexfloating[Any, Any]]]
- colour/appearance/atd95.py:264: note:     def __mul__(self, _SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, Any]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, Any]]]] | complex | _NestedSequence[complex], /) -> ndarray[tuple[Any, ...], dtype[number[Any, Any]]]
- colour/appearance/atd95.py:264: note:     def __mul__(self, _SupportsArray[dtype[timedelta64[Any]]] | _NestedSequence[_SupportsArray[dtype[timedelta64[Any]]]], /) -> ndarray[tuple[Any, ...], dtype[timedelta64[Any]]]
- colour/appearance/atd95.py:264: note:     def __mul__(self, _SupportsArray[dtype[object_]] | _NestedSequence[_SupportsArray[dtype[object_]]], /) -> Any
- colour/appearance/atd95.py:264: error: Unsupported operand types for * ("ndarray[tuple[Any, ...], dtype[floating[_16Bit] | floating[_32Bit] | float64]]" and "_NestedSequence[complex | bytes | str]")  [operator]
- colour/appearance/atd95.py:264: note: Right operand is of type "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]"
- colour/appearance/atd95.py:264: error: No overload variant of "__add__" of "ndarray" matches argument type "bytes"  [operator]
- colour/appearance/atd95.py:264: note:     def __add__(self, int | numpy.bool[builtins.bool], /) -> ndarray[tuple[Any, ...], dtype[floating[_16Bit] | floating[_32Bit] | float64]]
- colour/appearance/atd95.py:264: note:     def __add__(self, _SupportsArray[dtype[numpy.bool[builtins.bool]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool]]]] | builtins.bool | _NestedSequence[builtins.bool], /) -> ndarray[tuple[Any, ...], dtype[floating[_16Bit] | floating[_32Bit] | float64]]
- colour/appearance/atd95.py:264: note:     def __add__(self, _SupportsArray[dtype[floating[_64Bit]]] | _NestedSequence[_SupportsArray[dtype[floating[_64Bit]]]], /) -> ndarray[tuple[Any, ...], dtype[float64]]
- colour/appearance/atd95.py:264: note:     def __add__(self, _SupportsArray[dtype[complexfloating[_64Bit, _64Bit]]] | _NestedSequence[_SupportsArray[dtype[complexfloating[_64Bit, _64Bit]]]], /) -> ndarray[tuple[Any, ...], dtype[complex128]]
- colour/appearance/atd95.py:264: note:     def __add__(self, _SupportsArray[dtype[numpy.bool[builtins.bool] | integer[Any] | floating[Any]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | integer[Any] | floating[Any]]]] | float | _NestedSequence[float], /) -> ndarray[tuple[Any, ...], dtype[floating[Any]]]
- colour/appearance/atd95.py:264: note:     def __add__(self, _SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, Any]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, Any]]]] | complex | _NestedSequence[complex], /) -> ndarray[tuple[Any, ...], dtype[complexfloating[Any, Any]]]
- colour/appearance/atd95.py:264: note:     def __add__(self, _SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, Any]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, Any]]]] | complex | _NestedSequence[complex], /) -> ndarray[tuple[Any, ...], dtype[number[Any, Any]]]
- colour/appearance/atd95.py:264: note:     def __add__(self, _SupportsArray[dtype[object_]] | _NestedSequence[_SupportsArray[dtype[object_]]], /) -> Any
- colour/appearance/atd95.py:264: error: No overload variant of "__add__" of "ndarray" matches argument type "str"  [operator]
- colour/appearance/atd95.py:264: note:     def __add__(self, int | numpy.bool[builtins.bool], /) -> ndarray[tuple[Any, ...], dtype[complexfloating[Any, Any]]]
- colour/appearance/atd95.py:264: note:     def __add__(self, _SupportsArray[dtype[numpy.bool[builtins.bool]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool]]]] | builtins.bool | _NestedSequence[builtins.bool], /) -> ndarray[tuple[Any, ...], dtype[complexfloating[Any, Any]]]
- colour/appearance/atd95.py:264: error: Unsupported operand types for + ("bytes" and "str")  [operator]
- colour/appearance/atd95.py:264: error: Unsupported operand types for + ("str" and "ndarray[tuple[Any, ...], dtype[floating[_16Bit] | floating[_32Bit] | float64]]")  [operator]
- colour/appearance/atd95.py:264: error: Unsupported operand types for + ("str" and "ndarray[tuple[Any, ...], dtype[complexfloating[Any, Any]]]")  [operator]
- colour/appearance/atd95.py:264: error: Unsupported operand types for + ("str" and "bytes")  [operator]
- colour/appearance/atd95.py:264: note: Both left and right operands are unions
- colour/models/rgb/rgb_colourspace.py:1064: error: Item "str" of "RGB_Colourspace | str" has no attribute "whitepoint"  [union-attr]
- colour/models/rgb/rgb_colourspace.py:1066: error: Item "str" of "RGB_Colourspace | str" has no attribute "whitepoint"  [union-attr]
- colour/models/rgb/rgb_colourspace.py:1067: error: Item "str" of "RGB_Colourspace | str" has no attribute "matrix_XYZ_to_RGB"  [union-attr]
- colour/models/rgb/rgb_colourspace.py:1068: error: Item "str" of "RGB_Colourspace | str" has no attribute "cctf_encoding"  [union-attr]
- colour/models/rgb/rgb_colourspace.py:1197: error: Item "str" of "RGB_Colourspace | str" has no attribute "whitepoint"  [union-attr]
- colour/models/rgb/rgb_colourspace.py:1199: error: Item "str" of "RGB_Colourspace | str" has no attribute "whitepoint"  [union-attr]
- colour/models/rgb/rgb_colourspace.py:1200: error: Item "str" of "RGB_Colourspace | str" has no attribute "matrix_RGB_to_XYZ"  [union-attr]
- colour/models/rgb/rgb_colourspace.py:1201: error: Item "str" of "RGB_Colourspace | str" has no attribute "cctf_decoding"  [union-attr]

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
+ src/hydra_zen/structured_configs/_make_config.py:278: error: Unused "type: ignore" comment  [unused-ignore]

scrapy (https://github.com/scrapy/scrapy)
+ scrapy/downloadermiddlewares/httpcache.py:108: error: Returning Any from function declared to return "Request | Response | None"  [no-any-return]

urllib3 (https://github.com/urllib3/urllib3)
+ src/urllib3/connectionpool.py:760: error: Unused "type: ignore" comment  [unused-ignore]

comtypes (https://github.com/enthought/comtypes)
- comtypes/errorinfo.py:128: error: Item "str" of "Any | str" has no attribute "as_progid"  [union-attr]

core (https://github.com/home-assistant/core)
- Warning: disabling incremental mode may severely reduce performance
- If this is intentional, delete '.mypy_cache' to suppress this warning
+ homeassistant/components/cloud/account_link.py:66: error: Returning Any from function declared to return "list[dict[str, Any]]"  [no-any-return]
+ homeassistant/components/homeassistant/exposed_entities.py:257: error: Returning Any from function declared to return "bool"  [no-any-return]
+ homeassistant/components/homeassistant/exposed_entities.py:284: error: Returning Any from function declared to return "bool"  [no-any-return]
+ homeassistant/components/mqtt/models.py:398: error: Returning Any from function declared to return "str | bytes | bytearray"  [no-any-return]
+ homeassistant/components/mqtt/models.py:424: error: Returning Any from function declared to return "str | bytes | bytearray"  [no-any-return]
+ homeassistant/components/shelly/entity.py:592: error: Returning Any from function declared to return "str | int | float | None"  [no-any-return]
+ homeassistant/components/unifiprotect/utils.py:85: error: Returning Any from function declared to return "dict[str, Any]"  [no-any-return]
+ homeassistant/components/enphase_envoy/coordinator.py:91: error: Returning Any from function declared to return "bool"  [no-any-return]
+ homeassistant/components/mqtt/config_flow.py:849: error: Returning Any from function declared to return "str"  [no-any-return]

dulwich (https://github.com/dulwich/dulwich)
+ dulwich/client.py:4471: error: Returning Any from function declared to return "ProxyManager | PoolManager | AuthCallbackPoolManager"  [no-any-return]

pydantic (https://github.com/pydantic/pydantic)
+ pydantic/v1/main.py:864: error: Unused "type: ignore" comment  [unused-ignore]
- pydantic/_internal/_discriminated_union.py:210: error: "Mapping[str, Any]" has no attribute "pop"  [attr-defined]
- pydantic/types.py:3148: error: "Mapping[str, Any]" has no attribute "pop"  [attr-defined]
- pydantic/_internal/_known_annotated_metadata.py:223: error: Unsupported target for indexed assignment ("Mapping[str, Any]")  [index]
- pydantic/_internal/_known_annotated_metadata.py:223: error: Unsupported target for indexed assignment ("Mapping[str, Any] | AfterValidatorFunctionSchema")  [index]
- pydantic/_internal/_generate_schema.py:2358: error: Unsupported target for indexed assignment ("Mapping[str, Any]")  [index]
- pydantic/_internal/_generate_schema.py:2366: error: Unsupported target for indexed assignment ("Mapping[str, Any]")  [index]
+ pydantic/deprecated/copy_internals.py:49: error: Unused "type: ignore" comment  [unused-ignore]
- pydantic/experimental/pipeline.py:464: error: Unsupported target for indexed assignment ("Mapping[str, Any] | Any")  [index]
- pydantic/experimental/pipeline.py:468: error: Unsupported target for indexed assignment ("Mapping[str, Any] | Any")  [index]
- pydantic/experimental/pipeline.py:472: error: Unsupported target for indexed assignment ("Mapping[str, Any] | Any")  [index]
- pydantic/experimental/pipeline.py:496: error: Unsupported target for indexed assignment ("Mapping[str, Any] | Any")  [index]
- pydantic/experimental/pipeline.py:507: error: Unsupported target for indexed assignment ("Mapping[str, Any] | Any")  [index]
- pydantic/experimental/pipeline.py:518: error: Unsupported target for indexed assignment ("Mapping[str, Any] | Any")  [index]
- pydantic/experimental/pipeline.py:529: error: Unsupported target for indexed assignment ("Mapping[str, Any] | Any")  [index]
- pydantic/experimental/pipeline.py:543: error: Unsupported target for indexed assignment ("Mapping[str, Any] | Any")  [index]
- pydantic/experimental/pipeline.py:545: error: Unsupported target for indexed assignment ("Mapping[str, Any] | Any")  [index]
- pydantic/experimental/pipeline.py:562: error: Unsupported target for indexed assignment ("Mapping[str, Any] | Any")  [index]
- pydantic/experimental/pipeline.py:575: error: Unsupported target for indexed assignment ("Mapping[str, Any] | Any")  [index]
- pydantic/experimental/pipeline.py:586: error: Unsupported target for indexed assignment ("Mapping[str, Any] | Any")  [index]
- pydantic/experimental/pipeline.py:655: error: Unsupported target for indexed assignment ("Mapping[str, Any] | Any")  [index]

scipy (https://github.com/scipy/scipy)
- scipy/spatial/transform/_rotation_xp.py:521: error: Unsupported operand types for > ("int" and "Buffer")  [operator]
- scipy/spatial/transform/_rotation_xp.py:521: error: Unsupported operand types for > ("int" and "_SupportsArray[dtype[Any]]")  [operator]
- scipy/spatial/transform/_rotation_xp.py:521: error: Unsupported operand types for > ("int" and "_NestedSequence[_SupportsArray[dtype[Any]]]")  [operator]
- scipy/spatial/transform/_rotation_xp.py:521: error: Unsupported operand types for > ("int" and "complex")  [operator]
- scipy/spatial/transform/_rotation_xp.py:521: error: Unsupported operand types for > ("int" and "_NestedSequence[complex | bytes | str]")  [operator]
- scipy/spatial/transform/_rotation_xp.py:521: note: Left operand is of type "Any | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | str | _NestedSequence[complex | bytes | str]"
- scipy/spatial/transform/_rotation_xp.py:521: error: Unsupported operand types for < ("str" and "int")  [operator]
- scipy/spatial/transform/_rotation_xp.py:529: error: Item "Buffer" of "Any | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/spatial/transform/_rotation_xp.py:529: error: Item "_SupportsArray[dtype[Any]]" of "Any | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/spatial/transform/_rotation_xp.py:529: error: Item "_NestedSequence[_SupportsArray[dtype[Any]]]" of "Any | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/spatial/transform/_rotation_xp.py:529: error: Item "complex" of "Any | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/spatial/transform/_rotation_xp.py:529: error: Item "str" of "Any | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/spatial/transform/_rotation_xp.py:529: error: Item "_NestedSequence[complex | bytes | str]" of "Any | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/spatial/transform/_rotation_xp.py:532: error: Item "Buffer" of "Any | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/spatial/transform/_rotation_xp.py:532: error: Item "_SupportsArray[dtype[Any]]" of "Any | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/spatial/transform/_rotation_xp.py:532: error: Item "_NestedSequence[_SupportsArray[dtype[Any]]]" of "Any | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/spatial/transform/_rotation_xp.py:532: error: Item "complex" of "Any | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/spatial/transform/_rotation_xp.py:532: error: Item "str" of "Any | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/spatial/transform/_rotation_xp.py:532: error: Item "_NestedSequence[complex | bytes | str]" of "Any | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/stats/_entropy.py:328: error: Item "Buffer" of "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/stats/_entropy.py:328: error: Item "_SupportsArray[dtype[Any]]" of "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/stats/_entropy.py:328: error: Item "_NestedSequence[_SupportsArray[dtype[Any]]]" of "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/stats/_entropy.py:328: error: Item "complex" of "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/stats/_entropy.py:328: error: Item "bytes" of "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/stats/_entropy.py:328: error: Item "str" of "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/stats/_entropy.py:328: error: Item "_NestedSequence[complex | bytes | str]" of "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]" has no attribute "shape"  [union-attr]
- scipy/stats/_entropy.py:369: error: Item "Buffer" of "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]" has no attribute "dtype"  [union-attr]
- scipy/stats/_entropy.py:369: error: Item "_SupportsArray[dtype[Any]]" of "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]" has no attribute "dtype"  [union-attr]
- scipy/stats/_entropy.py:369: error: Item "_NestedSequence[_SupportsArray[dtype[Any]]]" of "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]" has no attribute "dtype"  [union-attr]
- scipy/stats/_entropy.py:369: error: Item "complex" of "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]" has no attribute "dtype"  [union-attr]
- scipy/stats/_entropy.py:369: error: Item "bytes" of "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]" has no attribute "dtype"  [union-attr]
- scipy/stats/_entropy.py:369: error: Item "str" of "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]" has no attribute "dtype"  [union-attr]
- scipy/stats/_entropy.py:369: error: Item "_NestedSequence[complex | bytes | str]" of "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]" has no attribute "dtype"  [union-attr]
+ scipy/spatial/transform/_rotation.py:2578: error: Unused "type: ignore" comment  [unused-ignore]
- scipy/conftest.py:719: error: "str" not callable  [operator]

sympy (https://github.com/sympy/sympy)
+ sympy/core/evalf.py:917: error: Unused "type: ignore" comment  [unused-ignore]

pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/arrays/interval.py:694: error: Argument 1 to "ndim" has incompatible type "ndarray[Any, Any] | ExtensionArray"; expected "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]"  [arg-type]
+ pandas/core/reshape/merge.py:2968: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas/core/indexes/base.py:4436: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas/core/indexes/base.py:4456: error: Unused "type: ignore" comment  [unused-ignore]

boostedblob (https://github.com/hauntsaninja/boostedblob)
+ boostedblob/listing.py:403: error: Unused "type: ignore" comment  [unused-ignore]
+ boostedblob/listing.py:412: error: Unused "type: ignore" comment  [unused-ignore]

poetry (https://github.com/python-poetry/poetry)
+ tests/helpers.py:269: error: Returning Any from function declared to return "EntryPoint"  [no-any-return]

ibis (https://github.com/ibis-project/ibis)
- ibis/backends/datafusion/__init__.py:429: error: Item "str" of "str | Any" has no attribute "names"  [union-attr]
- ibis/backends/datafusion/__init__.py:432: error: Item "str" of "str | Any" has no attribute "table"  [union-attr]

jax (https://github.com/google/jax)
- jax/_src/numpy/util.py:383: error: Argument 1 to "ndim" has incompatible type "int | float | complex | SupportsNdim"; expected "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]"  [arg-type]
- jax/_src/third_party/scipy/betaln.py:63: error: Unsupported operand types for > ("int" and "complex")  [operator]
- jax/_src/third_party/scipy/betaln.py:63: note: Left operand is of type "Array | ndarray[tuple[Any, ...], dtype[Any]] | numpy.bool[builtins.bool] | number[Any, Any] | builtins.bool | int | float | complex"
- jax/experimental/array_serialization/pytree_serialization.py:152: error: Item "str" of "str | PathLike[str]" has no attribute "exists"  [union-attr]
- jax/experimental/array_serialization/pytree_serialization.py:152: error: Item "PathLike[str]" of "str | PathLike[str]" has no attribute "exists"  [union-attr]
- jax/experimental/array_serialization/pytree_serialization.py:152: error: Item "str" of "str | PathLike[str]" has no attribute "iterdir"  [union-attr]
- jax/experimental/array_serialization/pytree_serialization.py:152: error: Item "PathLike[str]" of "str | PathLike[str]" has no attribute "iterdir"  [union-attr]
- jax/experimental/array_serialization/pytree_serialization.py:156: error: Item "str" of "str | PathLike[str]" has no attribute "iterdir"  [union-attr]
- jax/experimental/array_serialization/pytree_serialization.py:156: error: Item "PathLike[str]" of "str | PathLike[str]" has no attribute "iterdir"  [union-attr]
- jax/experimental/array_serialization/pytree_serialization.py:166: error: Item "str" of "str | PathLike[str]" has no attribute "exists"  [union-attr]
- jax/experimental/array_serialization/pytree_serialization.py:166: error: Item "PathLike[str]" of "str | PathLike[str]" has no attribute "exists"  [union-attr]
- jax/experimental/array_serialization/pytree_serialization.py:171: error: Item "str" of "str | PathLike[str]" has no attribute "exists"  [union-attr]
- jax/experimental/array_serialization/pytree_serialization.py:171: error: Item "PathLike[str]" of "str | PathLike[str]" has no attribute "exists"  [union-attr]
- jax/experimental/array_serialization/pytree_serialization.py:171: error: Item "str" of "str | PathLike[str]" has no attribute "iterdir"  [union-attr]
- jax/experimental/array_serialization/pytree_serialization.py:171: error: Item "PathLike[str]" of "str | PathLike[str]" has no attribute "iterdir"  [union-attr]
- jax/experimental/array_serialization/pytree_serialization.py:193: error: Item "str" of "str | PathLike[str]" has no attribute "mkdir"  [union-attr]
- jax/experimental/array_serialization/pytree_serialization.py:193: error: Item "PathLike[str]" of "str | PathLike[str]" has no attribute "mkdir"  [union-attr]
- jax/experimental/array_serialization/pytree_serialization.py:194: error: Item "str" of "str | PathLike[str]" has no attribute "exists"  [union-attr]
- jax/experimental/array_serialization/pytree_serialization.py:194: error: Item "PathLike[str]" of "str | PathLike[str]" has no attribute "exists"  [union-attr]
- jax/experimental/array_serialization/pytree_serialization.py:194: error: Item "str" of "str | PathLike[str]" has no attribute "is_dir"  [union-attr]
- jax/experimental/array_serialization/pytree_serialization.py:194: error: Item "PathLike[str]" of "str | PathLike[str]" has no attribute "is_dir"  [union-attr]

mkosi (https://github.com/systemd/mkosi)
+ mkosi/sandbox.py:570:5: error: Returning Any from function declared to return "int"  [no-any-return]

PyGithub (https://github.com/PyGithub/PyGithub)
+ github/PaginatedList.py:455: error: Unused "type: ignore" comment  [unused-ignore]

static-frame (https://github.com/static-frame/static-frame)
+ static_frame/core/index_datetime.py:150: error: Unused "type: ignore" comment  [unused-ignore]
+ static_frame/core/index_hierarchy.py:1523: error: Returning Any from function declared to return "int"  [no-any-return]
+ static_frame/core/index_hierarchy.py:2052: error: Returning Any from function declared to return "ndarray[Any, Any]"  [no-any-return]

apprise (https://github.com/caronc/apprise)
- apprise/utils/pem.py:323: error: "None" has no attribute "public_bytes"  [attr-defined]

mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
+ bson/code.py:74: error: Unused "type: ignore" comment  [unused-ignore]
+ pymongo/synchronous/bulk.py:369: error: Argument 5 to "_BulkWriteContext" has incompatible type "_EventListeners | None"; expected "_EventListeners"  [arg-type]
+ pymongo/synchronous/bulk.py:404: error: Argument 3 to "_execute_batch" of "_Bulk" has incompatible type "islice[Any]"; expected "list[Mapping[str, Any]]"  [arg-type]
+ pymongo/synchronous/bulk.py:424: error: Argument 3 to "_execute_batch_unack" of "_Bulk" has incompatible type "islice[Any]"; expected "list[Mapping[str, Any]]"  [arg-type]
+ pymongo/synchronous/bulk.py:501: error: Argument 5 to "_BulkWriteContext" has incompatible type "_EventListeners | None"; expected "_EventListeners"  [arg-type]
+ pymongo/synchronous/bulk.py:516: error: Argument 3 to "_execute_batch_unack" of "_Bulk" has incompatible type "islice[Any]"; expected "list[Mapping[str, Any]]"  [arg-type]
+ pymongo/asynchronous/bulk.py:369: error: Argument 5 to "_BulkWriteContext" has incompatible type "_EventListeners | None"; expected "_EventListeners"  [arg-type]
+ pymongo/asynchronous/bulk.py:404: error: Argument 3 to "_execute_batch" of "_AsyncBulk" has incompatible type "islice[Any]"; expected "list[Mapping[str, Any]]"  [arg-type]
+ pymongo/asynchronous/bulk.py:424: error: Argument 3 to "_execute_batch_unack" of "_AsyncBulk" has incompatible type "islice[Any]"; expected "list[Mapping[str, Any]]"  [arg-type]
+ pymongo/asynchronous/bulk.py:503: error: Argument 5 to "_BulkWriteContext" has incompatible type "_EventListeners | None"; expected "_EventListeners"  [arg-type]
+ pymongo/asynchronous/bulk.py:518: error: Argument 3 to "_execute_batch_unack" of "_AsyncBulk" has incompatible type "islice[Any]"; expected "list[Mapping[str, Any]]"  [arg-type]

@ilevkivskyi

Copy link
Copy Markdown
Member Author

I think primer looks very good. New errors in mongo are real (were previously wrongly unreachable). There is a healthy doze of Returning Any from function, but I think they are justified. I spot-checked some of them, and they all look essentially like this (real example):

    def _match_version(self, got_tuple: tuple[int, ...]) -> bool:
        ...
        op: Callable[[tuple[int, ...], tuple[int, ...]], bool]
        op = getattr(operator, self._OP_NAMES[self.op])
        return op(got_tuple, version_tuple)

IMO this is exactly the case where this error should be given. Literally nothing prevents me from writing:

    def _match_version(self, got_tuple: tuple[int, ...]) -> Cake:
        ...
        op: Callable[[tuple[int, ...], tuple[int, ...]], Cake]
        op = getattr(operator, self._OP_NAMES[self.op])
        return op(got_tuple, version_tuple)

But this doesn't mean I will get a cake. I think these are all from people who can't have even a single # type: ignore in their code. They will be not happy, but 15 errors for them are definitely better than ~150 errors for other people.

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.

1 participant