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 that results in a false negative when two import statements… #9755

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

erictraut
Copy link
Collaborator

… shadow the same symbol and an attribute is accessed between the two import statements. This addresses #9752.

… shadow the same symbol and an attribute is accessed between the two import statements. This addresses #9752.
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/utilities/tests/test_matchpy_connector.py:120:70 - error: Argument of type "list[Unequality | Unknown | Equality | Relational]" cannot be assigned to parameter "conditions_nonfalse" of type "List[Expr]" in function "add"
+   /tmp/mypy_primer/projects/sympy/sympy/utilities/tests/test_matchpy_connector.py:120:70 - error: Argument of type "list[Unequality | Integer]" cannot be assigned to parameter "conditions_nonfalse" of type "List[Expr]" in function "add"
-     Type "Unequality | Unknown | Equality | Relational" is not assignable to type "Expr"
+     Type "Unequality | Integer" is not assignable to type "Expr"
-       "Relational" is not assignable to "Expr"
+       "Unequality" is not assignable to "Expr"
-     Type "Unequality | Unknown | Equality | Relational" is not assignable to type "Expr"
+     Type "Unequality | Integer" is not assignable to type "Expr"
-       "Relational" is not assignable to "Expr"
+       "Unequality" is not assignable to "Expr"
-     Type "Unequality | Unknown | Equality | Relational" is not assignable to type "Expr"
+     Type "Unequality | Integer" is not assignable to type "Expr"
-       "Relational" is not assignable to "Expr"
+       "Unequality" is not assignable to "Expr"
-     Type "Unequality | Unknown | Equality | Relational" is not assignable to type "Expr"
+     Type "Unequality | Integer" is not assignable to type "Expr"
-       "Relational" is not assignable to "Expr" (reportArgumentType)
+       "Unequality" is not assignable to "Expr" (reportArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/vector/implicitregion.py:114:20 - error: Operator "**" not supported for "None" (reportOptionalOperand)
+   /tmp/mypy_primer/projects/sympy/sympy/vector/implicitregion.py:114:28 - error: Operator "*" not supported for types "Literal[4]" and "One | Zero | Expr | Unknown | Any | None"
+     Operator "*" not supported for types "Literal[4]" and "None" (reportOperatorIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/vector/implicitregion.py:503:30 - error: "coeff" is not a known attribute of "None" (reportOptionalMemberAccess)
+   /tmp/mypy_primer/projects/sympy/sympy/vector/implicitregion.py:504:30 - error: "coeff" is not a known attribute of "None" (reportOptionalMemberAccess)
+   /tmp/mypy_primer/projects/sympy/sympy/vector/implicitregion.py:505:30 - error: "coeff" is not a known attribute of "None" (reportOptionalMemberAccess)
-   /tmp/mypy_primer/projects/sympy/sympy/vector/operators.py:49:9 - error: Method "doit" overrides class "Basic" in an incompatible manner
-     Return type mismatch: base method returns type "Gradient", override returns type "VectorZero | Unknown | VectorAdd | Gradient"
-       Type "VectorZero | Unknown | VectorAdd | Gradient" is not assignable to type "Gradient"
-         "VectorAdd" is not assignable to "Gradient" (reportIncompatibleMethodOverride)
-     Return type mismatch: base method returns type "tuple[Expr, Expr]", override returns type "tuple[Self@Mul, Zero] | tuple[Zero, Expr] | tuple[Expr, Expr] | tuple[Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType, Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType] | tuple[Unknown, Unknown] | None"
-       Type "tuple[Self@Mul, Zero] | tuple[Zero, Expr] | tuple[Expr, Expr] | tuple[Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType, Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType] | tuple[Unknown, Unknown] | None" is not assignable to type "tuple[Expr, Expr]"
+     Return type mismatch: base method returns type "tuple[Expr, Expr]", override returns type "tuple[Self@Mul, Zero] | tuple[Zero, Expr] | tuple[Expr, Expr] | tuple[Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType, Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType] | tuple[Expr | Any | Unknown, Expr | Any | Unknown] | tuple[Expr | Any | Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | Number, Expr | Any | Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | Number] | None"
+       Type "tuple[Self@Mul, Zero] | tuple[Zero, Expr] | tuple[Expr, Expr] | tuple[Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType, Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType] | tuple[Expr | Any | Unknown, Expr | Any | Unknown] | tuple[Expr | Any | Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | Number, Expr | Any | Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | Number] | None" is not assignable to type "tuple[Expr, Expr]"
- 32998 errors, 73 warnings, 0 informations 
+ 33002 errors, 73 warnings, 0 informations 

mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
-   /tmp/mypy_primer/projects/mongo-python-driver/pymongo/ssl_support.py:54:16 - error: Type "SSLError" is not assignable to declared type "type[SSLError]"
+   /tmp/mypy_primer/projects/mongo-python-driver/pymongo/ssl_support.py:54:16 - error: Type "pymongo.pyopenssl_context.SSLError | pymongo.ssl_context.SSLError" is not assignable to declared type "type[SSLError]"
+     Type "pymongo.pyopenssl_context.SSLError | pymongo.ssl_context.SSLError" is not assignable to type "type[SSLError]"
-     "SSLError" is not assignable to "type[SSLError]"
+       "SSLError" is not assignable to "type[SSLError]"
-     Type "SSLError" is not assignable to type "type[SSLError]" (reportAssignmentType)
+       Type "SSLError" is not assignable to type "type[SSLError]" (reportAssignmentType)
+   /tmp/mypy_primer/projects/mongo-python-driver/pymongo/ssl_support.py:105:16 - error: Type "pymongo.pyopenssl_context.SSLContext | ssl.SSLContext" is not assignable to return type "SSLContext"
+     Type "pymongo.pyopenssl_context.SSLContext | ssl.SSLContext" is not assignable to type "SSLContext"
+       "ssl.SSLContext" is not assignable to "pymongo.pyopenssl_context.SSLContext" (reportReturnType)
- 1167 errors, 28 warnings, 0 informations 
+ 1168 errors, 28 warnings, 0 informations 

websockets (https://github.com/aaugustin/websockets)
- /tmp/mypy_primer/projects/websockets/src/websockets/__init__.py
-   /tmp/mypy_primer/projects/websockets/src/websockets/__init__.py:75:11 - error: "TYPE_CHECKING" is not a known attribute of module "typing" (reportAttributeAccessIssue)
- 992 errors, 15 warnings, 0 informations 
+ 991 errors, 15 warnings, 0 informations 

@erictraut erictraut merged commit 9f71e14 into main Jan 24, 2025
17 of 18 checks passed
@erictraut erictraut deleted the issue-9752-3 branch January 24, 2025 22:21
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