-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Merge two different applicable argument types when synthesizing corresponding argument #18627
Open
A5rocks
wants to merge
6
commits into
python:master
Choose a base branch
from
A5rocks:allow-differing-arg-types-callable-subtyping
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Merge two different applicable argument types when synthesizing corresponding argument #18627
A5rocks
wants to merge
6
commits into
python:master
from
A5rocks:allow-differing-arg-types-callable-subtyping
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This comment has been minimized.
This comment has been minimized.
Minimizing the prefect change, I find that this PR breaks this: from typing import Any, Callable, ParamSpec
P = ParamSpec("P")
def into(f: Callable[P, None], *args: P.args, **kwargs: P.kwargs) -> None:
return None
class C:
def f(self, y: bool = False, *, x: int = 42) -> None:
return None
ex: C | Any = C()
into(ex.f, x=-1) # E: Argument 1 to "into" has incompatible type "Callable[[bool, DefaultNamedArg(int, 'x')], None] | Any"; expected "Callable[[int], None]" I assume that paramspec callables are somehow messed up? |
The fallout is worse lambda inference, but this is more correct
A5rocks
commented
Feb 9, 2025
This comment has been minimized.
This comment has been minimized.
Diff from mypy_primer, showing the effect of this PR on open source code: kornia (https://github.com/kornia/kornia)
+ kornia/augmentation/container/augment.py:300: error: Unused "type: ignore" comment [unused-ignore]
+ kornia/augmentation/container/augment.py:427: error: Unused "type: ignore" comment [unused-ignore]
pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/arrays/_mixins.py:209: error: Unused "type: ignore" comment [unused-ignore]
+ pandas/core/arrays/_mixins.py:217: error: Unused "type: ignore" comment [unused-ignore]
+ pandas/core/indexes/multi.py:1314: error: Unused "type: ignore" comment [unused-ignore]
+ pandas/core/indexes/multi.py:2427: error: Unused "type: ignore" comment [unused-ignore]
+ pandas/plotting/_matplotlib/core.py:1605: error: Unused "type: ignore" comment [unused-ignore]
+ pandas/plotting/_matplotlib/core.py:1772: error: Unused "type: ignore" comment [unused-ignore]
xarray (https://github.com/pydata/xarray)
+ xarray/core/variable.py:1605: error: Unused "type: ignore" comment [unused-ignore]
django-stubs (https://github.com/typeddjango/django-stubs): 1.40x faster (57.8s -> 41.2s in a single noisy sample)
+ django-stubs/test/client.pyi:252: error: Unused "type: ignore" comment [unused-ignore]
+ django-stubs/test/client.pyi:262: error: Unused "type: ignore" comment [unused-ignore]
+ django-stubs/test/client.pyi:273: error: Unused "type: ignore" comment [unused-ignore]
+ django-stubs/test/client.pyi:283: error: Unused "type: ignore" comment [unused-ignore]
+ django-stubs/test/client.pyi:294: error: Unused "type: ignore" comment [unused-ignore]
+ django-stubs/test/client.pyi:305: error: Unused "type: ignore" comment [unused-ignore]
+ django-stubs/test/client.pyi:316: error: Unused "type: ignore" comment [unused-ignore]
+ django-stubs/test/client.pyi:327: error: Unused "type: ignore" comment [unused-ignore]
+ django-stubs/test/client.pyi:353: error: Unused "type: ignore" comment [unused-ignore]
+ django-stubs/test/client.pyi:363: error: Unused "type: ignore" comment [unused-ignore]
+ django-stubs/test/client.pyi:374: error: Unused "type: ignore" comment [unused-ignore]
+ django-stubs/test/client.pyi:384: error: Unused "type: ignore" comment [unused-ignore]
+ django-stubs/test/client.pyi:395: error: Unused "type: ignore" comment [unused-ignore]
+ django-stubs/test/client.pyi:406: error: Unused "type: ignore" comment [unused-ignore]
+ django-stubs/test/client.pyi:417: error: Unused "type: ignore" comment [unused-ignore]
+ django-stubs/test/client.pyi:428: error: Unused "type: ignore" comment [unused-ignore]
pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
+ pandas-stubs/core/indexes/multi.pyi:131: error: Unused "type: ignore" comment [unused-ignore]
ibis (https://github.com/ibis-project/ibis)
- ibis/expr/api.py:804: error: Overloaded function implementation does not accept all possible arguments of signature 2 [misc]
jax (https://github.com/google/jax)
+ jax/experimental/jax2tf/tests/jax2tf_limitations.py:111: error: Unused "type: ignore" comment [unused-ignore]
trio (https://github.com/python-trio/trio)
- src/trio/_core/_run.py:2743: error: Argument 1 to "run" of "Context" has incompatible type "Callable[[Any], object] | None"; expected "Callable[[Outcome[Any] | BaseException | None], object]" [arg-type]
+ src/trio/_core/_run.py:2743: error: Argument 1 to "run" of "Context" has incompatible type "Callable[[Any], object] | None"; expected "Callable[[Any], object]" [arg-type]
|
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #18596.
Fixes #16626.