Skip to content

Added support for tracking multiple constraint sets when performing p…#9864

Merged
erictraut merged 1 commit intomainfrom
issue-9835
Feb 9, 2025
Merged

Added support for tracking multiple constraint sets when performing p…#9864
erictraut merged 1 commit intomainfrom
issue-9835

Conversation

@erictraut
Copy link
Collaborator

…rotocol matching. This allows protocols with overloaded methods to contribute independent constraint sets. This addresses #9835.

…rotocol matching. This allows protocols with overloaded methods to contribute independent constraint sets. This addresses #9835.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2025

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/crypto/tests/test_crypto.py:475:22 - error: Argument of type "int | Unknown | None" cannot be assigned to parameter "base" of type "_SupportsSomeKindOfPow" in function "pow"
+   /tmp/mypy_primer/projects/sympy/sympy/crypto/tests/test_crypto.py:475:22 - error: Argument of type "int | Unknown | None" cannot be assigned to parameter "base" of type "_SupportsPow3[_E@pow, _M@pow, _T_co@pow]" in function "pow"
+     Type "int | Unknown | None" is not assignable to type "_SupportsPow3[int | Unknown, int | None, _T_co@pow]"
+       "int" is incompatible with protocol "_SupportsPow3[int | Unknown, int | None, _T_co@pow]"
+         "__pow__" is an incompatible type
+           No overloaded function matches type "(other: _E@_SupportsPow3, modulo: _M@_SupportsPow3, /) -> _T_co@_SupportsPow3" (reportArgumentType)
-     Type "int | Unknown | None" is not assignable to type "_SupportsSomeKindOfPow"
-       Type "None" is not assignable to type "_SupportsSomeKindOfPow"
-         "None" is incompatible with protocol "_SupportsPow2[Any, Any]"
-           "__pow__" is not present
-         "None" is incompatible with protocol "_SupportsPow3NoneOnly[Any, Any]"
-           "__pow__" is not present
-         "None" is incompatible with protocol "_SupportsPow3[Any, Any, Any]"
-           "__pow__" is not present (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/crypto/tests/test_crypto.py:475:29 - error: Argument of type "int | None" cannot be assigned to parameter "mod" of type "None" in function "pow"
-     Type "int | None" is not assignable to type "None"
-       "int" is not assignable to "None" (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/discrete/transforms.py:165:14 - error: Argument of type "int | Unknown | None" cannot be assigned to parameter "base" of type "int" in function "pow"
+   /tmp/mypy_primer/projects/sympy/sympy/discrete/transforms.py:165:14 - error: Argument of type "int | Unknown | None" cannot be assigned to parameter "base" of type "_SupportsPow3[_E@pow, _M@pow, _T_co@pow]" in function "pow"
-     Type "int | Unknown | None" is not assignable to type "int"
+     Type "int | Unknown | None" is not assignable to type "_SupportsPow3[Any | int, int, int]"
-       "None" is not assignable to "int" (reportArgumentType)
+       "None" is incompatible with protocol "_SupportsPow3[Any | int, int, int]"
+         "__pow__" is not present (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/ntheory/tests/test_residue.py:127:20 - error: Argument of type "list[int] | int | None" cannot be assigned to parameter "base" of type "int" in function "pow"
+   /tmp/mypy_primer/projects/sympy/sympy/ntheory/tests/test_residue.py:127:20 - error: Argument of type "list[int] | int | None" cannot be assigned to parameter "base" of type "_SupportsPow3[_E@pow, _M@pow, _T_co@pow]" in function "pow"
-     Type "list[int] | int | None" is not assignable to type "int"
+     Type "list[int] | int | None" is not assignable to type "_SupportsPow3[Literal[0], None, float]"
+       "list[int]" is incompatible with protocol "_SupportsPow3[Literal[0], None, float]"
+         "__pow__" is not present (reportArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/ntheory/tests/test_residue.py:127:36 - error: Argument of type "Literal[2]" cannot be assigned to parameter "exp" of type "_E@pow" in function "pow"
+     "Literal[2]" is not assignable to type "Literal[0]" (reportArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/ntheory/tests/test_residue.py:127:39 - error: Argument of type "int" cannot be assigned to parameter "mod" of type "_M@pow" in function "pow"
-       "list[int]" is not assignable to "int" (reportArgumentType)
+     "int" is not assignable to "None" (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/ntheory/tests/test_residue.py:218:20 - error: Argument of type "list[int] | int | list[Unknown] | None" cannot be assigned to parameter "base" of type "int" in function "pow"
+   /tmp/mypy_primer/projects/sympy/sympy/ntheory/tests/test_residue.py:218:20 - error: Argument of type "list[int] | int | list[Unknown] | None" cannot be assigned to parameter "base" of type "_SupportsPow3[_E@pow, _M@pow, _T_co@pow]" in function "pow"
-     Type "list[int] | int | list[Unknown] | None" is not assignable to type "int"
+     Type "list[int] | int | list[Unknown] | None" is not assignable to type "_SupportsPow3[int, int, int]"
-       "list[int]" is not assignable to "int" (reportArgumentType)
+       "list[int]" is incompatible with protocol "_SupportsPow3[int, int, int]"
+         "__pow__" is not present (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/solvers/diophantine/diophantine.py:3576:13 - error: Argument of type "int | None" cannot be assigned to parameter "base" of type "int" in function "pow"
+   /tmp/mypy_primer/projects/sympy/sympy/solvers/diophantine/diophantine.py:3576:13 - error: Argument of type "int | None" cannot be assigned to parameter "base" of type "_SupportsPow3[_E@pow, _M@pow, _T_co@pow]" in function "pow"
-     Type "int | None" is not assignable to type "int"
+     Type "int | None" is not assignable to type "_SupportsPow3[int, int, int]"
-       "None" is not assignable to "int" (reportArgumentType)
+       "None" is incompatible with protocol "_SupportsPow3[int, int, int]"
+         "__pow__" is not present (reportArgumentType)
-   /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)

rich (https://github.com/Textualize/rich)
+ /tmp/mypy_primer/projects/rich/rich/_ratio.py
+   /tmp/mypy_primer/projects/rich/rich/_ratio.py:75:17 - error: No overloads for "__setitem__" match the provided arguments (reportCallIssue)
+   /tmp/mypy_primer/projects/rich/rich/_ratio.py:75:17 - error: Argument of type "float" cannot be assigned to parameter "value" of type "int | None" in function "__setitem__"
+     Type "float" is not assignable to type "int | None"
+       "float" is not assignable to "int"
+       "float" is not assignable to "None" (reportArgumentType)
- 364 errors, 42 warnings, 0 informations 
+ 366 errors, 42 warnings, 0 informations 

pip (https://github.com/pypa/pip)
+ /tmp/mypy_primer/projects/pip/src/pip/_vendor/rich/_ratio.py
+   /tmp/mypy_primer/projects/pip/src/pip/_vendor/rich/_ratio.py:75:17 - error: No overloads for "__setitem__" match the provided arguments (reportCallIssue)
+   /tmp/mypy_primer/projects/pip/src/pip/_vendor/rich/_ratio.py:75:17 - error: Argument of type "float" cannot be assigned to parameter "value" of type "int | None" in function "__setitem__"
+     Type "float" is not assignable to type "int | None"
+       "float" is not assignable to "int"
+       "float" is not assignable to "None" (reportArgumentType)
- 1820 errors, 38 warnings, 0 informations 
+ 1822 errors, 38 warnings, 0 informations 

pycryptodome (https://github.com/Legrandin/pycryptodome)
-   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/Math/Primality.py:101:23 - error: Argument of type "IntegerBase" cannot be assigned to parameter "exp" of type "complex" in function "pow"
-     "IntegerBase" is not assignable to "complex" (reportArgumentType)
-   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/Math/Primality.py:101:26 - error: Argument of type "IntegerBase" cannot be assigned to parameter "mod" of type "None" in function "pow"
+   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/Math/Primality.py:101:17 - error: Argument of type "IntegerBase | Literal[1]" cannot be assigned to parameter "base" of type "_SupportsPow3[_E@pow, _M@pow, _T_co@pow]" in function "pow"
-     "IntegerBase" is not assignable to "None" (reportArgumentType)
+     Type "IntegerBase | Literal[1]" is not assignable to type "_SupportsPow3[IntegerBase, IntegerBase, _T_co@pow]"
+       "Literal[1]" is incompatible with protocol "_SupportsPow3[IntegerBase, IntegerBase, _T_co@pow]"
+         "__pow__" is an incompatible type
+           No overloaded function matches type "(other: _E@_SupportsPow3, modulo: _M@_SupportsPow3, /) -> _T_co@_SupportsPow3" (reportArgumentType)
-   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/PublicKey/DSA.py:483:16 - error: Argument of type "IntegerBase" cannot be assigned to parameter "exp" of type "complex" in function "pow"
-     "IntegerBase" is not assignable to "complex" (reportArgumentType)
-   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/PublicKey/DSA.py:483:19 - error: Argument of type "IntegerBase" cannot be assigned to parameter "mod" of type "None" in function "pow"
+   /tmp/mypy_primer/projects/pycryptodome/lib/Crypto/PublicKey/DSA.py:483:13 - error: Argument of type "IntegerBase | Unknown | Literal[1]" cannot be assigned to parameter "base" of type "_SupportsPow3[_E@pow, _M@pow, _T_co@pow]" in function "pow"
-     "IntegerBase" is not assignable to "None" (reportArgumentType)
+     Type "IntegerBase | Unknown | Literal[1]" is not assignable to type "_SupportsPow3[IntegerBase, IntegerBase, _T_co@pow]"
+       "Literal[1]" is incompatible with protocol "_SupportsPow3[IntegerBase, IntegerBase, _T_co@pow]"
+         "__pow__" is an incompatible type
+           No overloaded function matches type "(other: _E@_SupportsPow3, modulo: _M@_SupportsPow3, /) -> _T_co@_SupportsPow3" (reportArgumentType)
- 1775 errors, 55 warnings, 0 informations 
+ 1773 errors, 55 warnings, 0 informations 

@erictraut erictraut merged commit 131f56d into main Feb 9, 2025
18 checks passed
@erictraut erictraut deleted the issue-9835 branch February 9, 2025 23:48
erictraut added a commit that referenced this pull request Aug 30, 2025
…orming protocol matching. This allows protocols with overloaded methods to contribute independent constraint sets. This addresses #9835. (#9864)"

This reverts commit 131f56d.

This addresses #10849
erictraut added a commit that referenced this pull request Aug 30, 2025
…orming protocol matching. This allows protocols with overloaded methods to contribute independent constraint sets. This addresses #9835. (#9864)" (#10863)

This reverts commit 131f56d.

This addresses #10849
erictraut added a commit that referenced this pull request Sep 1, 2025
* main:
  Changed the evaluated type of `__class__` from `type[Self]` to `type[<Enclosing class]`. This addresses #10685. (#10874)
  Added optimization that reduces the number of Uri objects that need to be created during type evaluation. This is an attempt to address #10832. (#10872)
  Fixed bug that causes a false negative when using unquoted types in a TypedDict functional class definition if the types are forward declared. This addresses #10612. (#10869)
  Fixed bug that resulted in false negative when backslash followed by line feed occurs at end of file. This addresses #10814. (#10867)
  Fixed false negative when a keyword parameter in a child class method overrides a method with a `**kwargs` in the parent and the type is incompatible. This addresses #10815. (#10866)
  Fixed regression introduced in 1.1.343 that results in nondeterministic (order-dependent) type evaluation under certain circumstances involving recursive type aliases. This addresses #10850. (#10865)
  Revert "Added support for tracking multiple constraint sets when performing protocol matching. This allows protocols with overloaded methods to contribute independent constraint sets. This addresses #9835. (#9864)" (#10863)
  Fixed bug that contributes to out-of-memory crashes under certain circumstances where a module's transitive import graph is very large and may not fit within the available heap space. (#10862)
  Bump tmp from 0.2.3 to 0.2.5 in /packages/vscode-pyright (#10824)
  Added support for `match_args` dataclass parameter. This addresses #10858. (#10861)
  Fixed bug that results in false negative when a `closed=False` is used in `TypedDict` that subclasses from a non-open `TypedDict` base class. This addresses #10859. (#10860)
  Revert "Reverted a recent change that appears to have affected performance on some projects. This attempts to address #10832. (#10841)"
  Improved performance of import resolution when there are large number… (#10855)
  Document editable installs with uv (#10854)
  Fixed a bug that results in spurious errors if a class decorator is a… (#10846)
  Fixed a bug that results in false positive errors when using `object` methods (like `__eq__`) on a `Sentinel` instance. This addresses #10773. (#10844)
  Fixed bug that results in incorrect literal math results for bitwise negation. This addresses #10834. (#10842)
  Reverted a recent change that appears to have affected performance on some projects. This attempts to address #10832. (#10841)
  pull-pylance-with-pyright-1.1.403-20250820-201137 (#10831)
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