Skip to content

Add TypeGuards to builtins Methods#15467

Closed
George-Ogden wants to merge 4 commits intopython:mainfrom
George-Ogden:builtin-typeguard
Closed

Add TypeGuards to builtins Methods#15467
George-Ogden wants to merge 4 commits intopython:mainfrom
George-Ogden:builtin-typeguard

Conversation

@George-Ogden
Copy link

Start with equality of common classes to see changes in mypy_primer

@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:

schema_salad (https://github.com/common-workflow-language/schema_salad)
+ schema_salad/jsonld_context.py: note: In function "pred":
+ schema_salad/jsonld_context.py:53:31: error: Subclass of "str" and "MutableMapping[Any, Any]" cannot exist: would have incompatible method signatures  [unreachable]
+ schema_salad/jsonld_context.py:54:21: error: Statement is unreachable  [unreachable]
+ schema_salad/schema.py: note: In function "get_anon_name":
+ schema_salad/schema.py:433:27: error: Subclass of "str" and "Mapping[Any, Any]" cannot exist: would have incompatible method signatures  [unreachable]
+ schema_salad/schema.py:434:17: error: Statement is unreachable  [unreachable]

xarray (https://github.com/pydata/xarray)
+ .../projects/_xarray_venv/lib/python3.13/site-packages/pandas-stubs/io/formats/style.pyi:17: note: ... from here,
+ .../projects/_xarray_venv/lib/python3.13/site-packages/pandas-stubs/core/frame.pyi:176: note: ... from here,
+ .../projects/_xarray_venv/lib/python3.13/site-packages/pandas-stubs/_typing.pyi:36: note: ... from here,
+ xarray/core/extension_array.py:27: note: ... from here:

sympy (https://github.com/sympy/sympy)
+ sympy/diffgeom/diffgeom.py:2261: error: Definition of "__contains__" in base class "_deprecated_container" is incompatible with definition in base class "list"  [misc]

urllib3 (https://github.com/urllib3/urllib3)
+ src/urllib3/_collections.py:196: error: Signature of "__contains__" incompatible with supertype "builtins.set"  [override]
+ src/urllib3/_collections.py:196: note:      Superclass:
+ src/urllib3/_collections.py:196: note:          def __contains__(self, object, /) -> TypeGuard[tuple[str, str]]
+ src/urllib3/_collections.py:196: note:      Subclass:
+ src/urllib3/_collections.py:196: note:          def __contains__(self, object, /) -> bool

mkdocs (https://github.com/mkdocs/mkdocs)
+ mkdocs/utils/templates.py:47: error: Subclass of "ExtraScriptValue" and "str" cannot exist: would have incompatible method signatures  [unreachable]

django-stubs (https://github.com/typeddjango/django-stubs)
+ django-stubs/test/utils.pyi:36: error: Signature of "__contains__" incompatible with supertype "builtins.list"  [override]
+ django-stubs/test/utils.pyi:36: note:      Superclass:
+ django-stubs/test/utils.pyi:36: note:          def __contains__(self, object, /) -> TypeGuard[dict[str, Any]]
+ django-stubs/test/utils.pyi:36: note:      Subclass:
+ django-stubs/test/utils.pyi:36: note:          def __contains__(self, object, /) -> bool

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