-
-
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
Customize arguments-differ error messages #4422
Conversation
This commit changes the output messages of arguments-differ based on different error cases. It is part one of the issue pylint-dev#3536
This commit modifies the tests of arguments-differ output messages based on different error messages. It is part one of the issue pylint-dev#3536
This commit modifies the tests for arguments-differ output messages based on different error cases. It is part one of the issue pylint-dev#3536
This file emited arguments-differ messages on three methods in the end of the file because some parameters have changed name compared to the original method.
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.
Thank you, great work ! I suggested some small changes, the main thing being we should not change the existing tests, only their outputs. They're testing some use case that were constructed from dozen of issues and we need them to not regress. We can add other tests if required for typing check, having long functional test files with duplication is not a problem at all :)
arguments-differ:41:4:ClassmethodChild.func:Number of parameters has changed in overridden 'ClassmethodChild.func' method | ||
arguments-differ:68:4:VarargsChild.has_kwargs:Parameter 'arg' was of type 'bool' and is now of type 'int' in overridden 'VarargsChild.has_kwargs' method | ||
arguments-differ:68:4:VarargsChild.has_kwargs:Variadics removed in overridden 'VarargsChild.has_kwargs' method | ||
arguments-differ:71:4:VarargsChild.no_kwargs:Parameter 'args' has been renamed in overridden 'VarargsChild.no_kwargs' method |
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.
arguments-differ:71:4:VarargsChild.no_kwargs:Parameter 'args' has been renamed in overridden 'VarargsChild.no_kwargs' method | |
arguments-differ:71:4:VarargsChild.no_kwargs:Parameter 'args' has been renamed to 'arg' in overridden 'VarargsChild.no_kwargs' method |
arguments-differ:68:4:VarargsChild.has_kwargs:Parameter 'arg' was of type 'bool' and is now of type 'int' in overridden 'VarargsChild.has_kwargs' method | ||
arguments-differ:68:4:VarargsChild.has_kwargs:Variadics removed in overridden 'VarargsChild.has_kwargs' method | ||
arguments-differ:71:4:VarargsChild.no_kwargs:Parameter 'args' has been renamed in overridden 'VarargsChild.no_kwargs' method | ||
arguments-differ:172:4:SecondChangesArgs.test:Number of parameters has changed in overridden 'SecondChangesArgs.test' method |
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.
arguments-differ:172:4:SecondChangesArgs.test:Number of parameters has changed in overridden 'SecondChangesArgs.test' method | |
arguments-differ:172:4:SecondChangesArgs.test:Number of parameters was 4 in 'Classname.base_method' and is now 5 in overridden 'SecondChangesArgs.test' |
pylint/checkers/classes.py
Outdated
overridden: List[astroid.AssignName], | ||
dummy_parameter_regex: Pattern, | ||
counter: int, | ||
): |
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.
Here it was a boolean before it look like it's now a list of string.
): | |
) -> List[str]: |
pylint/checkers/classes.py
Outdated
return True | ||
return False | ||
result.append( | ||
"Parameter '" + str(original_param.name) + "' has been renamed in" |
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.
"Parameter '" + str(original_param.name) + "' has been renamed in" | |
f"Parameter '{original_param.name}' has been renamed to '{overridden_param.name}' in" |
pylint/checkers/classes.py
Outdated
original: List[astroid.FunctionDef], | ||
overridden: List[astroid.FunctionDef], | ||
dummy_parameter_regex: Pattern, | ||
): |
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.
): | |
) -> List[str]: |
pylint/checkers/classes.py
Outdated
) | ||
if len(different_kwonly) > 0: |
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.
if len(different_kwonly) > 0: | |
if different_kwonly: |
@@ -3,13 +3,13 @@ | |||
|
|||
class Parent(object): | |||
|
|||
def test(self): |
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.
Could we refrain from changing the existing functional test in this MR, please ? I would like to see if the old use cases are all handled well. We can add more functional tests if required :)
Thank you! Okay I see, I'm working on these changes :) |
This commit removes several changes that have been done on some method parameters, so that we keep the initial format of the tests.
This commit adds some changes on the output messages and also adds some more code for the compatibility with the initial tests.
for more information, see https://pre-commit.ci
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.
Thank you , great work and very nice new message ! Could we also keep the typing change in functional tests for the next MR, please?
pylint/checkers/classes.py
Outdated
"Parameter '" | ||
+ str(original_param.name) | ||
+ "' was of type '" | ||
+ original_type | ||
+ "' and is now of type '" | ||
+ overridden_type | ||
+ "' in" |
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.
"Parameter '" | |
+ str(original_param.name) | |
+ "' was of type '" | |
+ original_type | |
+ "' and is now of type '" | |
+ overridden_type | |
+ "' in" | |
f "Parameter '{original_param.name}' was of type '{original_type}' and " | |
"is now of type '{overridden_type}' in" |
…into args-differ-msg
for more information, see https://pre-commit.ci
Thank you! What do you mean exactly? The parameter types on the tests? |
ChangeLog
Outdated
@@ -51,6 +51,8 @@ Release date: 2021-04-25 | |||
|
|||
Closes #4399 | |||
|
|||
* Customize output messages for ``arguments-differ`` error message based on the different error cases. |
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.
* Customize output messages for ``arguments-differ`` error message based on the different error cases. | |
* The warning for ``arguments-differ`` now signal explicitly the difference it detected by naming the argument or type that changed. |
for more information, see https://pre-commit.ci
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.
It look like we're getting a problem in the pipeline because of #4439. I'll merge as soon as someone fix it and the test pass when we rebase. Thank you for all the work on this !
My pleasure! So I have to wait for this PR to be merged in order to start working on the second pull request? |
Well, you can disregard the error and start the second one, we will rebase on master once the first one is merged. I also see that there is a problem with mypy that you could check before that: https://results.pre-commit.ci/run/github/47671127/1620160302.btadc94JQO-yT6SZWp2aLg |
The pylint problem here isn't related to the issue you linked. AFAIK it's because the annotation was assumed to have the |
I am working on the mypy errors, I think they might fix the problem. I had a small mistake on the parameter typing here. |
This commit fixes the ignoring of special methods on function overriding and also removes incorrect use of the attribute name.
for more information, see https://pre-commit.ci
This commits creates the new error arguments-renamed based on the functionality added on pylint-dev#4422 and the changes of pylint-dev#4456.
* Create new error arguments-renamed This commits creates the new error arguments-renamed based on the functionality added on #4422 and the changes of #4456. * Merge test files for arguments-differ This commit merges the two kinds of test files that existed for the arguments-differ error, since now all tests run in Python3. * Add tests for arguments-renamed error * Add new error arguments-renamed Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Pierre Sassoulas <[email protected]>
Steps
doc/whatsnew/<current release.rst>
.Description
This pull request customizes the output messages of
arguments-differ
error message based on different error cases (type change, name change, number of parameters etc). It aims to act as a base for the creation of a new error message,arguments-renamed
.Type of Changes
Related Issue
Part one of #3536