microsoft / pyright

Static Type Checker for Python
Other
13.04k stars 1.39k forks source link

Changed the behavior for eliding literals from a union when the non-l… #8395

Closed erictraut closed 1 month ago

erictraut commented 1 month ago

…iteral subtype is also present. This is still done for bool literals but not for other literal subtypes. This preserves more information in the union, which can be useful for completion suggestions.

github-actions[bot] commented 1 month ago

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


porcupine (https://github.com/Akuli/porcupine)
-   /tmp/mypy_primer/projects/porcupine/porcupine/plugins/directory_tree.py:414:22 - error: Operator "+" not supported for types "int" and "int | LiteralString"
+   /tmp/mypy_primer/projects/porcupine/porcupine/plugins/directory_tree.py:414:22 - error: Operator "+" not supported for types "int" and "int | LiteralString | Literal[0]"
-   /tmp/mypy_primer/projects/porcupine/porcupine/plugins/directory_tree.py:415:22 - error: Operator "+" not supported for types "int" and "int | LiteralString"
+   /tmp/mypy_primer/projects/porcupine/porcupine/plugins/directory_tree.py:415:22 - error: Operator "+" not supported for types "int" and "int | LiteralString | Literal[0]"
-   /tmp/mypy_primer/projects/porcupine/porcupine/plugins/directory_tree.py:415:22 - error: Operator "+" not supported for types "int | Unknown" and "int | LiteralString"
+   /tmp/mypy_primer/projects/porcupine/porcupine/plugins/directory_tree.py:415:22 - error: Operator "+" not supported for types "int | Unknown" and "int | LiteralString | Literal[0]"

pycryptodome (https://github.com/Legrandin/pycryptodome)
-   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/IO/PKCS8.py:168:17 - error: Operator "+=" not supported for types "Unbound | str" and "str"
+   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/IO/PKCS8.py:168:17 - error: Operator "+=" not supported for types "Unbound | str | Literal['PBES1[Invalid]']" and "str"
-   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/IO/PKCS8.py:170:17 - error: Operator "+=" not supported for types "Unbound | str" and "Literal[',PBES2[Invalid]']"
+   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/IO/PKCS8.py:170:17 - error: Operator "+=" not supported for types "Unbound | str | Literal['PBES1[Invalid]']" and "Literal[',PBES2[Invalid]']"
-   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/IO/_PBES.py:369:34 - error: Argument of type "DES3Mode" cannot be assigned to parameter "mode" of type "Literal[1]" in function "new"
+   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/IO/_PBES.py:369:34 - error: Argument of type "DES3Mode | Literal[2, 11]" cannot be assigned to parameter "mode" of type "Literal[1]" in function "new"
+     Type "DES3Mode | Literal[2, 11]" is incompatible with type "Literal[1]"
-     "DES3Mode" is incompatible with type "Literal[1]" (reportArgumentType)
+       "DES3Mode" is incompatible with type "Literal[1]" (reportArgumentType)
-   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/IO/_PBES.py:532:34 - error: Argument of type "DES3Mode" cannot be assigned to parameter "mode" of type "Literal[1]" in function "new"
+   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/IO/_PBES.py:532:34 - error: Argument of type "DES3Mode | Literal[2, 11]" cannot be assigned to parameter "mode" of type "Literal[1]" in function "new"
+     Type "DES3Mode | Literal[2, 11]" is incompatible with type "Literal[1]"
-     "DES3Mode" is incompatible with type "Literal[1]" (reportArgumentType)
+       "DES3Mode" is incompatible with type "Literal[1]" (reportArgumentType)
-     Return type mismatch: base method returns type "bool", override returns type "Unknown | IntegerBase | int | Any"
+     Return type mismatch: base method returns type "bool", override returns type "Unknown | IntegerBase | int | Any | Literal[0]"
-       Type "Unknown | IntegerBase | int | Any" is incompatible with type "bool"
+       Type "Unknown | IntegerBase | int | Any | Literal[0]" is incompatible with type "bool"

sympy (https://github.com/sympy/sympy)
-   /tmp/mypy_primer/projects/sympy/sympy/combinatorics/coset_table.py:791:16 - error: Operator ">=" not supported for types "None" and "int" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/combinatorics/coset_table.py:791:16 - error: Operator ">=" not supported for types "None" and "int | Literal[1]"
+     Operator ">=" not supported for types "None" and "int"
+     Operator ">=" not supported for types "None" and "Literal[1]" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/combinatorics/coset_table.py:792:20 - error: Operator ">" not supported for types "None" and "int" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/combinatorics/coset_table.py:792:20 - error: Operator ">" not supported for types "None" and "int | Literal[1]"
+     Operator ">" not supported for types "None" and "int"
+     Operator ">" not supported for types "None" and "Literal[1]" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/combinatorics/graycode.py:286:16 - error: No overloads for "rjust" match the provided arguments (reportCallIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/combinatorics/homomorphisms.py:403:13 - error: Argument of type "int" cannot be assigned to parameter "value" of type "None" in function "__setitem__"
+   /tmp/mypy_primer/projects/sympy/sympy/combinatorics/homomorphisms.py:403:13 - error: Argument of type "int | Literal[0]" cannot be assigned to parameter "value" of type "None" in function "__setitem__"
+     Type "int | Literal[0]" is incompatible with type "None"
-     "int" is incompatible with "None" (reportArgumentType)
+       "int" is incompatible with "None" (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/combinatorics/perm_groups.py:2215:21 - error: Argument of type "int" cannot be assigned to parameter "value" of type "None" in function "__setitem__"
+   /tmp/mypy_primer/projects/sympy/sympy/combinatorics/perm_groups.py:2215:21 - error: Argument of type "int | Literal[0]" cannot be assigned to parameter "value" of type "None" in function "__setitem__"
+     Type "int | Literal[0]" is incompatible with type "None"
-     "int" is incompatible with "None" (reportArgumentType)
+       "int" is incompatible with "None" (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/combinatorics/permutations.py:2799:13 - error: Operator "-" not supported for types "None" and "int" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/combinatorics/permutations.py:2799:13 - error: Operator "-" not supported for types "None" and "int | Literal[0]"
+     Operator "-" not supported for types "None" and "int"
+     Operator "-" not supported for types "None" and "Literal[0]" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/combinatorics/tests/test_group_numbers.py:11:32 - error: Operator "**" not supported for types "int | array[int] | Unknown | None" and "Literal[12]"
+   /tmp/mypy_primer/projects/sympy/sympy/combinatorics/tests/test_group_numbers.py:11:32 - error: Operator "**" not supported for types "int | array[int] | Unknown | Literal[2, 3, 4, 7, 8] | None" and "Literal[12]"
-   /tmp/mypy_primer/projects/sympy/sympy/combinatorics/tests/test_group_numbers.py:24:30 - error: Operator "**" not supported for types "int | array[int] | Unknown | None" and "Literal[2]"
+   /tmp/mypy_primer/projects/sympy/sympy/combinatorics/tests/test_group_numbers.py:24:30 - error: Operator "**" not supported for types "int | array[int] | Unknown | Literal[2, 3, 4, 7, 8] | None" and "Literal[2]"
-   /tmp/mypy_primer/projects/sympy/sympy/combinatorics/tests/test_group_numbers.py:46:29 - error: Operator "**" not supported for types "int | array[int] | Unknown | None" and "Literal[2]"
+   /tmp/mypy_primer/projects/sympy/sympy/combinatorics/tests/test_group_numbers.py:46:29 - error: Operator "**" not supported for types "int | array[int] | Unknown | Literal[2, 3, 4, 7, 8] | None" and "Literal[2]"
-   /tmp/mypy_primer/projects/sympy/sympy/concrete/products.py:565:24 - error: Operator "**" not supported for types "Basic" and "int" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/concrete/products.py:565:24 - error: Operator "**" not supported for types "Basic" and "int | Literal[1]"
+     Operator "**" not supported for types "Basic" and "int"
+     Operator "**" not supported for types "Basic" and "Literal[1]" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/concrete/summations.py:878:20 - error: Operator "*" not supported for types "int" and "Basic" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/concrete/summations.py:878:20 - error: Operator "*" not supported for types "int | Literal[1]" and "Basic"
+     Operator "*" not supported for types "int" and "Basic"
+     Operator "*" not supported for types "Literal[1]" and "Basic" (reportOperatorIssue)
-     Return type mismatch: base method returns type "tuple[Literal[5], Literal[0], str]", override returns type "tuple[Literal[4], int, str]"
+     Return type mismatch: base method returns type "tuple[Literal[5], Literal[0], str]", override returns type "tuple[Literal[4], int | Literal[0, 10000], str]"
-       "tuple[Literal[4], int, str]" is incompatible with "tuple[Literal[5], Literal[0], str]"
+       "tuple[Literal[4], int | Literal[0, 10000], str]" is incompatible with "tuple[Literal[5], Literal[0], str]"
-   /tmp/mypy_primer/projects/sympy/sympy/core/mul.py:670:13 - error: Operator "*=" not supported for types "Unknown | AccumulationBounds | Order | _NotImplementedType" and "int"
+   /tmp/mypy_primer/projects/sympy/sympy/core/mul.py:670:13 - error: Operator "*=" not supported for types "Unknown | AccumulationBounds | Order | _NotImplementedType" and "int | Literal[1]"
+     Operator "*" not supported for types "Order" and "int"
-     Operator "*" not supported for types "Order" and "int" (reportOperatorIssue)
+     Operator "*" not supported for types "Order" and "Literal[1]" (reportOperatorIssue)
-     Return type mismatch: base method returns type "tuple[Literal[5], Literal[0], str]", override returns type "tuple[Literal[4], int, str]"
+     Return type mismatch: base method returns type "tuple[Literal[5], Literal[0], str]", override returns type "tuple[Literal[4], int | Literal[0, 10000], str]"
-       "tuple[Literal[4], int, str]" is incompatible with "tuple[Literal[5], Literal[0], str]"
+       "tuple[Literal[4], int | Literal[0, 10000], str]" is incompatible with "tuple[Literal[5], Literal[0], str]"
-   /tmp/mypy_primer/projects/sympy/sympy/core/tests/test_numbers.py:1185:26 - error: Operator "*" not supported for types "int | Unknown | None" and "Pow"
+   /tmp/mypy_primer/projects/sympy/sympy/core/tests/test_numbers.py:1185:26 - error: Operator "*" not supported for types "int | Unknown | Literal[2, 3, 4, 7, 8] | None" and "Pow"
+     Operator "*" not supported for types "None" and "Pow"
+     Operator "*" not supported for types "Literal[2]" and "Pow"
+     Operator "*" not supported for types "Literal[3]" and "Pow"
+     Operator "*" not supported for types "Literal[4]" and "Pow"
+     Operator "*" not supported for types "Literal[7]" and "Pow"
-     Operator "*" not supported for types "None" and "Pow" (reportOperatorIssue)
+     Operator "*" not supported for types "Literal[8]" and "Pow" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/core/tests/test_numbers.py:1186:17 - error: Operator "*" not supported for types "Literal[4]" and "int | Unknown | None"
+   /tmp/mypy_primer/projects/sympy/sympy/core/tests/test_numbers.py:1186:17 - error: Operator "*" not supported for types "Literal[4]" and "int | Unknown | Literal[2, 3, 4, 7, 8] | None"
-   /tmp/mypy_primer/projects/sympy/sympy/crypto/tests/test_crypto.py:451:20 - error: Argument of type "int | Unknown | None" cannot be assigned to parameter "number" of type "int | SupportsIndex" in function "bin" (reportArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/crypto/tests/test_crypto.py:451:20 - error: Argument of type "int | Unknown | Literal[2, 3, 4, 7, 8] | None" cannot be assigned to parameter "number" of type "int | SupportsIndex" in function "bin" (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/crypto/tests/test_crypto.py:467:20 - error: Argument of type "int | Unknown | None" cannot be assigned to parameter "number" of type "int | SupportsIndex" in function "bin" (reportArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/crypto/tests/test_crypto.py:467:20 - error: Argument of type "int | Unknown | Literal[2, 3, 4, 7, 8] | None" cannot be assigned to parameter "number" of type "int | SupportsIndex" in function "bin" (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/crypto/tests/test_crypto.py:475:22 - error: Argument of type "int | Unknown | None" cannot be assigned to parameter "base" of type "_SupportsSomeKindOfPow" in function "pow" (reportArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/crypto/tests/test_crypto.py:475:22 - error: Argument of type "int | Unknown | Literal[2, 5, 3] | None" cannot be assigned to parameter "base" of type "_SupportsSomeKindOfPow" in function "pow" (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/crypto/tests/test_crypto.py:475:29 - error: Argument of type "int | Unknown | None" cannot be assigned to parameter "mod" of type "None" in function "pow"
+   /tmp/mypy_primer/projects/sympy/sympy/crypto/tests/test_crypto.py:475:29 - error: Argument of type "int | Unknown | Literal[2, 3, 4, 7, 8] | None" cannot be assigned to parameter "mod" of type "None" in function "pow"
-     Type "int | Unknown | None" is incompatible with type "None"
+     Type "int | Unknown | Literal[2, 3, 4, 7, 8] | None" is incompatible with type "None"
-   /tmp/mypy_primer/projects/sympy/sympy/discrete/transforms.py:165:14 - error: Argument of type "int | Unknown | None" cannot be assigned to parameter "base" of type "int" in function "pow"

... (truncated 357 lines) ...

pywin32 (https://github.com/mhammond/pywin32)
-   /tmp/mypy_primer/projects/pywin32/Pythonwin/pywin/framework/interact.py:594:29 - warning: Operator "+" not supported for types "object" and "Unknown | str"
+   /tmp/mypy_primer/projects/pywin32/Pythonwin/pywin/framework/interact.py:594:29 - warning: Operator "+" not supported for types "object" and "Unknown | str | Literal['\t', '']"
+     Operator "+" not supported for types "object" and "str"
+     Operator "+" not supported for types "object" and "Literal['\t']"
-     Operator "+" not supported for types "object" and "str" (reportOperatorIssue)
+     Operator "+" not supported for types "object" and "Literal['']" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/pywin32/Pythonwin/pywin/framework/editor/editor.py:262:27 - warning: Operator "/" not supported for types "float | int" and "str | int"
+   /tmp/mypy_primer/projects/pywin32/Pythonwin/pywin/framework/editor/editor.py:262:27 - warning: Operator "/" not supported for types "float | int | Literal[0]" and "str | int"
+     Operator "/" not supported for types "int" and "str"
-     Operator "/" not supported for types "int" and "str" (reportOperatorIssue)
+     Operator "/" not supported for types "Literal[0]" and "str" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/pywin32/Pythonwin/pywin/framework/editor/editor.py:265:23 - warning: Operator "/" not supported for types "Unknown | float | int" and "str | int"
+   /tmp/mypy_primer/projects/pywin32/Pythonwin/pywin/framework/editor/editor.py:265:23 - warning: Operator "/" not supported for types "Unknown | float | int | Literal[0]" and "str | int"
+     Operator "/" not supported for types "int" and "str"
-     Operator "/" not supported for types "int" and "str" (reportOperatorIssue)
+     Operator "/" not supported for types "Literal[0]" and "str" (reportOperatorIssue)

cloud-init (https://github.com/canonical/cloud-init)
-   /tmp/mypy_primer/projects/cloud-init/cloudinit/config/cc_growpart.py:447:31 - error: Argument of type "Unknown | str | Any | None" cannot be assigned to parameter "path" of type "FileDescriptorOrPath" in function "stat" (reportArgumentType)
+   /tmp/mypy_primer/projects/cloud-init/cloudinit/config/cc_growpart.py:447:31 - error: Argument of type "Unknown | str | Any | Literal['/dev/root'] | None" cannot be assigned to parameter "path" of type "FileDescriptorOrPath" in function "stat" (reportArgumentType)
-   /tmp/mypy_primer/projects/cloud-init/cloudinit/config/cc_growpart.py:470:56 - error: Argument of type "Unknown | str | Any | None" cannot be assigned to parameter "blockdev" of type "str" in function "get_mapped_device"
+   /tmp/mypy_primer/projects/cloud-init/cloudinit/config/cc_growpart.py:470:56 - error: Argument of type "Unknown | str | Any | Literal['/dev/root'] | None" cannot be assigned to parameter "blockdev" of type "str" in function "get_mapped_device"
-     Type "Unknown | str | Any | None" is incompatible with type "str"
+     Type "Unknown | str | Any | Literal['/dev/root'] | None" is incompatible with type "str"
-   /tmp/mypy_primer/projects/cloud-init/cloudinit/config/cc_growpart.py:514:51 - error: Argument of type "Unknown | str | Any | None" cannot be assigned to parameter "devpath" of type "str" in function "device_part_info"
+   /tmp/mypy_primer/projects/cloud-init/cloudinit/config/cc_growpart.py:514:51 - error: Argument of type "Unknown | str | Any | Literal['/dev/root'] | None" cannot be assigned to parameter "devpath" of type "str" in function "device_part_info"
-     Type "Unknown | str | Any | None" is incompatible with type "str"
+     Type "Unknown | str | Any | Literal['/dev/root'] | None" is incompatible with type "str"
-   /tmp/mypy_primer/projects/cloud-init/cloudinit/config/cc_seed_random.py:71:24 - error: Argument of type "bytes | str | Unknown" cannot be assigned to parameter "buffer" of type "ReadableBuffer" in function "write"
+   /tmp/mypy_primer/projects/cloud-init/cloudinit/config/cc_seed_random.py:71:24 - error: Argument of type "bytes | str | Unknown | Literal[b""]" cannot be assigned to parameter "buffer" of type "ReadableBuffer" in function "write"
-     Type "bytes | str | Unknown" is incompatible with type "ReadableBuffer"
+     Type "bytes | str | Unknown | Literal[b""]" is incompatible with type "ReadableBuffer"
-   /tmp/mypy_primer/projects/cloud-init/cloudinit/sources/DataSourceLXD.py:360:53 - error: Argument of type "str | bytes" cannot be assigned to parameter "url" of type "str" in function "_get_json_response"
+   /tmp/mypy_primer/projects/cloud-init/cloudinit/sources/DataSourceLXD.py:360:53 - error: Argument of type "str | bytes | Literal[b""]" cannot be assigned to parameter "url" of type "str" in function "_get_json_response"
-     Type "str | bytes" is incompatible with type "str"
+     Type "str | bytes | Literal[b""]" is incompatible with type "str"
-   /tmp/mypy_primer/projects/cloud-init/cloudinit/sources/DataSourceLXD.py:410:30 - error: Argument of type "str | bytes" cannot be assigned to parameter "url" of type "str" in function "_do_request"
+   /tmp/mypy_primer/projects/cloud-init/cloudinit/sources/DataSourceLXD.py:410:30 - error: Argument of type "str | bytes | Literal[b""]" cannot be assigned to parameter "url" of type "str" in function "_do_request"
-     Type "str | bytes" is incompatible with type "str"
+     Type "str | bytes | Literal[b""]" is incompatible with type "str"
-   /tmp/mypy_primer/projects/cloud-init/cloudinit/sources/DataSourceLXD.py:416:55 - error: Argument of type "str | bytes" cannot be assigned to parameter "url" of type "str" in function "_get_json_response"
+   /tmp/mypy_primer/projects/cloud-init/cloudinit/sources/DataSourceLXD.py:416:55 - error: Argument of type "str | bytes | Literal[b""]" cannot be assigned to parameter "url" of type "str" in function "_get_json_response"
-     Type "str | bytes" is incompatible with type "str"
+     Type "str | bytes | Literal[b""]" is incompatible with type "str"
+   /tmp/mypy_primer/projects/cloud-init/cloudinit/sources/DataSourceSmartOS.py:712:44 - error: Cannot access attribute "encode" for class "Literal[b""]"
+     Attribute "encode" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/cloud-init/doc/rtd/conf.py:241:5 - error: Operator "+=" not supported for types "str" and "str | Unknown | None"
+   /tmp/mypy_primer/projects/cloud-init/doc/rtd/conf.py:241:5 - error: Operator "+=" not supported for types "str | Literal['']" and "str | Unknown | Literal[''] | None"
+     Operator "+" not supported for types "str" and "None"
-     Operator "+" not supported for types "str" and "None" (reportOperatorIssue)
+     Operator "+" not supported for types "Literal['']" and "None" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/cloud-init/doc/rtd/conf.py:242:5 - error: Operator "+=" not supported for types "Unknown | str" and "str | Unknown | None"
+   /tmp/mypy_primer/projects/cloud-init/doc/rtd/conf.py:242:5 - error: Operator "+=" not supported for types "Unknown | str | Literal['']" and "str | Unknown | Literal[''] | None"
+     Operator "+" not supported for types "str" and "None"
-     Operator "+" not supported for types "str" and "None" (reportOperatorIssue)
+     Operator "+" not supported for types "Literal['']" and "None" (reportOperatorIssue)
-     Return type mismatch: base method returns type "str", override returns type "None"
+     Return type mismatch: base method returns type "str | Literal['iid-datasource']", override returns type "None"
+       Type "None" is incompatible with type "str | Literal['iid-datasource']"
+         "None" is incompatible with "str"
-       "None" is incompatible with "str" (reportIncompatibleMethodOverride)
+         "None" is incompatible with type "Literal['iid-datasource']" (reportIncompatibleMethodOverride)
- 1522 errors, 97 warnings, 0 informations 
+ 1523 errors, 97 warnings, 0 informations 

check-jsonschema (https://github.com/python-jsonschema/check-jsonschema)
-   /tmp/mypy_primer/projects/check-jsonschema/src/check_jsonschema/utils.py:77:48 - error: Operator "+" not supported for types "str | Unbound" and "str"
+   /tmp/mypy_primer/projects/check-jsonschema/src/check_jsonschema/utils.py:77:48 - error: Operator "+" not supported for types "str | Unbound | Literal['']" and "str"

pyodide (https://github.com/pyodide/pyodide)
-   /tmp/mypy_primer/projects/pyodide/src/py/pyodide/console.py:124:25 - error: Argument of type "str" cannot be assigned to parameter "return_mode" of type "ReturnMode" in function "__init__"
+   /tmp/mypy_primer/projects/pyodide/src/py/pyodide/console.py:124:25 - error: Argument of type "str | Literal['none']" cannot be assigned to parameter "return_mode" of type "ReturnMode" in function "__init__" (reportArgumentType)
-     Type "str" is incompatible with type "ReturnMode"
-       "str" is incompatible with type "Literal['last_expr']"
-       "str" is incompatible with type "Literal['last_expr_or_assign']"
-       "str" is incompatible with type "Literal['none']" (reportArgumentType)

scikit-learn (https://github.com/scikit-learn/scikit-learn)
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/calibration.py:409:43 - error: Cannot access attribute "split" for class "Literal[5]"
+     Attribute "split" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/discriminant_analysis.py:589:26 - error: Cannot access attribute "shape" for class "LiteralString"
+     Attribute "shape" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/discriminant_analysis.py:589:26 - error: Cannot access attribute "shape" for class "Literal['no_validation']"
+     Attribute "shape" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/discriminant_analysis.py:599:46 - error: Cannot access attribute "dtype" for class "LiteralString"
+     Attribute "dtype" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/discriminant_analysis.py:599:46 - error: Cannot access attribute "dtype" for class "Literal['no_validation']"
+     Attribute "dtype" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/discriminant_analysis.py:599:63 - error: Cannot access attribute "shape" for class "LiteralString"
+     Attribute "shape" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/discriminant_analysis.py:599:63 - error: Cannot access attribute "shape" for class "Literal['no_validation']"
+     Attribute "shape" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/discriminant_analysis.py:601:60 - error: Cannot access attribute "dtype" for class "LiteralString"
+     Attribute "dtype" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/discriminant_analysis.py:601:60 - error: Cannot access attribute "dtype" for class "Literal['no_validation']"
+     Attribute "dtype" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/discriminant_analysis.py:612:47 - error: Cannot access attribute "shape" for class "LiteralString"
+     Attribute "shape" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/discriminant_analysis.py:612:47 - error: Cannot access attribute "shape" for class "Literal['no_validation']"
+     Attribute "shape" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/discriminant_analysis.py:648:77 - error: Cannot access attribute "dtype" for class "LiteralString"
+     Attribute "dtype" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/discriminant_analysis.py:648:77 - error: Cannot access attribute "dtype" for class "Literal['no_validation']"
+     Attribute "dtype" is unknown (reportAttributeAccessIssue)
+     Attribute "dtype" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/discriminant_analysis.py:651:66 - error: Cannot access attribute "dtype" for class "LiteralString"
+     Attribute "dtype" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/discriminant_analysis.py:651:66 - error: Cannot access attribute "dtype" for class "Literal['no_validation']"
+     Attribute "shape" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/discriminant_analysis.py:910:35 - error: Cannot access attribute "shape" for class "LiteralString"
+     Attribute "shape" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/discriminant_analysis.py:910:35 - error: Cannot access attribute "shape" for class "Literal['no_validation']"
-   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:163:24 - error: Cannot access attribute "shape" for class "tuple[str, str]"
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:163:24 - error: Cannot access attribute "shape" for class "tuple[str | Literal['no_validation'], str | Literal['no_validation']]"
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:163:24 - error: Cannot access attribute "shape" for class "Literal['no_validation']"
+     Attribute "shape" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:359:24 - error: Cannot access attribute "shape" for class "tuple[str, str]"
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:359:24 - error: Cannot access attribute "shape" for class "tuple[str | Literal['no_validation'], str | Literal['no_validation']]"
+     Attribute "shape" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:359:24 - error: Cannot access attribute "shape" for class "Literal['no_validation']"
-   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:363:24 - error: Cannot access attribute "multiply" for class "tuple[str, str]"
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:363:24 - error: Cannot access attribute "multiply" for class "tuple[str | Literal['no_validation'], str | Literal['no_validation']]"
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:363:24 - error: Cannot access attribute "multiply" for class "Literal['no_validation']"
+     Attribute "multiply" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:363:49 - error: Cannot access attribute "mean" for class "tuple[str, str]"
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:363:49 - error: Cannot access attribute "mean" for class "tuple[str | Literal['no_validation'], str | Literal['no_validation']]"
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:363:49 - error: Cannot access attribute "mean" for class "Literal['no_validation']"
+     Attribute "mean" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:363:79 - error: Cannot access attribute "var" for class "tuple[str, str]"
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:363:79 - error: Cannot access attribute "var" for class "tuple[str | Literal['no_validation'], str | Literal['no_validation']]"
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:363:79 - error: Cannot access attribute "var" for class "Literal['no_validation']"
+     Attribute "var" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:373:14 - error: Cannot access attribute "dtype" for class "tuple[str, str]"
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:373:14 - error: Cannot access attribute "dtype" for class "tuple[str | Literal['no_validation'], str | Literal['no_validation']]"
+   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:373:14 - error: Cannot access attribute "dtype" for class "Literal['no_validation']"
+     Attribute "dtype" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/scikit-learn/sklearn/kernel_approximation.py:376:66 - error: Cannot access attribute "dtype" for class "tuple[str, str]"

... (truncated 872 lines) ...```