-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
duplicate-code in Inheritance and implementation classes #4350
Comments
You can use: [SIMILARITIES]
# min-similarity= (more than the default 4 ?)
ignore-imports=yes |
Feel free to reopen if that does not answer the question. |
Thank you for your reply. This configuration is literally set to ignore imports, and it should not work in the case I mentioned above. Because the warning thrown in the above case is not related to the import code. As I suspected, I added the parameter Here is my sample repository where I put the above code and automatically run PyLint through GitHub Action. In the pipeline, I first looked at the configuration of PyLint, and I did enable it, but the warning still appears. Here is pylint config: https://github.com/whg517/demo/blob/45b499dfa66235d5579802be95a38cfcb2dfb767/setup.cfg#L46 |
Hi @Pierre-Sassoulas . Could you please open it again? I have no authority to open the ISSUE you closed. Thanks a lot. |
Sorry, I confused import with signature so in fact this is a dupe of #3619. You can disable similarities for this file as long as |
I see, thank you, and hope the community can improve this feature as soon as possible. |
question
When I inherited and implemented my superclass, PyLint detected duplication of part of the code that I defined for method parameters, and I wondered if PyLint could disable this.
What I'm saying is not to completely disallow duplicate-code, but to prevent PyLint from throwing warnings triggered by the above situation.
Specific description:
When I have a base class that contains some public methods and some abstract methods, subclasses need to implement the abstract methods. In some cases, you may also override methods already implemented by the parent class.
So my subclass will integrate the base class and then implement the methods of the parent class. In general, there is no problem.
But when I use type annotations, I annotate the types for those parameters, and I annotate the return value of the method. The method definition is too long, so I have to use it
The indentation. The part of the method definition becomes multiline. This part of the code also needs to be reused for subclass integration. (When a subclass implements or overrides a parent's method, the method's parameters can be looser than the parent's, and the return value can be stricter.)
This causes PyLint to detect that multiple lines of code in the method definition section are duplicated. This part of the code should not actually throw a warning.
Of course I also tried to put this code on one line, and running PyLint doesn't throw a warning about duplicate code, but it does throw a warning that the trip is too long.
So I wanted to know how to solve this part of the problem.
Specific cases:
base.py
executors.py
Pylint output:
I'm also a little confused about the output. Why does tests/tests.py show that the two files are similar? I don't have any code under my tests.
The text was updated successfully, but these errors were encountered: