[ty] Format conflicting types as an enumeration (#18956)
## Summary Format conflicting declared types as ``` `str`, `int` and `bytes` ``` Thanks to @AlexWaygood for the initial draft. @dcreager, looking forward to your one-character follow-up PR.
This commit is contained in:
@@ -16,7 +16,7 @@ def _(flag: bool):
|
||||
else:
|
||||
x: int
|
||||
|
||||
x = 1 # error: [conflicting-declarations] "Conflicting declared types for `x`: str, int"
|
||||
x = 1 # error: [conflicting-declarations] "Conflicting declared types for `x`: `str` and `int`"
|
||||
```
|
||||
|
||||
## Incompatible declarations for 2 (out of 3) types
|
||||
@@ -29,7 +29,7 @@ def _(flag1: bool, flag2: bool):
|
||||
x: int
|
||||
|
||||
# Here, the declared type for `x` is `int | str | Unknown`.
|
||||
x = 1 # error: [conflicting-declarations] "Conflicting declared types for `x`: str, int"
|
||||
x = 1 # error: [conflicting-declarations] "Conflicting declared types for `x`: `str` and `int`"
|
||||
```
|
||||
|
||||
## Incompatible declarations with repeated types
|
||||
@@ -47,7 +47,7 @@ def _(flag1: bool, flag2: bool, flag3: bool, flag4: bool):
|
||||
else:
|
||||
x: bytes
|
||||
|
||||
x = "a" # error: [conflicting-declarations] "Conflicting declared types for `x`: str, int, bytes"
|
||||
x = "a" # error: [conflicting-declarations] "Conflicting declared types for `x`: `str`, `int` and `bytes`"
|
||||
```
|
||||
|
||||
## Incompatible declarations with bad assignment
|
||||
|
||||
Reference in New Issue
Block a user