================================================================================
#21607: mypy cannot decide if a cast is necessary or redundant
Labels: bug, topic-literal-types, topic-inference
Link: https://github.com/python/mypy/issues/21607
@@ -1,3 +1,2 @@
-gh_21607_body_0.py:14: error: Redundant cast to "Literal['apple', 'orange']" [redundant-cast]
gh_21607_body_0.py:15: error: Cannot infer value of type parameter "T" of "function" [misc]
-Found 2 errors in 1 file (checked 1 source file)
+Found 1 error in 1 file (checked 1 source file)
================================================================================
#21050: Generic `NamedTuple` does appear attribute-less in `match` statements, and member type information is erased
Labels: bug
Link: https://github.com/python/mypy/issues/21050
@@ -1,2 +1 @@
-gh_21050_body_0.py:12: error: Returning Any from function declared to return "int" [no-any-return]
-Found 1 error in 1 file (checked 1 source file)
+Success: no issues found in 1 source file
================================================================================
#19761: Inconsistent processing Literal as TypeVar
Labels: bug, topic-casts, topic-type-context
Link: https://github.com/python/mypy/issues/19761
@@ -1,4 +1,3 @@
-gh_19761_body_1.py:9: error: Redundant cast to "Literal['a']" [redundant-cast]
gh_19761_body_1.py:11: note: Revealed type is "str"
gh_19761_body_1.py:12: note: Revealed type is "Literal['a']"
-Found 1 error in 1 file (checked 1 source file)
+Success: no issues found in 1 source file
@@ -1,4 +1,3 @@
-gh_19761_body_0.py:6: error: Redundant cast to "Literal['a']" [redundant-cast]
gh_19761_body_0.py:7: note: Revealed type is "str"
gh_19761_body_0.py:8: note: Revealed type is "Literal['a']"
-Found 1 error in 1 file (checked 1 source file)
+Success: no issues found in 1 source file
================================================================================
#19055: Regression: false positive avoid redundant cast with literal union
Labels: bug
Link: https://github.com/python/mypy/issues/19055
@@ -1,2 +1 @@
-gh_19055_c2866388785_0.py:6: error: Redundant cast to "Literal['a', 'b']" [redundant-cast]
-Found 1 error in 1 file (checked 1 source file)
+Success: no issues found in 1 source file
@@ -1,2 +1 @@
-gh_19055_body_0.py:9: error: Redundant cast to "Literal['a', 'b']" [redundant-cast]
-Found 1 error in 1 file (checked 1 source file)
+Success: no issues found in 1 source file
================================================================================
#16819: Type Narrowing: `if val == Literal` should always narrow to Literal
Labels: feature, topic-literal-types, topic-type-narrowing
Link: https://github.com/python/mypy/issues/16819
@@ -1,4 +1,3 @@
gh_16819_body_0.py:2: error: Function is missing a return type annotation [no-untyped-def]
gh_16819_body_0.py:7: error: Function is missing a return type annotation [no-untyped-def]
-gh_16819_body_0.py:10: error: Incompatible types in assignment (expression has type "str", variable has type "Literal['a'] | None") [assignment]
-Found 3 errors in 1 file (checked 1 source file)
+Found 2 errors in 1 file (checked 1 source file)
@@ -1,14 +1,10 @@
gh_16819_body_1.py:3: error: Function is missing a return type annotation [no-untyped-def]
gh_16819_body_1.py:7: error: Function is missing a return type annotation [no-untyped-def]
-gh_16819_body_1.py:10: note: Revealed type is "str"
-gh_16819_body_1.py:11: error: Argument 1 to "only_ab" has incompatible type "str"; expected "Literal['a', 'b']" [arg-type]
-gh_16819_body_1.py:13: error: Argument 1 to "only_ab" has incompatible type "str"; expected "Literal['a', 'b']" [arg-type]
+gh_16819_body_1.py:10: note: Revealed type is "Literal['a']? | Literal['b']?"
gh_16819_body_1.py:15: error: Function is missing a return type annotation [no-untyped-def]
gh_16819_body_1.py:19: note: Revealed type is "Literal['a'] | Literal['b']"
-gh_16819_body_1.py:22: error: Argument 1 to "only_ab" has incompatible type "str"; expected "Literal['a', 'b']" [arg-type]
gh_16819_body_1.py:24: error: Function is missing a return type annotation [no-untyped-def]
gh_16819_body_1.py:28: note: Revealed type is "Literal['a'] | Literal['b']"
-gh_16819_body_1.py:31: error: Argument 1 to "only_ab" has incompatible type "str"; expected "Literal['a', 'b']" [arg-type]
gh_16819_body_1.py:34: error: Function is missing a return type annotation [no-untyped-def]
gh_16819_body_1.py:37: note: Revealed type is "Literal['a'] | Literal['b']"
gh_16819_body_1.py:42: error: Function is missing a return type annotation [no-untyped-def]
@@ -17,5 +13,4 @@
gh_16819_body_1.py:55: note: Revealed type is "Literal['a'] | Literal['b']"
gh_16819_body_1.py:61: error: Function is missing a return type annotation [no-untyped-def]
gh_16819_body_1.py:66: error: Function is missing a return type annotation [no-untyped-def]
-gh_16819_body_1.py:69: error: Incompatible types in assignment (expression has type "str", variable has type "Literal['a'] | None") [assignment]
-Found 14 errors in 1 file (checked 1 source file)
+Found 9 errors in 1 file (checked 1 source file)
================================================================================
#16534: Mypy doesn't assign TypedDict output as Literals
Labels: feature, topic-typed-dict
Link: https://github.com/python/mypy/issues/16534
@@ -1,2 +1 @@
-gh_16534_c1820871810_0.py:22: error: TypedDict key must be a string literal; expected one of ("b", "c", "d") [literal-required]
-Found 1 error in 1 file (checked 1 source file)
+Success: no issues found in 1 source file
================================================================================
#15106: Support type narrowing literals using `typing.get_args()`
Labels: feature, topic-type-narrowing
Link: https://github.com/python/mypy/issues/15106
@@ -1,2 +1 @@
-gh_15106_c2106305410_0.py:7: error: Incompatible return value type (got "str", expected "Literal['foo', 'bar', 'baz'] | None") [return-value]
-Found 1 error in 1 file (checked 1 source file)
+Success: no issues found in 1 source file
================================================================================
#12535: Narrowing types to `Literal` using `in` syntax
Labels: feature, topic-literal-types, topic-type-narrowing
Link: https://github.com/python/mypy/issues/12535
@@ -1,2 +1 @@
-gh_12535_c1677620108_0.py:8: error: Argument 1 to "takes_foo" has incompatible type "str"; expected "Literal['foo']" [arg-type]
-Found 1 error in 1 file (checked 1 source file)
+Success: no issues found in 1 source file
@@ -1,5 +1,5 @@
gh_12535_body_0.py:2: note: Revealed type is "str"
-gh_12535_body_0.py:4: note: Revealed type is "str"
+gh_12535_body_0.py:4: note: Revealed type is "Literal['a']? | Literal['b']? | Literal['c']?"
gh_12535_body_0.py:7: note: Revealed type is "int"
-gh_12535_body_0.py:9: note: Revealed type is "int"
+gh_12535_body_0.py:9: note: Revealed type is "Literal[10]? | Literal[20]? | Literal[50]?"
Success: no issues found in 1 source file
================================================================================
#10028: Literal typeguard
Labels: feature, topic-type-narrowing
Link: https://github.com/python/mypy/issues/10028
@@ -1,4 +1,3 @@
gh_10028_body_0.py:4: error: Function is missing a return type annotation [no-untyped-def]
gh_10028_body_0.py:8: error: Function is missing a return type annotation [no-untyped-def]
-gh_10028_body_0.py:15: error: Argument 1 to "f" has incompatible type "str"; expected "Literal['a', 'b']" [arg-type]
-Found 3 errors in 1 file (checked 1 source file)
+Found 2 errors in 1 file (checked 1 source file)
================================================================================
#5359: TypedDict item insertion support
Labels: feature, topic-typed-dict, priority-1-normal
Link: https://github.com/python/mypy/issues/5359
@@ -1,3 +1 @@
-gh_5359_body_0.py:12: error: TypedDict key must be a string literal; expected one of ("children", "vars", "hosts") [literal-required]
-gh_5359_body_0.py:16: error: TypedDict key must be a string literal; expected one of ("children", "vars", "hosts") [literal-required]
-Found 2 errors in 1 file (checked 1 source file)
+Success: no issues found in 1 source file
Found 10 issues with different output.