-
-
Notifications
You must be signed in to change notification settings - Fork 454
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
try and use named arguments from caller for matching name #2294
Conversation
298983c
to
43ac4a8
Compare
for kinds, argnames, args in zip(ctx.arg_kinds, ctx.arg_names, ctx.args): | ||
for kind, argname, arg in zip(kinds, argnames, args): | ||
if kind == ArgKind.ARG_NAMED and argname == name: | ||
return arg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one could imagine a perverse class that does something like:
class FK(ForeignKey[_ST, _GT]):
def __init__(self, *args, **kwargs):
kwargs['null'] = not kwargs.get('null', False)
super().__init__(*args, **kwargs)
but I'm thinking that's probably not going to happen and possibly ok to ignore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess they could even do that today and trick the current code with:
class FK(ForeignKey[_ST, _GT]):
def __init__(self, *args, null: bool = False, **kwargs):
null = not null
super().__init__(*args, null=null, **kwargs)
so definitely not a problem imo :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about reusing _get_argument
from mypy.plugins.common
? Would it solve this problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the current code is equivalent to that so it wouldn't help (_get_argument only looks at callee args)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
test failing prior to change:
the
FK
example matches a similar one in sentry