Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix new style union syntax in type aliases#14008

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JukkaL merged 14 commits intomasterfromfix-literal-union
Nov 7, 2022
Merged

Conversation

@JukkaL
Copy link
Collaborator

Fix Python 3.10| union syntax in type aliases, when one of
the operands is a type alias or a type with an overloaded__init__.

Fixes#12368.Fixes#12005.Fixes#11426.

@@ -0,0 +1,35 @@
from typing import Generic, TypeVar, Callable, Any, Mapping
Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Some tests were using the typeshed stub forfunctools, and it requirestyping._SpecialForm. Instead of adding a bunch oftyping-medium.pyi fixtures, I decided to create a simplified stub to use in tests. This also speeds up the test cases a bit.

@github-actions

This comment has been minimized.

@hauntsaninja
Copy link
Collaborator

pandas looks like a real issue, they probably meant to do_truthy_value: Scalar instead of_truthy_value = Scalar in the base class

@github-actions
Copy link
Contributor

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

Tanjun (https://github.com/FasterSpeeding/Tanjun)- tanjun/annotations.py:1064: error: Dict entry 6 has incompatible type "object": "Tuple[ToUser, ToRole]"; expected "Type[Any]": "Tuple[Union[Callable[[str], Coroutine[Any, Any, Any]], Callable[[str], Any]], ...]"  [dict-item]+ tanjun/annotations.py:1064: error: Dict entry 6 has incompatible type "<typing special form>": "Tuple[ToUser, ToRole]"; expected "Type[Any]": "Tuple[Union[Callable[[str], Coroutine[Any, Any, Any]], Callable[[str], Any]], ...]"  [dict-item]- tanjun/annotations.py:1072: error: List item 4 has incompatible type "object"; expected "Type[Any]"  [list-item]+ tanjun/annotations.py:1072: error: List item 4 has incompatible type "<typing special form>"; expected "Type[Any]"  [list-item]- tanjun/annotations.py:1247: error: Dict entry 6 has incompatible type "object": "Callable[[_ArgConfig, SlashCommand[Any], str], Self?]"; expected "Type[Any]": "Callable[[_ArgConfig, SlashCommand[Any], str], SlashCommand[Any]]"  [dict-item]+ tanjun/annotations.py:1247: error: Dict entry 6 has incompatible type "<typing special form>": "Callable[[_ArgConfig, SlashCommand[Any], str], Self?]"; expected "Type[Any]": "Callable[[_ArgConfig, SlashCommand[Any], str], SlashCommand[Any]]"  [dict-item]discord.py (https://github.com/Rapptz/discord.py)- discord/app_commands/transformers.py:728: error: Dict entry 0 has incompatible type "AppCommandOptionType": "Tuple[Type[str], object]"; expected "AppCommandOptionType": "Tuple[Type[Any], ...]"  [dict-item]+ discord/app_commands/transformers.py:728: error: Dict entry 0 has incompatible type "AppCommandOptionType": "Tuple[Type[str], <typing special form>]"; expected "AppCommandOptionType": "Tuple[Type[Any], ...]"  [dict-item]- discord/app_commands/transformers.py:729: error: Dict entry 1 has incompatible type "AppCommandOptionType": "Tuple[Type[int], object]"; expected "AppCommandOptionType": "Tuple[Type[Any], ...]"  [dict-item]+ discord/app_commands/transformers.py:729: error: Dict entry 1 has incompatible type "AppCommandOptionType": "Tuple[Type[int], <typing special form>]"; expected "AppCommandOptionType": "Tuple[Type[Any], ...]"  [dict-item]- discord/app_commands/transformers.py:730: error: Dict entry 2 has incompatible type "AppCommandOptionType": "Tuple[Type[bool], object]"; expected "AppCommandOptionType": "Tuple[Type[Any], ...]"  [dict-item]+ discord/app_commands/transformers.py:730: error: Dict entry 2 has incompatible type "AppCommandOptionType": "Tuple[Type[bool], <typing special form>]"; expected "AppCommandOptionType": "Tuple[Type[Any], ...]"  [dict-item]- discord/app_commands/transformers.py:731: error: Dict entry 3 has incompatible type "AppCommandOptionType": "Tuple[Type[float], object]"; expected "AppCommandOptionType": "Tuple[Type[Any], ...]"  [dict-item]+ discord/app_commands/transformers.py:731: error: Dict entry 3 has incompatible type "AppCommandOptionType": "Tuple[Type[float], <typing special form>]"; expected "AppCommandOptionType": "Tuple[Type[Any], ...]"  [dict-item]- discord/app_commands/transformers.py:738: error: Incompatible default for argument "_none" (default has type "object", argument has type "type")  [assignment]+ discord/app_commands/transformers.py:738: error: Incompatible default for argument "_none" (default has type "<typing special form>", argument has type "type")  [assignment]- discord/app_commands/commands.py:254: error: Incompatible default for argument "_none" (default has type "object", argument has type "type")  [assignment]+ discord/app_commands/commands.py:254: error: Incompatible default for argument "_none" (default has type "<typing special form>", argument has type "type")  [assignment]- discord/ext/commands/converter.py:1177: error: Argument 2 to "issubclass" has incompatible type "_SpecialForm"; expected "Union[type, UnionType, Tuple[Union[type, UnionType, Tuple[Any, ...]], ...]]"  [arg-type]+ discord/ext/commands/converter.py:1177: error: Argument 2 to "issubclass" has incompatible type "<typing special form>"; expected "Union[type, UnionType, Tuple[Union[type, UnionType, Tuple[Any, ...]], ...]]"  [arg-type]pandera (https://github.com/pandera-dev/pandera)- pandera/dtypes.py:23: error: Incompatible import of "Literal" (imported name has type "typing_extensions._SpecialForm", local name has type "typing._SpecialForm")  [assignment]+ pandera/dtypes.py:23: error: Incompatible import of "Literal" (imported name has type "typing_extensions._SpecialForm", local name has type "<typing special form>")  [assignment]- pandera/schemas.py:46: error: Incompatible import of "Literal" (imported name has type "typing_extensions._SpecialForm", local name has type "typing._SpecialForm")  [assignment]+ pandera/schemas.py:46: error: Incompatible import of "Literal" (imported name has type "typing_extensions._SpecialForm", local name has type "<typing special form>")  [assignment]pandas (https://github.com/pandas-dev/pandas)+ pandas/core/arrays/integer.py:135: error: Incompatible types in assignment (expression has type "int", base class "BaseMaskedArray" defined the type as "<typing special form>")  [assignment]+ pandas/core/arrays/integer.py:136: error: Incompatible types in assignment (expression has type "int", base class "BaseMaskedArray" defined the type as "<typing special form>")  [assignment]+ pandas/core/arrays/floating.py:119: error: Incompatible types in assignment (expression has type "float", base class "BaseMaskedArray" defined the type as "<typing special form>")  [assignment]+ pandas/core/arrays/floating.py:120: error: Incompatible types in assignment (expression has type "float", base class "BaseMaskedArray" defined the type as "<typing special form>")  [assignment]+ pandas/core/arrays/boolean.py:290: error: Incompatible types in assignment (expression has type "bool", base class "BaseMaskedArray" defined the type as "<typing special form>")  [assignment]+ pandas/core/arrays/boolean.py:291: error: Incompatible types in assignment (expression has type "bool", base class "BaseMaskedArray" defined the type as "<typing special form>")  [assignment]

@JukkaLJukkaL merged commit39d35cd intomasterNov 7, 2022
@JukkaLJukkaL deleted the fix-literal-union branchNovember 7, 2022 15:38
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ilevkivskyiilevkivskyiilevkivskyi approved these changes

@hauntsaninjahauntsaninjahauntsaninja approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

3 participants

@JukkaL@hauntsaninja@ilevkivskyi

[8]ページ先頭

©2009-2025 Movatter.jp