-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
arguments-differ is triggered if just arg names changed #3536
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
Comments
Thanks, separating this behaviour into two checks sounds like a good idea. |
Hello, I would like to work on that. If I understood correctly, the |
Hey, nice to see you're becoming a regular 😄 I assigned you the issue ! Regarding the task itself I think what @socketpair proposed is nice:
If I understood correctly import enum
class Condiment(enum.Enum):
CINAMON = 1
SUGAR = 2
class Fruit:
def brew(self, fruit_name: str):
print(f"Brewing a fruit named {fruit_name}")
def eat_with_condiment(self, fruit_name:str, condiment: Condiment):
print(f"Eating a fruit named {fruit_name} with {condiment}")
class Orange(Fruit):
def brew(self, orange_name: str): # [arguments-renamed]
print(f"Brewing an orange named {orange_name}")
def eat_with_condiment(self, condiment: Condiment, orange_name:str): # [argument-differ]
print(f"Eating a fruit named {orange_name} with {condiment}")
class Banana(Fruit):
def brew(self, fruit_name: str): # No warning
print(f"Brewing a banana named {fruit_name}")
def eat_with_condiment(self, fruit_name:str, condiment: Condiment, error:str): # [argument-differ]
print(f"Eating a fruit named {fruit_name} with {condiment}")
# ... Maybe we can create other fruit for type changing, or args becoming kwargs depending
# on the existing functional test covering that already ?
|
Nice to see you again 😃 Thank you for the example. I think for the |
Hello @Pierre-Sassoulas , I have a question. I'm having difficulty understanding what this line checks. What regex does the |
It seem to be coming from the call line 1763: Dummy regex is defined here in the class:
So the value come straight from the configuration file where it can be defined this way:
To be fair I don't think we have too pass the regex variable around because it seem to be a constant (?). Maybe I did not understand that part well. |
Do you think that I can compare the parameter types using |
I don't know if this answer your question specifically but about how to use # is_call_of_name(parent, "function_name")
def is_call_of_name(node: astroid.node_classes.NodeNG, name: str) -> bool:
"""Checks if node is a function call with the given name"""
return (
isinstance(node, astroid.Call)
and isinstance(node.func, astroid.Name)
and node.func.name == name
) |
Ok I get it. However, the parameters I want to compare are |
I think you need to use |
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
Changes the output messages of arguments-differ based on different error cases. It is part one of the issue #3536
Hello, I have a few questions regarding the arguments-renamed error. The output message will be the same as the one below which was added to the arguments-differ?https://github.com/PyCQA/pylint/blob/6b3c49895f5e1750e2cc6c4e0c4e0c5460056cd2/tests/functional/a/arguments_differ.txt#L5 |
Yes I think the message would be the same, but not the name of the message. I did not understand the question about tests for python 3, I think we're going only test for python 3 since we do not have test for python 2 now ? The python 2 tests are historical, don't worry about them :) |
I am asking because on my initial PR the checks for pyton3 had failed. There are two test files for arguments-differ, the first one is |
Hum ok, I think they could be merged as implicitly every tests if py3 now. |
You mean to merge these two files in one? There is also this file that specifies the Python version. |
Yes merging the two file, the .rc file can be removed, it was the configuration for |
I think we should differentiate errors:
arguments-differ
if something changed except the names (i.e., number of args, their types, or args become kwargs, or so.).arguments-renamed
should be raised only if a name was changed.But arguments changed in a way that old arguments change their positions (i.e. swapped)
arguments-differ
should be raise anyway:Rationale:
If I just add
# pylint: disable=arguments-differ
it would hide other arguments-related errors in this line. As a workaround I can write something like:but this is slightly stupid. I would not like to do such a trick just to silence the linter.
The text was updated successfully, but these errors were encountered: