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 issue that results in a false positive "type could not be deter… #9323

Merged
merged 1 commit into from
Oct 24, 2024

Conversation

erictraut
Copy link
Collaborator

…mined because it refers to itself" error caused by a false dependency due to narrowing logic. This may also improve type analysis performance in some code. This addresses #9139.

…mined because it refers to itself" error caused by a false dependency due to narrowing logic. This may also improve type analysis performance in some code. This addresses #9139.
Copy link
Contributor

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

sympy (https://github.com/sympy/sympy)
+   /tmp/mypy_primer/projects/sympy/sympy/codegen/algorithms.py:110:21 - error: Argument of type "Print" cannot be assigned to parameter "object" of type "Declaration" in function "append"
+     "Print" is not assignable to "Declaration" (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/ast.py:401:8 - error: Class definition for "NoneToken" depends on itself (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/ast.py:1511:27 - error: Cannot access attribute "cast_check" for class "Token*"
-     Attribute "cast_check" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:324:40 - error: Cannot access attribute "cast_check" for class "Token*"
-     Attribute "cast_check" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:325:20 - error: Cannot access attribute "cast_check" for class "Token*"
-     Attribute "cast_check" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:326:20 - error: Cannot access attribute "cast_check" for class "Token*"
-     Attribute "cast_check" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:327:20 - error: Cannot access attribute "cast_check" for class "Token*"
-     Attribute "cast_check" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:454:16 - error: Cannot access attribute "dig" for class "Token*"
-     Attribute "dig" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:455:16 - error: Cannot access attribute "dig" for class "Token*"
-     Attribute "dig" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:460:16 - error: Cannot access attribute "decimal_dig" for class "Token*"
-     Attribute "decimal_dig" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:461:16 - error: Cannot access attribute "decimal_dig" for class "Token*"
-     Attribute "decimal_dig" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:466:16 - error: Cannot access attribute "max_exponent" for class "Token*"
-     Attribute "max_exponent" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:467:16 - error: Cannot access attribute "max_exponent" for class "Token*"
-     Attribute "max_exponent" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:472:16 - error: Cannot access attribute "min_exponent" for class "Token*"
-     Attribute "min_exponent" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:473:16 - error: Cannot access attribute "min_exponent" for class "Token*"
-     Attribute "min_exponent" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:478:78 - error: Operator "-" not supported for type "type[__class_UndefinedFunction] | Literal[6]" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:479:87 - error: Operator "-" not supported for type "type[__class_UndefinedFunction] | Literal[15]" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:478:20 - error: Cannot access attribute "eps" for class "Token*"
-     Attribute "eps" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:478:83 - error: Cannot access attribute "dig" for class "Token*"
-     Attribute "dig" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:479:20 - error: Cannot access attribute "eps" for class "Token*"
-     Attribute "eps" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:479:92 - error: Cannot access attribute "dig" for class "Token*"
-     Attribute "dig" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:484:79 - error: Operator "-" not supported for type "type[__class_UndefinedFunction] | Literal[6]" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:485:89 - error: Operator "-" not supported for type "type[__class_UndefinedFunction] | Literal[15]" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:484:20 - error: Cannot access attribute "max" for class "Token*"
-     Attribute "max" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:484:84 - error: Cannot access attribute "dig" for class "Token*"
-     Attribute "dig" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:485:20 - error: Cannot access attribute "max" for class "Token*"
-     Attribute "max" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:485:94 - error: Cannot access attribute "dig" for class "Token*"
-     Attribute "dig" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:491:80 - error: Operator "-" not supported for type "type[__class_UndefinedFunction] | Literal[6]" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:492:90 - error: Operator "-" not supported for type "type[__class_UndefinedFunction] | Literal[15]" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:491:20 - error: Cannot access attribute "tiny" for class "Token*"
-     Attribute "tiny" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:491:85 - error: Cannot access attribute "dig" for class "Token*"
-     Attribute "dig" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:492:20 - error: Cannot access attribute "tiny" for class "Token*"
-     Attribute "tiny" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:492:95 - error: Cannot access attribute "dig" for class "Token*"
-     Attribute "dig" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:496:16 - error: Cannot access attribute "cast_check" for class "Token*"
-     Attribute "cast_check" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:497:20 - error: Cannot access attribute "cast_check" for class "Token*"
-     Attribute "cast_check" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:498:27 - error: Cannot access attribute "cast_check" for class "Token*"
-     Attribute "cast_check" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:500:16 - error: Cannot access attribute "cast_nocheck" for class "Token*"
-     Attribute "cast_nocheck" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:501:16 - error: Cannot access attribute "cast_nocheck" for class "Token*"
-     Attribute "cast_nocheck" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:502:16 - error: Cannot access attribute "cast_nocheck" for class "Token*"
-     Attribute "cast_nocheck" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:503:16 - error: Cannot access attribute "cast_nocheck" for class "Token*"
-     Attribute "cast_nocheck" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:504:27 - error: Cannot access attribute "cast_nocheck" for class "Token*"
-     Attribute "cast_nocheck" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:511:36 - error: Cannot access attribute "cast_check" for class "Token*"
-     Attribute "cast_check" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:512:36 - error: Cannot access attribute "cast_check" for class "Token*"
-     Attribute "cast_check" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:513:36 - error: Cannot access attribute "cast_check" for class "Token*"
-     Attribute "cast_check" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:514:36 - error: Cannot access attribute "cast_check" for class "Token*"
-     Attribute "cast_check" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:515:36 - error: Cannot access attribute "cast_check" for class "Token*"
-     Attribute "cast_check" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:516:36 - error: Cannot access attribute "cast_check" for class "Token*"
-     Attribute "cast_check" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:519:28 - error: Cannot access attribute "cast_check" for class "Token*"
-     Attribute "cast_check" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/codegen/tests/test_ast.py:525:36 - error: Cannot access attribute "cast_check" for class "Token*"
-     Attribute "cast_check" is unknown (reportAttributeAccessIssue)

... (truncated 23 lines) ...

@erictraut erictraut merged commit 5537ec9 into main Oct 24, 2024
18 checks passed
@erictraut erictraut deleted the issue-9139 branch October 24, 2024 22:57
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.

1 participant