-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[red-knot] Add __init__
arguments check when doing try_call
on a class literal
#16512
base: main
Are you sure you want to change the base?
Conversation
This is still a draft, as I wanted to discuss a couple of things first. First of all, @sharkdp did all the hard work and it seems almost too easy now. However, there are a couple of caveats.
|
I'm not convinced.
Agreed, should be a pretty easy change I think? |
I'm not sure I understand your first point. It's both possible and common to have a def f() -> int:
return 1
x = f(1) # error: [too-many-positional-arguments]
reveal_type(x) # revealed: int What's unusual about Those are just some general comments, haven't looked at the code in the PR yet, will do that tomorrow! |
Maybe this is what you meant by "We don't have to model things totally correctly", but I guess we should (eventually) emit a diagnostic if |
First, I realized I confused everyone by saying
Hence, I suggest adding a method of a function in Any objections?
I haven't looked yet, I'll apply the change since everyone is fine. But this means that more tests will change in this PR than just those related to |
(Didn't get to this today, sorry; will come back to it tomorrow.) |
Summary
Addresses #16511 for simple cases where only
__init__
method is bound on class or doesn't exist at all.No handling of
__new__
or modified__call__
on metaclass.Test Plan