Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PEP 695] Enable new type parameter syntax by default #17798

Merged
merged 6 commits into from
Sep 20, 2024

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Sep 20, 2024

I think the PEP 695 syntax is supported well enough now to enable it by default.

Copy link
Contributor

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

artigraph (https://github.com/artigraph/artigraph)
+ src/arti/internal/utils.py:213: error: Incompatible default for argument "default" (default has type "None", argument has type "D")  [assignment]
+ src/arti/internal/utils.py:213: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
+ src/arti/internal/utils.py:213: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
- src/arti/internal/utils.py:25: error: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support  [valid-type]
- src/arti/internal/utils.py:25: error: Name "Ret" is not defined  [name-defined]
- src/arti/internal/utils.py:28: error: Unused "type: ignore[return-value]" comment  [unused-ignore]
- src/arti/internal/utils.py:213: error: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support  [valid-type]
- src/arti/internal/utils.py:213: error: Name "V" is not defined  [name-defined]
- src/arti/internal/utils.py:213: error: Name "D" is not defined  [name-defined]
- src/arti/internal/utils.py:230: error: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support  [valid-type]
- src/arti/internal/utils.py:231: error: Name "K" is not defined  [name-defined]
- src/arti/internal/utils.py:231: error: Name "V" is not defined  [name-defined]
- src/arti/internal/utils.py:232: error: Name "V" is not defined  [name-defined]
- src/arti/internal/utils.py:262: error: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support  [valid-type]
- src/arti/internal/utils.py:262: error: Name "K" is not defined  [name-defined]
- src/arti/internal/utils.py:262: error: Name "V" is not defined  [name-defined]
+ src/arti/internal/type_hints.py:119: error: Incompatible default for argument "default" (default has type "None", argument has type "D")  [assignment]
+ src/arti/internal/type_hints.py:119: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
+ src/arti/internal/type_hints.py:119: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
+ src/arti/internal/type_hints.py:125: error: Incompatible default for argument "default" (default has type "None", argument has type "D")  [assignment]
+ src/arti/internal/type_hints.py:125: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
+ src/arti/internal/type_hints.py:125: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
+ src/arti/internal/type_hints.py:130: error: Incompatible default for argument "default" (default has type "None", argument has type "D")  [assignment]
+ src/arti/internal/type_hints.py:130: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
+ src/arti/internal/type_hints.py:130: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
+ src/arti/internal/type_hints.py:139: error: Argument 2 has incompatible type "type[T@get_item_from_annotated]"; expected "T@lenient_issubclass"  [arg-type]
+ src/arti/internal/type_hints.py:177: error: Argument 2 to "_check_issubclass" has incompatible type "T"; expected "type"  [arg-type]
- src/arti/internal/type_hints.py:118: error: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support  [valid-type]
- src/arti/internal/type_hints.py:119: error: Name "T" is not defined  [name-defined]
- src/arti/internal/type_hints.py:119: error: Name "D" is not defined  [name-defined]
- src/arti/internal/type_hints.py:120: error: Name "T" is not defined  [name-defined]
- src/arti/internal/type_hints.py:120: error: Name "D" is not defined  [name-defined]
- src/arti/internal/type_hints.py:124: error: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support  [valid-type]
- src/arti/internal/type_hints.py:125: error: Name "T" is not defined  [name-defined]
- src/arti/internal/type_hints.py:125: error: Name "D" is not defined  [name-defined]
- src/arti/internal/type_hints.py:126: error: Name "T" is not defined  [name-defined]
- src/arti/internal/type_hints.py:126: error: Name "D" is not defined  [name-defined]
- src/arti/internal/type_hints.py:129: error: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support  [valid-type]
- src/arti/internal/type_hints.py:130: error: Name "T" is not defined  [name-defined]
- src/arti/internal/type_hints.py:130: error: Name "D" is not defined  [name-defined]
- src/arti/internal/type_hints.py:131: error: Name "T" is not defined  [name-defined]
- src/arti/internal/type_hints.py:131: error: Name "D" is not defined  [name-defined]
- src/arti/internal/type_hints.py:166: error: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support  [valid-type]
- src/arti/internal/type_hints.py:166: error: Name "T" is not defined  [name-defined]
- src/arti/internal/mappings.py:14: error: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support  [valid-type]
- src/arti/internal/mappings.py:14: error: Name "K" is not defined  [name-defined]
- src/arti/internal/mappings.py:14: error: Name "V" is not defined  [name-defined]
- src/arti/internal/mappings.py:15: error: Name "K" is not defined  [name-defined]
- src/arti/internal/mappings.py:15: error: Name "V" is not defined  [name-defined]
- src/arti/internal/mappings.py:16: error: Name "K" is not defined  [name-defined]
- src/arti/internal/mappings.py:16: error: Name "V" is not defined  [name-defined]
- src/arti/internal/mappings.py:21: error: Name "K" is not defined  [name-defined]
- src/arti/internal/mappings.py:21: error: Name "V" is not defined  [name-defined]
- src/arti/internal/mappings.py:27: error: Name "K" is not defined  [name-defined]
- src/arti/internal/mappings.py:33: error: Name "K" is not defined  [name-defined]
- src/arti/internal/mappings.py:33: error: Name "V" is not defined  [name-defined]
- src/arti/internal/mappings.py:33: error: "frozendict" expects no type arguments, but 2 given  [type-arg]
- src/arti/internal/mappings.py:47: error: Name "K" is not defined  [name-defined]
- src/arti/internal/mappings.py:47: error: Name "V" is not defined  [name-defined]
+ src/arti/internal/mappings.py:100: error: ClassVar cannot contain type variables  [misc]
- src/arti/internal/mappings.py:64: error: PEP 695 type aliases are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support  [valid-type]
- src/arti/internal/mappings.py:64: error: Name "K" is not defined  [name-defined]
- src/arti/internal/mappings.py:64: error: Name "V" is not defined  [name-defined]
- src/arti/internal/mappings.py:76: error: PEP 695 type aliases are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support  [valid-type]
- src/arti/internal/mappings.py:76: error: Name "V" is not defined  [name-defined]
- src/arti/internal/mappings.py:76: error: The type "type[TypedBox]" is not generic and not indexable  [misc]
- src/arti/internal/mappings.py:76: error: Name "TypedBox" is used before definition  [used-before-def]
- src/arti/internal/mappings.py:79: error: PEP 695 type aliases are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support  [valid-type]
- src/arti/internal/mappings.py:79: error: Name "InputContainer" is used before definition  [used-before-def]
- src/arti/internal/mappings.py:80: error: PEP 695 type aliases are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support  [valid-type]
- src/arti/internal/mappings.py:80: error: Variable "arti.internal.mappings.InputElement" is not valid as a type  [valid-type]
- src/arti/internal/mappings.py:80: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- src/arti/internal/mappings.py:94: error: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support  [valid-type]
- src/arti/internal/mappings.py:94: error: Variable "arti.internal.mappings.TypedNode" is not valid as a type  [valid-type]
- src/arti/internal/mappings.py:94: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- src/arti/internal/mappings.py:94: error: Name "V" is not defined  [name-defined]
- src/arti/internal/mappings.py:100: error: Name "V" is not defined  [name-defined]
- src/arti/internal/mappings.py:103: error: Name "V" is not defined  [name-defined]
- src/arti/internal/mappings.py:119: error: Variable "arti.internal.mappings.InputElement" is not valid as a type  [valid-type]
- src/arti/internal/mappings.py:119: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- src/arti/internal/mappings.py:125: error: Variable "arti.internal.mappings.TypedNode" is not valid as a type  [valid-type]
- src/arti/internal/mappings.py:125: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- src/arti/internal/mappings.py:125: error: Name "V" is not defined  [name-defined]
- src/arti/internal/mappings.py:132: error: Name "V" is not defined  [name-defined]
- src/arti/internal/mappings.py:145: error: Variable "arti.internal.mappings.TypedNode" is not valid as a type  [valid-type]
- src/arti/internal/mappings.py:145: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases

... (truncated 160 lines) ...

core (https://github.com/home-assistant/core)
+ Warning: NewGenericSyntax is already enabled by default

@JukkaL JukkaL merged commit 5dfc7d9 into master Sep 20, 2024
20 checks passed
@JukkaL JukkaL deleted the enable-pep695-syntax branch September 20, 2024 13:31
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.

2 participants