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 issues with type aliases and new style unions#14181

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 16 commits intomasterfromfix-type-union
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
16 commits
Select commitHold shift + click to select a range
8d90d97
Fix issues with type aliases and new style unions
JukkaLNov 4, 2022
acd93db
Black
JukkaLNov 7, 2022
51660b0
Fix test case
JukkaLNov 7, 2022
f73ee51
WIP add failing cases
JukkaLNov 7, 2022
096d8bd
Fix aliases in stubs
JukkaLNov 24, 2022
3e4e809
Update test case
JukkaLNov 24, 2022
a732e7a
Add test case covering #14158
JukkaLNov 24, 2022
41cd383
Minor tweaks
JukkaLNov 24, 2022
afc8754
Fix TreeTransform
JukkaLNov 24, 2022
ceee87b
Fix aststrip
JukkaLNov 24, 2022
8666b55
A few additional fixes + add test case
JukkaLNov 24, 2022
7a7284b
Fix type check
JukkaLNov 24, 2022
0716501
Black
JukkaLNov 24, 2022
d178f7f
Merge remote-tracking branch 'origin/master' into fix-type-union
JukkaLNov 24, 2022
ac2df6c
Remove accidentally added test stub
JukkaLNov 24, 2022
3980050
Merge branch 'master' into fix-type-union
JukkaLNov 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Fix aststrip
  • Loading branch information
@JukkaL
JukkaL committedNov 24, 2022
commitceee87bee619341f0ba9852a4fde09116a79c06f
4 changes: 4 additions & 0 deletionsmypy/server/aststrip.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -222,6 +222,10 @@ def visit_index_expr(self, node: IndexExpr) -> None:
node.analyzed = None # May have been an alias or type application.
super().visit_index_expr(node)

def visit_op_expr(self, node: OpExpr) -> None:
node.analyzed = None # May have been an alias
super().visit_op_expr(node)

def strip_ref_expr(self, node: RefExpr) -> None:
node.kind = None
node.node = None
Expand Down
31 changes: 31 additions & 0 deletionstest-data/unit/fine-grained.test
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10277,3 +10277,34 @@ A = str
m.py:5: error: Invalid statement in TypedDict definition; expected "field_name: field_type"
==
m.py:5: error: Invalid statement in TypedDict definition; expected "field_name: field_type"

[case testTypeAliasWithNewStyleUnionChangedToVariable]
# flags: --python-version 3.10
import a

[file a.py]
from b import C, D
A = C | D
a: A
reveal_type(a)

[file b.py]
C = int
D = str

[file b.py.2]
C = "x"
D = "y"

[file b.py.3]
C = str
D = int
[out]
a.py:4: note: Revealed type is "Union[builtins.int, builtins.str]"
==
a.py:2: error: Unsupported left operand type for | ("str")
a.py:3: error: Variable "a.A" is not valid as a type
a.py:3: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
a.py:4: note: Revealed type is "A?"
==
a.py:4: note: Revealed type is "Union[builtins.str, builtins.int]"

[8]ページ先頭

©2009-2025 Movatter.jp