-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix Incompatible return value type error message for long tuple with Union and non-Union type mismatch
#18881
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
Changes from 2 commits
a58a971
220a2f4
11a6c13
9109962
57177bf
e36a0c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1665,6 +1665,45 @@ a.f = a.f # E: Property "f" defined in "A" is read-only | |
| a.f.x # E: "int" has no attribute "x" | ||
| [builtins fixtures/property.pyi] | ||
|
|
||
| [case testPropertyWithTupleUnionAndNonUnionMismatchReturnValueType] | ||
| from typing import Tuple, Union | ||
| class A: | ||
| a: str | ||
| b: str | ||
| c: str | ||
| d: str | ||
| e: str | ||
| f: str | ||
| g: Union[str, int] | ||
| h: Union[str, float] | ||
| i: Union[str, None] | ||
| j: Union[str, None] | ||
| k: Union[str, None] | ||
| l: Union[str, None] | ||
|
|
||
| @property | ||
| def x(self) -> Tuple[str, str, str, str, str, str, str, str, str, str, str, str]: | ||
|
||
| return ( | ||
| self.a, | ||
| self.b, | ||
| self.c, | ||
| self.d, | ||
| self.e, | ||
| self.f, | ||
| self.g, | ||
| self.h, | ||
| self.i, | ||
| self.j, | ||
| self.k, | ||
| self.l, | ||
| ) | ||
| [out] | ||
| main:18: error: Incompatible return value type (6 tuple items are incompatible; 3 items are omitted) | ||
| main:18: note: Expression tuple item 6 has type "Union[str, int]"; "str" expected; | ||
| main:18: note: Expression tuple item 7 has type "Union[str, float]"; "str" expected; | ||
| main:18: note: Expression tuple item 8 has type "Optional[str]"; "str" expected; | ||
| [builtins fixtures/property.pyi] | ||
|
|
||
| -- Descriptors | ||
| -- ----------- | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.