Skip to content

Fixed bug that results in a false positive when accessing a generic a…#10305

Merged
erictraut merged 1 commit intomainfrom
issue-10304
Apr 11, 2025
Merged

Fixed bug that results in a false positive when accessing a generic a…#10305
erictraut merged 1 commit intomainfrom
issue-10304

Conversation

@erictraut
Copy link
Collaborator

…ttribute from an object whose type is type[X]. This addresses #10304.

…ttribute from an object whose type is `type[X]`. This addresses #10304.
@github-actions
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/tensor/tests/test_indexed.py:358:36 - error: Cannot access attribute "diff" for class "Relational"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:358:36 - error: Cannot access attribute "diff" for class "Unequality"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:360:36 - error: Cannot access attribute "diff" for class "Relational"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:360:36 - error: Cannot access attribute "diff" for class "Unequality"
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:363:36 - error: Cannot access attribute "diff" for class "Relational"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:363:36 - error: Cannot access attribute "diff" for class "Unequality"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:370:36 - error: Cannot access attribute "diff" for class "Relational"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:370:36 - error: Cannot access attribute "diff" for class "Unequality"
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:372:36 - error: Cannot access attribute "diff" for class "Relational"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:372:36 - error: Cannot access attribute "diff" for class "Unequality"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:374:36 - error: Cannot access attribute "diff" for class "Relational"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:374:36 - error: Cannot access attribute "diff" for class "Unequality"
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:376:36 - error: Cannot access attribute "diff" for class "Relational"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:376:36 - error: Cannot access attribute "diff" for class "Unequality"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:389:36 - error: Cannot access attribute "diff" for class "Relational"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:389:36 - error: Cannot access attribute "diff" for class "Unequality"
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:390:36 - error: Cannot access attribute "diff" for class "Relational"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:390:36 - error: Cannot access attribute "diff" for class "Unequality"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:394:38 - error: Cannot access attribute "diff" for class "Relational"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:394:38 - error: Cannot access attribute "diff" for class "Unequality"
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:395:38 - error: Cannot access attribute "diff" for class "Relational"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:395:38 - error: Cannot access attribute "diff" for class "Unequality"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:396:38 - error: Cannot access attribute "diff" for class "Relational"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:396:38 - error: Cannot access attribute "diff" for class "Unequality"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:397:38 - error: Cannot access attribute "diff" for class "Relational"
+     Attribute "diff" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_indexed.py:397:38 - error: Cannot access attribute "diff" for class "Unequality"
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:554:13 - error: Cannot access attribute "canon_bp" for class "Expr"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:554:13 - error: Cannot access attribute "canon_bp" for class "One"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:554:13 - error: Cannot access attribute "canon_bp" for class "Zero"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:554:13 - error: Cannot access attribute "canon_bp" for class "TensExpr"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:558:15 - error: Cannot access attribute "canon_bp" for class "Expr"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:558:15 - error: Cannot access attribute "canon_bp" for class "Zero"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:558:15 - error: Cannot access attribute "canon_bp" for class "One"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:558:15 - error: Cannot access attribute "canon_bp" for class "NegativeOne"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:558:15 - error: Cannot access attribute "canon_bp" for class "Integer"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:558:15 - error: Cannot access attribute "canon_bp" for class "Rational"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:558:15 - error: Cannot access attribute "canon_bp" for class "NaN"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:558:15 - error: Cannot access attribute "canon_bp" for class "ComplexInfinity"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:558:15 - error: Cannot access attribute "canon_bp" for class "Half"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:558:15 - error: Cannot access attribute "canon_bp" for class "Infinity"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:558:15 - error: Cannot access attribute "canon_bp" for class "NegativeInfinity"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:558:15 - error: Cannot access attribute "canon_bp" for class "Float"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:558:15 - error: Cannot access attribute "canon_bp" for class "Number"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:577:13 - error: Cannot access attribute "canon_bp" for class "Expr"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:577:13 - error: Cannot access attribute "canon_bp" for class "One"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:577:13 - error: Cannot access attribute "canon_bp" for class "NegativeOne"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:577:13 - error: Cannot access attribute "canon_bp" for class "Zero"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/tests/test_tensor.py:577:13 - error: Cannot access attribute "canon_bp" for class "Integer"
+     Attribute "canon_bp" is unknown (reportAttributeAccessIssue)

... (truncated 65 lines) ...

pytest (https://github.com/pytest-dev/pytest)
-   /tmp/mypy_primer/projects/pytest/src/_pytest/capture.py:933:56 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pytest/src/_pytest/capture.py:934:56 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pytest/src/_pytest/capture.py:966:48 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pytest/src/_pytest/capture.py:967:48 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues)
- 634 errors, 58 warnings, 0 informations 
+ 630 errors, 58 warnings, 0 informations 

hydpy (https://github.com/hydpy-dev/hydpy)
-   /tmp/mypy_primer/projects/hydpy/hydpy/docs/prepare.py:126:40 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues)
- 1324 errors, 49 warnings, 0 informations 
+ 1323 errors, 49 warnings, 0 informations 

pwndbg (https://github.com/pwndbg/pwndbg)
-   /tmp/mypy_primer/projects/pwndbg/pwndbg/aglib/heap/structs.py:175:42 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pwndbg/pwndbg/aglib/heap/structs.py:206:46 - error: Access to generic instance variable through class is ambiguous (reportGeneralTypeIssues)
- 2906 errors, 148 warnings, 0 informations 
+ 2904 errors, 148 warnings, 0 informations 

@erictraut erictraut merged commit 6b6a335 into main Apr 11, 2025
16 checks passed
@erictraut erictraut deleted the issue-10304 branch April 11, 2025 18:03
erictraut added a commit that referenced this pull request Jun 8, 2025
…eneric attribute from an object whose type is `type[X]`. This addresses #10304. (#10305)"

This reverts commit 6b6a335.
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