Skip to content

gh-15770: Use TypeForm in __class_getitem__ signatures#15776

Draft
Andrew5057 wants to merge 4 commits into
python:mainfrom
Andrew5057:typeform-generic-classgetitem
Draft

gh-15770: Use TypeForm in __class_getitem__ signatures#15776
Andrew5057 wants to merge 4 commits into
python:mainfrom
Andrew5057:typeform-generic-classgetitem

Conversation

@Andrew5057
Copy link
Copy Markdown
Contributor

Addresses #15770.

TypeForm has been accepted for 3.15. When major type checkers adopt stable support for it (mypy is the most important holdout right now), we can hopefully start using it throughout the standard library to reject invalid parameterizations.

@github-actions
Copy link
Copy Markdown
Contributor

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

static-frame (https://github.com/static-frame/static-frame)
+ static_frame/core/type_clinic.py:786: error: Argument 1 to "__class_getitem__" of "tuple" has incompatible type "tuple[Any, ...]"; expected "TypeForm[Any]"  [arg-type]

scikit-learn (https://github.com/scikit-learn/scikit-learn)
+ sklearn/conftest.py:347: error: Definition of "__class_getitem__" in base class "dict" is incompatible with definition in base class "spmatrix"  [misc]

discord.py (https://github.com/Rapptz/discord.py)
+ discord/ext/commands/converter.py:1143: error: Argument 1 of "__class_getitem__" is incompatible with supertype "builtins.list"; supertype defines the argument type as "TypeForm[Any]"  [override]
+ discord/ext/commands/converter.py:1143: note: This violates the Liskov substitution principle
+ discord/ext/commands/converter.py:1143: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides

cwltool (https://github.com/common-workflow-language/cwltool)
+ .../projects/_cwltool_venv/lib/python3.13/site-packages/galaxy/tool_util_models/parameter_validators.py:24: note: ... from here,
+ .../projects/_cwltool_venv/lib/python3.13/site-packages/galaxy/tool_util_models/parameters.py:57: note: ... from here,
+ .../projects/_cwltool_venv/lib/python3.13/site-packages/galaxy/tool_util_models/__init__.py:31: note: ... from here:

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