Skip to content

Eliminated unnecessary complexity in modeling of property fget, fset,…#10206

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

Eliminated unnecessary complexity in modeling of property fget, fset,…#10206
erictraut merged 1 commit intomainfrom
propSimplification

Conversation

@erictraut
Copy link
Copy Markdown
Collaborator

… and fdel methods.

@github-actions
Copy link
Copy Markdown
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/ast.py:915:9 - error: "func" incorrectly overrides property of same name in class "Basic"
-     Property method "fget" is incompatible
-       Return type mismatch: base method returns type "type[String]", override returns type "() -> Self@String"
-         Type "() -> Self@String" is not assignable to type "type[String]" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/sympy/sympy/core/symbol.py:447:9 - error: "free_symbols" incorrectly overrides property of same name in class "Basic"
-     Property method "fget" is incompatible
-       Return type mismatch: base method returns type "set[Basic]", override returns type "set[Self@Symbol]"
-         "set[Self@Symbol]" is not assignable to "set[Basic]"
-           Type parameter "_T@set" is invariant, but "Self@Symbol" is not the same as "Basic"
-           Consider switching from "set" to "Container" which is covariant (reportIncompatibleMethodOverride)
-       Return type mismatch: base method returns type "set[Basic]", override returns type "set[Self@MatrixSymbol]"
+       Return type mismatch: base method returns type "set[Basic]", override returns type "set[MatrixSymbol]"
-         "set[Self@MatrixSymbol]" is not assignable to "set[Basic]"
+         "set[MatrixSymbol]" is not assignable to "set[Basic]"
-           Type parameter "_T@set" is invariant, but "Self@MatrixSymbol" is not the same as "Basic"
+           Type parameter "_T@set" is invariant, but "MatrixSymbol" is not the same as "Basic"
-   /tmp/mypy_primer/projects/sympy/sympy/physics/mechanics/wrapping_geometry.py:154:9 - error: "point" incorrectly overrides property of same name in class "WrappingGeometryBase"
-     Property method "fget" is incompatible
-       Parameter 1 name mismatch: base parameter is named "cls", override parameter is named "self" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/sympy/sympy/physics/mechanics/wrapping_geometry.py:385:9 - error: "point" incorrectly overrides property of same name in class "WrappingGeometryBase"
-     Property method "fget" is incompatible
-       Parameter 1 name mismatch: base parameter is named "cls", override parameter is named "self" (reportIncompatibleMethodOverride)
-       Return type mismatch: base method returns type "set[Basic]", override returns type "set[Self@RandomSymbol]"
+       Return type mismatch: base method returns type "set[Basic]", override returns type "set[RandomSymbol]"
-         "set[Self@RandomSymbol]" is not assignable to "set[Basic]"
+         "set[RandomSymbol]" is not assignable to "set[Basic]"
-           Type parameter "_T@set" is invariant, but "Self@RandomSymbol" is not the same as "Basic"
+           Type parameter "_T@set" is invariant, but "RandomSymbol" is not the same as "Basic"
-       Return type mismatch: base method returns type "set[RandomIndexedSymbol]", override returns type "set[Basic] | set[Self@RandomIndexedSymbol]"
+       Return type mismatch: base method returns type "set[RandomIndexedSymbol]", override returns type "set[Basic] | set[RandomIndexedSymbol]"
-         Type "set[Basic] | set[Self@RandomIndexedSymbol]" is not assignable to type "set[RandomIndexedSymbol]"
+         Type "set[Basic] | set[RandomIndexedSymbol]" is not assignable to type "set[RandomIndexedSymbol]"
-           "set[Self@RandomIndexedSymbol]" is not assignable to "set[RandomIndexedSymbol]"
+           "set[Basic]" is not assignable to "set[RandomIndexedSymbol]"
-             Type parameter "_T@set" is invariant, but "Self@RandomIndexedSymbol" is not the same as "RandomIndexedSymbol"
+             Type parameter "_T@set" is invariant, but "Basic" is not the same as "RandomIndexedSymbol"
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:170:41 - error: Argument of type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" cannot be assigned to parameter "expr" of type "ArrayDiagonal" in function "_array_diag2contr_diagmatrix"
-     Type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" is not assignable to type "ArrayDiagonal"
-       "Basic" is not assignable to "ArrayDiagonal" (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:174:41 - error: Argument of type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" cannot be assigned to parameter "expr" of type "ArrayDiagonal" in function "_array_diag2contr_diagmatrix"
-     Type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" is not assignable to type "ArrayDiagonal"
-       "Basic" is not assignable to "ArrayDiagonal" (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:180:41 - error: Argument of type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" cannot be assigned to parameter "expr" of type "ArrayDiagonal" in function "_array_diag2contr_diagmatrix"
-     Type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" is not assignable to type "ArrayDiagonal"
-       "Basic" is not assignable to "ArrayDiagonal" (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:184:41 - error: Argument of type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" cannot be assigned to parameter "expr" of type "ArrayDiagonal" in function "_array_diag2contr_diagmatrix"
-     Type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" is not assignable to type "ArrayDiagonal"
-       "Basic" is not assignable to "ArrayDiagonal" (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:188:41 - error: Argument of type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" cannot be assigned to parameter "expr" of type "ArrayDiagonal" in function "_array_diag2contr_diagmatrix"
-     Type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" is not assignable to type "ArrayDiagonal"
-       "Basic" is not assignable to "ArrayDiagonal" (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:196:41 - error: Argument of type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" cannot be assigned to parameter "expr" of type "ArrayDiagonal" in function "_array_diag2contr_diagmatrix"
-     Type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" is not assignable to type "ArrayDiagonal"
-       "Basic" is not assignable to "ArrayDiagonal" (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:205:41 - error: Argument of type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" cannot be assigned to parameter "expr" of type "ArrayDiagonal" in function "_array_diag2contr_diagmatrix"
-     Type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" is not assignable to type "ArrayDiagonal"
-       "Basic" is not assignable to "ArrayDiagonal" (reportArgumentType)
+     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:213:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayDiagonal"
+     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:213:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayAdd"
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:217:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayDiagonal"
+     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:217:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayAdd"
+     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
+     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:223:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayDiagonal"
+     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:223:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayAdd"
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:227:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayDiagonal"
+     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:227:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayAdd"
+     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)

... (truncated 324 lines) ...

xarray (https://github.com/pydata/xarray)
-   /tmp/mypy_primer/projects/xarray/xarray/core/variable.py:2286:9 - error: "imag" incorrectly overrides property of same name in class "NamedArray"
-     Property method "fget" is incompatible
-       Parameter 1 type mismatch: base parameter is type "NamedArray[_ShapeType@imag, Unknown]", override parameter is type "Variable"
-         "NamedArray[_ShapeType@imag, Unknown]" is not assignable to "Variable" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/xarray/xarray/core/variable.py:2297:9 - error: "real" incorrectly overrides property of same name in class "NamedArray"
-     Property method "fget" is incompatible
-       Parameter 1 type mismatch: base parameter is type "NamedArray[_ShapeType@real, Unknown]", override parameter is type "Variable"
-         "NamedArray[_ShapeType@real, Unknown]" is not assignable to "Variable" (reportIncompatibleMethodOverride)
- 2425 errors, 93 warnings, 0 informations 
+ 2423 errors, 93 warnings, 0 informations 

mypy (https://github.com/python/mypy)
-   /tmp/mypy_primer/projects/mypy/mypy/typeshed/stdlib/fractions.pyi:46:9 - error: "numerator" incorrectly overrides property of same name in class "Rational"
-     Property method "fget" is incompatible
-       Parameter 1 name mismatch: base parameter is named "self", override parameter is named "a" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/mypy/mypy/typeshed/stdlib/fractions.pyi:48:9 - error: "denominator" incorrectly overrides property of same name in class "Rational"
-     Property method "fget" is incompatible
-       Parameter 1 name mismatch: base parameter is named "self", override parameter is named "a" (reportIncompatibleMethodOverride)
- 1247 errors, 101 warnings, 0 informations 
+ 1245 errors, 101 warnings, 0 informations 

boostedblob (https://github.com/hauntsaninja/boostedblob)
-   /tmp/mypy_primer/projects/boostedblob/boostedblob/path.py:81:9 - error: "parent" incorrectly overrides property of same name in class "BasePath"
-     Property method "fget" is incompatible
-       Parameter 1 type mismatch: base parameter is type "T@parent", override parameter is type "LocalPath"
-         "object*" is not assignable to "LocalPath" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/boostedblob/boostedblob/path.py:153:9 - error: "parent" incorrectly overrides property of same name in class "BasePath"
-     Property method "fget" is incompatible
-       Parameter 1 type mismatch: base parameter is type "T@parent", override parameter is type "AzurePath"
-         "object*" is not assignable to "AzurePath" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/boostedblob/boostedblob/path.py:215:9 - error: "parent" incorrectly overrides property of same name in class "BasePath"
-     Property method "fget" is incompatible
-       Parameter 1 type mismatch: base parameter is type "T@parent", override parameter is type "GooglePath"
-         "object*" is not assignable to "GooglePath" (reportIncompatibleMethodOverride)
- 25 errors, 0 warnings, 0 informations 
+ 22 errors, 0 warnings, 0 informations 

@erictraut erictraut merged commit 2b821aa into main Mar 29, 2025
18 checks passed
@erictraut erictraut deleted the propSimplification branch March 29, 2025 17:40
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