Skip to content
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

Fixed bug in x is <Literal> and x == <Literal> type guard logic. … #6110

Merged
merged 1 commit into from
Oct 10, 2023

Conversation

erictraut
Copy link
Collaborator

…It was not properly handling the case where x is Any or Unknown. This addresses #6109.

…It was not properly handling the case where `x` is `Any` or `Unknown`. This addresses #6109.
@erictraut erictraut merged commit 3ae1d11 into main Oct 10, 2023
@erictraut erictraut deleted the issue6109 branch October 10, 2023 02:20
@github-actions
Copy link
Contributor

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

spack (https://github.com/spack/spack)
+   /tmp/mypy_primer/projects/spack/lib/spack/spack/test/spec_semantics.py:807:28 - error: Cannot access member "family" for type "Literal['x86_64']"
+     Member "family" is unknown (reportGeneralTypeIssues)
- 3873 errors, 48 warnings, 0 informations 
+ 3874 errors, 48 warnings, 0 informations 

Tanjun (https://github.com/FasterSpeeding/Tanjun)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:1472:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:1498:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:1617:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:1680:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:1885:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:1949:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:2104:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:2188:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:2337:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:2360:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:2496:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:2519:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:2655:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:2678:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:2748:16 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:2766:16 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:2809:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:2833:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:3027:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:3050:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:3186:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/Tanjun/tests/commands/test_slash.py:3209:19 - warning: Argument type is unknown
-     Argument corresponds to parameter "__key" in function "__getitem__" (reportUnknownArgumentType)
- 2344 errors, 9841 warnings, 0 informations 
+ 2344 errors, 9819 warnings, 0 informations 

dd-trace-py (https://github.com/DataDog/dd-trace-py)
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/appsec/_iast/taint_sinks/ast_taint.py:33:46 - error: Operator "+" not supported for types "Literal['Random.']" and "Any | None"
+     Operator "+" not supported for types "Literal['Random.']" and "None" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/contrib/botocore/patch.py:585:52 - error: Argument of type "Any | None" cannot be assigned to parameter "endpoint_name" of type "str" in function "_add_api_param_span_tags"
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/contrib/botocore/patch.py:585:52 - error: Argument of type "Any | Literal['sns', 'kinesis', 'events', 'sqs', 'lambda'] | None" cannot be assigned to parameter "endpoint_name" of type "str" in function "_add_api_param_span_tags"
-     Type "Any | None" cannot be assigned to type "str"
+     Type "Any | Literal['sns', 'kinesis', 'events', 'sqs', 'lambda'] | None" cannot be assigned to type "str"
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/dogstatsd/base.py:469:76 - error: Argument of type "float | Unknown" cannot be assigned to parameter "sample_rate" of type "int" in function "_serialize_metric"
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/dogstatsd/base.py:469:76 - error: Argument of type "float | Unknown | Literal[1]" cannot be assigned to parameter "sample_rate" of type "int" in function "_serialize_metric"
-     Type "float | Unknown" cannot be assigned to type "int"
+     Type "float | Unknown | Literal[1]" cannot be assigned to type "int"
- 9364 errors, 465 warnings, 0 informations 
+ 9365 errors, 465 warnings, 0 informations 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants