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

Display arg name, not number, for functions called with kwargs #4504

Merged
merged 4 commits into from Jan 26, 2018

Conversation

Projects
None yet
2 participants
@elliott-beach
Contributor

elliott-beach commented Jan 24, 2018

Fixes #4487.
The new error message is in this format:

 C(foo='')  # E: Argument "foo" to "C" has incompatible type "str"; expected "int"

elliott-beach added some commits Jan 24, 2018

@msullivan

Looks good! Great change.

Two small things.

ReturnStmt, NameExpr, Var, CONTRAVARIANT, COVARIANT, SymbolNode
)
ReturnStmt, NameExpr, Var, CONTRAVARIANT, COVARIANT, SymbolNode,
CallExpr)

This comment has been minimized.

@msullivan

msullivan Jan 26, 2018

Collaborator

Nit: leave the closing paren on a line of its own

# number.
arg_name = context.arg_names[n - 1] if isinstance(context, CallExpr) else None
if arg_name:
message_format = 'Argument "{}" {}has incompatible type {}; expected {}'

This comment has been minimized.

@msullivan

msullivan Jan 26, 2018

Collaborator

I think it would be cleaner to make the computation of arg_name conditional (and either quoted or not) while leaving the main format string unconditional, to reduce duplication.

@elliott-beach

This comment has been minimized.

Contributor

elliott-beach commented Jan 26, 2018

Thanks for the review @msullivan. I believe I addressed your requests.

@msullivan msullivan merged commit af0de0b into python:master Jan 26, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment