Skip to content

Fixed a bug that results in a false negative for a method override th…#10209

Merged
erictraut merged 1 commit intomainfrom
overrideSelf
Mar 29, 2025
Merged

Fixed a bug that results in a false negative for a method override th…#10209
erictraut merged 1 commit intomainfrom
overrideSelf

Conversation

@erictraut
Copy link
Copy Markdown
Collaborator

…at uses Self in a contravariant position. This addresses https://discuss.python.org/t/unsoundness-of-contravariant-self-type/86338.

@github-actions
Copy link
Copy Markdown
Contributor

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

pycryptodome (https://github.com/Legrandin/pycryptodome)
-   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/Util/asn1.py:322:13 - error: Method "decode" overrides class "DerObject" in an incompatible manner
-     Return type mismatch: base method returns type "DerInteger", override returns type "DerObject"
-       "DerObject" is not assignable to "DerInteger" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/Util/asn1.py:412:9 - error: Method "decode" overrides class "DerObject" in an incompatible manner
-     Return type mismatch: base method returns type "DerBoolean", override returns type "DerObject"
-       "DerObject" is not assignable to "DerBoolean" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/Util/asn1.py:588:13 - error: Method "decode" overrides class "DerObject" in an incompatible manner
-     Return type mismatch: base method returns type "DerSequence", override returns type "DerObject"
-       "DerObject" is not assignable to "DerSequence" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/Util/asn1.py:779:9 - error: Method "decode" overrides class "DerObject" in an incompatible manner
-     Return type mismatch: base method returns type "DerObjectId", override returns type "DerObject"
-       "DerObject" is not assignable to "DerObjectId" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/Util/asn1.py:884:9 - error: Method "decode" overrides class "DerObject" in an incompatible manner
-     Return type mismatch: base method returns type "DerBitString", override returns type "DerObject"
-       "DerObject" is not assignable to "DerBitString" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/Util/asn1.py:996:9 - error: Method "decode" overrides class "DerObject" in an incompatible manner
-     Return type mismatch: base method returns type "DerSetOf", override returns type "DerObject"
-       "DerObject" is not assignable to "DerSetOf" (reportIncompatibleMethodOverride)
- 1783 errors, 55 warnings, 0 informations 
+ 1777 errors, 55 warnings, 0 informations 

ibis (https://github.com/ibis-project/ibis)
-     Return type mismatch: base method returns type "Relation", override returns type "Relation | Node"
+     Return type mismatch: base method returns type "Coercible", override returns type "Relation | Node"
-       Type "Relation | Node" is not assignable to type "Relation"
+       Type "Relation | Node" is not assignable to type "Coercible"
-         "Node" is not assignable to "Relation" (reportIncompatibleMethodOverride)
+         "Node" is not assignable to "Coercible" (reportIncompatibleMethodOverride)

sympy (https://github.com/sympy/sympy)
-       Return type mismatch: base method returns type "type[String]", override returns type "() -> String"
+       Return type mismatch: base method returns type "type[Basic]", override returns type "() -> String"
-         Type "() -> String" is not assignable to type "type[String]" (reportIncompatibleMethodOverride)
+         Type "() -> String" is not assignable to type "type[Basic]" (reportIncompatibleMethodOverride)
-     Return type mismatch: base method returns type "Product", override returns type "tuple[Unknown, ...] | Unknown | Product | Basic | ComplexInfinity | Expr | Float | Half | Infinity | Integer | NaN | NegativeInfinity | NegativeOne | Number | One | Rational | Zero"
+     Return type mismatch: base method returns type "Basic", override returns type "tuple[Unknown, ...] | Unknown | Product | Basic | ComplexInfinity | Expr | Float | Half | Infinity | Integer | NaN | NegativeInfinity | NegativeOne | Number | One | Rational | Zero"
-       Type "tuple[Unknown, ...] | Unknown | Product | Basic | ComplexInfinity | Expr | Float | Half | Infinity | Integer | NaN | NegativeInfinity | NegativeOne | Number | One | Rational | Zero" is not assignable to type "Product"
+       Type "tuple[Unknown, ...] | Unknown | Product | Basic | ComplexInfinity | Expr | Float | Half | Infinity | Integer | NaN | NegativeInfinity | NegativeOne | Number | One | Rational | Zero" is not assignable to type "Basic"
-         "Basic" is not assignable to "Product" (reportIncompatibleMethodOverride)
+         "tuple[Unknown, ...]" is not assignable to "Basic" (reportIncompatibleMethodOverride)
-     Return type mismatch: base method returns type "Sum", override returns type "tuple[Unknown, ...] | Unknown | Sum | Expr | Zero | NaN | Piecewise | Basic | Equality | None"
+     Return type mismatch: base method returns type "Basic", override returns type "tuple[Unknown, ...] | Unknown | Sum | Expr | Zero | NaN | Piecewise | Basic | Equality | None"
-       Type "tuple[Unknown, ...] | Unknown | Sum | Expr | Zero | NaN | Piecewise | Basic | Equality | None" is not assignable to type "Sum"
+       Type "tuple[Unknown, ...] | Unknown | Sum | Expr | Zero | NaN | Piecewise | Basic | Equality | None" is not assignable to type "Basic"
-         "Basic" is not assignable to "Sum" (reportIncompatibleMethodOverride)
+         "tuple[Unknown, ...]" is not assignable to "Basic" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/sympy/sympy/core/add.py:1011:9 - error: Method "_eval_as_leading_term" overrides class "Expr" in an incompatible manner
-     Return type mismatch: base method returns type "Add", override returns type "Unknown | Order | Expr | Any | Zero"
-       Type "Unknown | Order | Expr | Any | Zero" is not assignable to type "Add"
-   /tmp/mypy_primer/projects/sympy/sympy/core/add.py:1175:9 - error: Method "as_content_primitive" overrides class "Expr" in an incompatible manner
-     Return type mismatch: base method returns type "tuple[One, Add]", override returns type "tuple[One | NegativeOne | Zero | Integer | Expr | ComplexInfinity | Rational | NaN | Half | Infinity | NegativeInfinity | Float | _NotImplementedType, Expr | Unknown | Add]"
-       "tuple[One | NegativeOne | Zero | Integer | Expr | ComplexInfinity | Rational | NaN | Half | Infinity | NegativeInfinity | Float | _NotImplementedType, Expr | Unknown | Add]" is not assignable to "tuple[One, Add]"
-         Tuple entry 2 is incorrect type
-           Type "Expr | Unknown | Add" is not assignable to type "Add"
-             "Expr" is not assignable to "Add" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/sympy/sympy/core/expr.py:4097:9 - error: Method "doit" overrides class "Basic" in an incompatible manner
-     Return type mismatch: base method returns type "UnevaluatedExpr", override returns type "Basic"
-       "Basic" is not assignable to "UnevaluatedExpr" (reportIncompatibleMethodOverride)
-     Return type mismatch: base method returns type "Derivative", override returns type "Unknown | ArrayDerivative | Derivative | Zero | Literal[0]"
+     Return type mismatch: base method returns type "Expr", override returns type "Unknown | ArrayDerivative | Derivative | Zero | Literal[0]"
-       Type "Unknown | ArrayDerivative | Derivative | Zero | Literal[0]" is not assignable to type "Derivative"
+       Type "Unknown | ArrayDerivative | Derivative | Zero | Literal[0]" is not assignable to type "Expr"
-         "Literal[0]" is not assignable to "Derivative" (reportIncompatibleMethodOverride)
+         "Literal[0]" is not assignable to "Expr" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/sympy/sympy/core/function.py:2251:9 - error: Method "doit" overrides class "Basic" in an incompatible manner
-     Return type mismatch: base method returns type "Subs", override returns type "Basic | Unknown"
-       Type "Basic | Unknown" is not assignable to type "Subs"
-         "Basic" is not assignable to "Subs" (reportIncompatibleMethodOverride)
-     Return type mismatch: base method returns type "tuple[One, Rational]", override returns type "tuple[Rational, One] | tuple[Rational | NaN | ComplexInfinity | One | NegativeOne | Zero | Integer | Half, NegativeOne] | tuple[One, Never]"
+     Return type mismatch: base method returns type "tuple[One, Expr]", override returns type "tuple[Rational, One] | tuple[Rational | NaN | ComplexInfinity | One | NegativeOne | Zero | Integer | Half, NegativeOne] | tuple[One, Never]"
-       Type "tuple[Rational, One] | tuple[Rational | NaN | ComplexInfinity | One | NegativeOne | Zero | Integer | Half, NegativeOne] | tuple[One, Never]" is not assignable to type "tuple[One, Rational]"
+       Type "tuple[Rational, One] | tuple[Rational | NaN | ComplexInfinity | One | NegativeOne | Zero | Integer | Half, NegativeOne] | tuple[One, Never]" is not assignable to type "tuple[One, Expr]"
-         "tuple[Rational, One]" is not assignable to "tuple[One, Rational]"
+         "tuple[Rational, One]" is not assignable to "tuple[One, Expr]"
-   /tmp/mypy_primer/projects/sympy/sympy/core/power.py:1650:9 - error: Method "_eval_as_leading_term" overrides class "Expr" in an incompatible manner
-     Return type mismatch: base method returns type "Pow", override returns type "Unknown | Expr | Pow"
-       Type "Unknown | Expr | Pow" is not assignable to type "Pow"
-         "Expr" is not assignable to "Pow" (reportIncompatibleMethodOverride)
-     Return type mismatch: base method returns type "tuple[One, Pow]", override returns type "tuple[Pow, Pow] | tuple[Number, Pow] | tuple[One, Pow]"
+     Return type mismatch: base method returns type "tuple[One, Expr]", override returns type "tuple[Pow, Pow] | tuple[Number, Pow] | tuple[One, Pow]"
-       Type "tuple[Pow, Pow] | tuple[Number, Pow] | tuple[One, Pow]" is not assignable to type "tuple[One, Pow]"
+       Type "tuple[Pow, Pow] | tuple[Number, Pow] | tuple[One, Pow]" is not assignable to type "tuple[One, Expr]"
-         "tuple[Number, Pow]" is not assignable to "tuple[One, Pow]"
+         "tuple[Number, Pow]" is not assignable to "tuple[One, Expr]"
-     Return type mismatch: base method returns type "factorial", override returns type "One | factorial"
+     Return type mismatch: base method returns type "Function", override returns type "One | factorial"
-       Type "One | factorial" is not assignable to type "factorial"
+       Type "One | factorial" is not assignable to type "Function"
-         "One" is not assignable to "factorial" (reportIncompatibleMethodOverride)
+         "One" is not assignable to "Function" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/sympy/sympy/functions/elementary/complexes.py:323:9 - error: Method "doit" overrides class "Basic" in an incompatible manner
-     Return type mismatch: base method returns type "sign", override returns type "Expr | sign"
-       Type "Expr | sign" is not assignable to type "sign"
-         "Expr" is not assignable to "sign" (reportIncompatibleMethodOverride)
-     Return type mismatch: base method returns type "arg", override returns type "Zero | Unknown"
+     Return type mismatch: base method returns type "Function", override returns type "Zero | Unknown"
-       Type "Zero | Unknown" is not assignable to type "arg"
+       Type "Zero | Unknown" is not assignable to type "Function"
-         "Zero" is not assignable to "arg" (reportIncompatibleMethodOverride)
+         "Zero" is not assignable to "Function" (reportIncompatibleMethodOverride)
-     Return type mismatch: base method returns type "conjugate | Expr | None", override returns type "Basic"
+     Return type mismatch: base method returns type "Expr | None", override returns type "Basic"
-       Type "Basic" is not assignable to type "conjugate | Expr | None"
+       Type "Basic" is not assignable to type "Expr | None"
-         "Basic" is not assignable to "conjugate"
-     Return type mismatch: base method returns type "transpose | Expr | None", override returns type "Basic"
+     Return type mismatch: base method returns type "Expr | None", override returns type "Basic"
-       Type "Basic" is not assignable to type "transpose | Expr | None"
+       Type "Basic" is not assignable to type "Expr | None"
-         "Basic" is not assignable to "transpose"
-     Return type mismatch: base method returns type "adjoint | Expr | None", override returns type "Basic"
+     Return type mismatch: base method returns type "Expr | None", override returns type "Basic"
-       Type "Basic" is not assignable to type "adjoint | Expr | None"
+       Type "Basic" is not assignable to type "Expr | None"
-         "Basic" is not assignable to "adjoint"
-     Return type mismatch: base method returns type "tuple[exp_polar, Mul]", override returns type "tuple[exp_polar, One] | tuple[ExpBase, Mul]"

... (truncated 1062 lines) ...

bokeh (https://github.com/bokeh/bokeh)
-     Return type mismatch: base method returns type "PropertyValueList[T@PropertyValueList]", override returns type "Self@PropertyValueList[T@PropertyValueList]"
+     Return type mismatch: base method returns type "list[T@PropertyValueList]", override returns type "Self@PropertyValueList[T@PropertyValueList]"
-       "PropertyValueList[T@PropertyValueList]*" is not assignable to "PropertyValueList[T@PropertyValueList]"
+       "PropertyValueList[T@PropertyValueList]*" is not assignable to "list[T@PropertyValueList]"
-         Type parameter "T@PropertyValueList" is invariant, but "T@PropertyValueList" is not the same as "T@PropertyValueList" (reportIncompatibleMethodOverride)
+         Type parameter "_T@list" is invariant, but "T@PropertyValueList" is not the same as "T@PropertyValueList"
+         Consider switching from "list" to "Sequence" which is covariant (reportIncompatibleMethodOverride)
-     Return type mismatch: base method returns type "PropertyValueList[T@PropertyValueList]", override returns type "Self@PropertyValueList[T@PropertyValueList]"
+     Return type mismatch: base method returns type "list[T@PropertyValueList]", override returns type "Self@PropertyValueList[T@PropertyValueList]"
-       "PropertyValueList[T@PropertyValueList]*" is not assignable to "PropertyValueList[T@PropertyValueList]"
+       "PropertyValueList[T@PropertyValueList]*" is not assignable to "list[T@PropertyValueList]"
-         Type parameter "T@PropertyValueList" is invariant, but "T@PropertyValueList" is not the same as "T@PropertyValueList" (reportIncompatibleMethodOverride)
+         Type parameter "_T@list" is invariant, but "T@PropertyValueList" is not the same as "T@PropertyValueList"
+         Consider switching from "list" to "Sequence" which is covariant (reportIncompatibleMethodOverride)

scikit-learn (https://github.com/scikit-learn/scikit-learn)
-     Return type mismatch: base method returns type "MyEstimator", override returns type "None"
+     Return type mismatch: base method returns type "DecisionTreeRegressor", override returns type "None"
-       "None" is not assignable to "MyEstimator" (reportIncompatibleMethodOverride)
+       "None" is not assignable to "DecisionTreeRegressor" (reportIncompatibleMethodOverride)
-     Return type mismatch: base method returns type "FrozenEstimator", override returns type "None"
+     Return type mismatch: base method returns type "BaseEstimator", override returns type "None"
-       "None" is not assignable to "FrozenEstimator" (reportIncompatibleMethodOverride)
+       "None" is not assignable to "BaseEstimator" (reportIncompatibleMethodOverride)
-     Return type mismatch: base method returns type "LassoMock", override returns type "None"
+     Return type mismatch: base method returns type "ElasticNet", override returns type "None"
-       "None" is not assignable to "LassoMock" (reportIncompatibleMethodOverride)
+       "None" is not assignable to "ElasticNet" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/scikit-learn/sklearn/linear_model/tests/test_sgd.py:61:9 - error: Method "fit" overrides class "BaseSGDRegressor" in an incompatible manner
-     Return type mismatch: base method returns type "_SparseSGDRegressor", override returns type "SGDRegressor"
-       "SGDRegressor" is not assignable to "_SparseSGDRegressor" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/scikit-learn/sklearn/linear_model/tests/test_sgd.py:65:9 - error: Method "partial_fit" overrides class "BaseSGDRegressor" in an incompatible manner
-     Return type mismatch: base method returns type "_SparseSGDRegressor", override returns type "SGDRegressor"
-       "SGDRegressor" is not assignable to "_SparseSGDRegressor" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/scikit-learn/sklearn/linear_model/tests/test_sgd.py:76:9 - error: Method "fit" overrides class "SGDOneClassSVM" in an incompatible manner
-     Return type mismatch: base method returns type "_SparseSGDOneClassSVM", override returns type "SGDOneClassSVM"
-       "SGDOneClassSVM" is not assignable to "_SparseSGDOneClassSVM" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/scikit-learn/sklearn/linear_model/tests/test_sgd.py:80:9 - error: Method "partial_fit" overrides class "SGDOneClassSVM" in an incompatible manner
-     Return type mismatch: base method returns type "_SparseSGDOneClassSVM", override returns type "SGDOneClassSVM"
-       "SGDOneClassSVM" is not assignable to "_SparseSGDOneClassSVM" (reportIncompatibleMethodOverride)
-     Return type mismatch: base method returns type "MySGD", override returns type "None"
+     Return type mismatch: base method returns type "BaseSGDRegressor", override returns type "None"
-       "None" is not assignable to "MySGD" (reportIncompatibleMethodOverride)
+       "None" is not assignable to "BaseSGDRegressor" (reportIncompatibleMethodOverride)
- 14525 errors, 30 warnings, 0 informations 
+ 14521 errors, 30 warnings, 0 informations 

prefect (https://github.com/PrefectHQ/prefect)
+   /tmp/mypy_primer/projects/prefect/src/prefect/concurrency/context.py:11:5 - error: "__var__" overrides symbol of same name in class "ContextModel"
+     Variable is mutable so its type is invariant
+       Override type "ContextVar[ConcurrencyContext]" is not the same as base type "ContextVar[ContextModel]" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/prefect/src/prefect/concurrency/v1/context.py:12:5 - error: "__var__" overrides symbol of same name in class "ContextModel"
+     Variable is mutable so its type is invariant
+       Override type "ContextVar[ConcurrencyContext]" is not the same as base type "ContextVar[ContextModel]" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/prefect/src/prefect/context.py:208:5 - error: "__var__" overrides symbol of same name in class "ContextModel"
+     Variable is mutable so its type is invariant
+       Override type "ContextVar[SyncClientContext]" is not the same as base type "ContextVar[ContextModel]" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/prefect/src/prefect/context.py:266:5 - error: "__var__" overrides symbol of same name in class "ContextModel"
+     Variable is mutable so its type is invariant
+       Override type "ContextVar[AsyncClientContext]" is not the same as base type "ContextVar[ContextModel]" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/prefect/src/prefect/context.py:380:5 - error: "__var__" overrides symbol of same name in class "ContextModel"
+     Variable is mutable so its type is invariant
+       Override type "ContextVar[EngineContext]" is not the same as base type "ContextVar[ContextModel]" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/prefect/src/prefect/context.py:427:5 - error: "__var__" overrides symbol of same name in class "ContextModel"
+     Variable is mutable so its type is invariant
+       Override type "ContextVar[TaskRunContext]" is not the same as base type "ContextVar[ContextModel]" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/prefect/src/prefect/context.py:462:5 - error: "__var__" overrides symbol of same name in class "ContextModel"
+     Variable is mutable so its type is invariant
+       Override type "ContextVar[TagsContext]" is not the same as base type "ContextVar[ContextModel]" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/prefect/src/prefect/context.py:479:5 - error: "__var__" overrides symbol of same name in class "ContextModel"
+     Variable is mutable so its type is invariant
+       Override type "ContextVar[SettingsContext]" is not the same as base type "ContextVar[ContextModel]" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/prefect/src/prefect/transactions.py:79:5 - error: "__var__" overrides symbol of same name in class "ContextModel"
+     Variable is mutable so its type is invariant
+       Override type "ContextVar[Transaction]" is not the same as base type "ContextVar[ContextModel]" (reportIncompatibleVariableOverride)
- 5444 errors, 288 warnings, 0 informations 
+ 5453 errors, 288 warnings, 0 informations 

comtypes (https://github.com/enthought/comtypes)
-     Return type mismatch: base method returns type "tagVARIANT", override returns type "Any | Unknown | None"
+     Return type mismatch: base method returns type "_CData", override returns type "Any | Unknown | None"
-       Type "Any | Unknown | None" is not assignable to type "tagVARIANT"
+       Type "Any | Unknown | None" is not assignable to type "_CData"
-         "None" is not assignable to "tagVARIANT" (reportIncompatibleMethodOverride)
+         "None" is not assignable to "_CData" (reportIncompatibleMethodOverride)

pip (https://github.com/pypa/pip)
+     "MutableMapping[Unknown, Unknown]" is not assignable to "OrderedDict"
-     Return type mismatch: base method returns type "tuple[type[RequestError], tuple[None, None]]", override returns type "tuple[type[Self@RequestError], tuple[None, Unknown, None]]"
+     Return type mismatch: base method returns type "tuple[type[PoolError], tuple[None, None]]", override returns type "tuple[type[Self@RequestError], tuple[None, Unknown, None]]"
-       "tuple[type[Self@RequestError], tuple[None, Unknown, None]]" is not assignable to "tuple[type[RequestError], tuple[None, None]]"
+       "tuple[type[Self@RequestError], tuple[None, Unknown, None]]" is not assignable to "tuple[type[PoolError], tuple[None, None]]"

steam.py (https://github.com/Gobot1234/steam.py)
+   /tmp/mypy_primer/projects/steam.py/steam/ext/csgo/models.py:187:15 - error: Method "csgo_profile" overrides class "PartialUser" in an incompatible manner
+     Return type mismatch: base method returns type "CoroutineType[Any, Any, ProfileInfo[PartialUser]]", override returns type "CoroutineType[Any, Any, ProfileInfo[ClientUser]]"
+       "CoroutineType[Any, Any, ProfileInfo[ClientUser]]" is not assignable to "CoroutineType[Any, Any, ProfileInfo[PartialUser]]"
+         Type parameter "_ReturnT_co@CoroutineType" is covariant, but "ProfileInfo[ClientUser]" is not a subtype of "ProfileInfo[PartialUser]"
+           "ProfileInfo[ClientUser]" is not assignable to "ProfileInfo[PartialUser]"
+             Type parameter "UserT@ProfileInfo" is invariant, but "ClientUser" is not the same as "PartialUser" (reportIncompatibleMethodOverride)
- 8520 errors, 94 warnings, 0 informations 
+ 8521 errors, 94 warnings, 0 informations 

asynq (https://github.com/quora/asynq)
+   /tmp/mypy_primer/projects/asynq/asynq/tests/test_multiple_inheritance.py:43:9 - error: "method" overrides symbol of same name in class "Parent1"
+     "AsyncDecorator[Any, (self: Child)]" is not assignable to "AsyncDecorator[Any, (self: Parent1)]"
+       Type parameter "_P@AsyncDecorator" is invariant, but "(self: Child)" is not the same as "(self: Parent1)" (reportIncompatibleVariableOverride)
+   /tmp/mypy_primer/projects/asynq/asynq/tests/test_multiple_inheritance.py:43:9 - error: "method" overrides symbol of same name in class "Parent2"
+     "AsyncDecorator[Any, (self: Child)]" is not assignable to "AsyncDecorator[Any, (self: Parent2)]"
+       Type parameter "_P@AsyncDecorator" is invariant, but "(self: Child)" is not the same as "(self: Parent2)" (reportIncompatibleVariableOverride)
- 166 errors, 9 warnings, 0 informations 
+ 168 errors, 9 warnings, 0 informations 

dd-trace-py (https://github.com/DataDog/dd-trace-py)
-     Property method "fget" is incompatible
-       Return type mismatch: base method returns type "type[LazyTaintList]", override returns type "type[list[Unknown]]"
-         "type[list[Unknown]]" is not assignable to "type[LazyTaintList]"
-         Type "type[list[Unknown]]" is not assignable to type "type[LazyTaintList]" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/appsec/_iast/_taint_utils.py:205:9 - error: "__class__" incorrectly overrides property of same name in class "object"
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/appsec/_iast/_taint_utils.py:372:9 - error: "__class__" incorrectly overrides property of same name in class "object"
-     Property method "fget" is incompatible
-       Return type mismatch: base method returns type "type[LazyTaintDict]", override returns type "type[dict[Unknown, Unknown]]"
-         "type[dict[Unknown, Unknown]]" is not assignable to "type[LazyTaintDict]"
-         Type "type[dict[Unknown, Unknown]]" is not assignable to type "type[LazyTaintDict]" (reportIncompatibleMethodOverride)
- 12716 errors, 601 warnings, 0 informations 
+ 12714 errors, 601 warnings, 0 informations 

xarray (https://github.com/pydata/xarray)
+   /tmp/mypy_primer/projects/xarray/xarray/core/indexes.py:691:9 - error: Method "concat" overrides class "Index" in an incompatible manner
+     Parameter 2 type mismatch: base parameter is type "Sequence[Index]", override parameter is type "Sequence[PandasIndex]"
+       "Sequence[Index]" is not assignable to "Sequence[PandasIndex]"
+         Type parameter "_T_co@Sequence" is covariant, but "Index" is not a subtype of "PandasIndex"
+           "Index" is not assignable to "PandasIndex" (reportIncompatibleMethodOverride)
+   /tmp/mypy_primer/projects/xarray/xarray/core/indexes.py:819:9 - error: Method "join" overrides class "Index" in an incompatible manner
+     Parameter 2 type mismatch: base parameter is type "Index", override parameter is type "PandasIndex"
+       "Index" is not assignable to "PandasIndex" (reportIncompatibleMethodOverride)
+   /tmp/mypy_primer/projects/xarray/xarray/core/indexes.py:833:9 - error: Method "reindex_like" overrides class "Index" in an incompatible manner
+     Parameter 2 type mismatch: base parameter is type "Index", override parameter is type "PandasIndex"
+       "Index" is not assignable to "PandasIndex" (reportIncompatibleMethodOverride)
+   /tmp/mypy_primer/projects/xarray/xarray/core/indexes.py:995:9 - error: Method "concat" overrides class "PandasIndex" in an incompatible manner
+     Parameter 2 type mismatch: base parameter is type "Sequence[PandasIndex]", override parameter is type "Sequence[PandasMultiIndex]"
+       "Sequence[PandasIndex]" is not assignable to "Sequence[PandasMultiIndex]"
+         Type parameter "_T_co@Sequence" is covariant, but "PandasIndex" is not a subtype of "PandasMultiIndex"
+           "PandasIndex" is not assignable to "PandasMultiIndex" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/xarray/xarray/core/variable.py:2692:9 - error: Method "_finalize_indexing_result" overrides class "Variable" in an incompatible manner
-     Return type mismatch: base method returns type "IndexVariable", override returns type "Variable | Self@IndexVariable"
-       Type "Variable | IndexVariable*" is not assignable to type "IndexVariable"
-         "Variable" is not assignable to "IndexVariable" (reportIncompatibleMethodOverride)
- 2423 errors, 93 warnings, 0 informations 
+ 2426 errors, 93 warnings, 0 informations 

mypy (https://github.com/python/mypy)
+   /tmp/mypy_primer/projects/mypy/mypy/typeshed/stdlib/datetime.pyi:334:9 - error: Method "__sub__" overrides class "date" in an incompatible manner
+     Override does not handle all overloads of base method (reportIncompatibleMethodOverride)
+ /tmp/mypy_primer/projects/mypy/mypy/typeshed/stdlib/distutils/version.pyi
+   /tmp/mypy_primer/projects/mypy/mypy/typeshed/stdlib/distutils/version.pyi:27:9 - error: Method "_cmp" overrides class "Version" in an incompatible manner
+     Parameter 2 type mismatch: base parameter is type "Version | str", override parameter is type "StrictVersion | str"
+       Type "Version | str" is not assignable to type "StrictVersion | str"
+         Type "Version" is not assignable to type "StrictVersion | str"
+           "Version" is not assignable to "StrictVersion"
+           "Version" is not assignable to "str" (reportIncompatibleMethodOverride)
+   /tmp/mypy_primer/projects/mypy/mypy/typeshed/stdlib/distutils/version.pyi:36:9 - error: Method "_cmp" overrides class "Version" in an incompatible manner
+     Parameter 2 type mismatch: base parameter is type "Version | str", override parameter is type "LooseVersion | str"
+       Type "Version | str" is not assignable to type "LooseVersion | str"
+         Type "Version" is not assignable to type "LooseVersion | str"
+           "Version" is not assignable to "LooseVersion"
+           "Version" is not assignable to "str" (reportIncompatibleMethodOverride)
+ /tmp/mypy_primer/projects/mypy/mypy/typeshed/stdlib/enum.pyi
+   /tmp/mypy_primer/projects/mypy/mypy/typeshed/stdlib/enum.pyi:316:13 - error: Method "__or__" overrides class "Flag" in an incompatible manner
+     Parameter 2 type mismatch: base parameter is type "Flag", override parameter is type "int"
+       "Flag" is not assignable to "int" (reportIncompatibleMethodOverride)
+   /tmp/mypy_primer/projects/mypy/mypy/typeshed/stdlib/enum.pyi:317:13 - error: Method "__and__" overrides class "Flag" in an incompatible manner
+     Parameter 2 type mismatch: base parameter is type "Flag", override parameter is type "int"
+       "Flag" is not assignable to "int" (reportIncompatibleMethodOverride)

... (truncated 73 lines) ...```

@erictraut erictraut merged commit 4e847ba into main Mar 29, 2025
18 checks passed
@erictraut erictraut deleted the overrideSelf branch March 29, 2025 19:19
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