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

Overload is not reported as inconsistend when positional or keyword arguments are missing in implementation #7937

Closed
ImogenBits opened this issue May 16, 2024 · 1 comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working

Comments

@ImogenBits
Copy link

In this overload:

@overload
def f(a: int) -> int: ...
@overload
def f(*args: int) -> int: ...

def f(*args: int) -> int: ...

pyright reports no errors. But the first overload claims the function is callable as f(a=1), which fails at runtime. If you make that overload's argument keyword only, pyright does report the implementation as missing the keyword parameter "a".

I think the keyword or positional variant should also be reported since it leads to runtime errors that aren't caught. From what I understand it, (a: str) -> int should also be a supertype of (*, a: str) -> int, so it seems strange that it raises fewer errors here.

@ImogenBits ImogenBits added the enhancement request New feature or request label May 16, 2024
@erictraut erictraut added bug Something isn't working and removed enhancement request New feature or request labels May 16, 2024
erictraut added a commit that referenced this issue May 16, 2024
…able type is compatible with another callable type and the first has a `*args` parameter and the second has a single positional+keyword parameter. This addresses #7937.
erictraut added a commit that referenced this issue May 17, 2024
…able type is compatible with another callable type and the first has a `*args` parameter and the second has a single positional+keyword parameter. This addresses #7937. (#7938)
@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label May 17, 2024
@erictraut
Copy link
Collaborator

This is addressed in pyright 1.1.364.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants