-
-
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
The duplicate-code (R0801) can't be disabled #214
Comments
Original comment by Radek Holý (BitBucket: PyDeq, GitHub: @PyDeQ?): Pylint marks even import blocks as duplicates. In my case, it is:
I doubt it is possible to clean up/refactor the code to prevent this, thus it would be nice if it would ignore imports or if it would be possible to use the disable comment. |
Original comment by Buck Evan (BitBucket: bukzor, GitHub: @bukzor?): I've run into this today. My project has several setup.py files, which of course look quite similar, but can't really share code. I'll have to turn the checker off entirely I think. |
any news on this issue ? |
No one is currently working on this. This would be nice to have fixed, but unfortunately I didn't have time to look into it. A pull request would be appreciated though and would definitely move it forward. |
We can't disable it more fine-grained: pylint-dev/pylint#214 I think for the shown duplicate (histroy in webkittab/webenginetab) it makes no sense to refactor things as a Mixin...
The test code contain setup and teardown that are same for two tests. Pylint complains about these two methods in two modules. The setup and teardown are needed because they are called by the test framework and cannot be removed. It seems that pylint 1.7.2 has open fault that makes disabling of the check in portion of the code not to work /1/. It also seems that pylint 1.7.2 the ignore-comments and ignore-docstrings do not seem to work as expected. Even when the values should state that these are ignored, the min-similarity had to be increased to 8 because there are 7 lines in these two referred methods. The target is to get the warnings down to see changes easily. This fix could be fixed later on by setting the min-similarity to 4 and use the ignore docstring and comment settings combined with the code tag to ignore the duplicated code. /1/ pylint-dev/pylint#214 Signed-off-by: Heikki Laaksonen <[email protected]>
Is this related to duplicate-except? it cannot be disabled either. sorry, Seems it is able to be disabled. |
…ce (#5202) Class inheritance based approach to distro specific overrides. How it works: The certbot-apache plugin entrypoint has been changed to entrypoint.ENTRYPOINT which is a variable containing appropriate override class for system, if available. Override classes register themselves using decorator override.register() which takes a list of distribution fingerprints (ID & LIKE variables in /etc/os-release, or platform.linux_distribution() as a fallback). These end up as keys in dict override.OVERRIDE_CLASSES and values for the keys are references to the class that called the decorator, hence allowing self-registration of override classes when they are imported. The only file importing these override classes is entrypoint.py, so adding new override classes would need only one import in addition to the actual override class file. Generic changes: Parser initialization has been moved to separate class method, allowing easy override where needed. Cleaned up configurator.py a bit, and moved some helper functions to newly created apache_util.py Split Debian specific code from configurator.py to debian_override.py Changed define_cmd to apache_cmd because the parameters are for every distribution supporting this behavior, and we're able to use the value to build the additional configuration dump commands. Moved add_parser_mod() from configurator to parser add_mod() Added two new configuration dump parsing methods to update_runtime_variables() in parser: update_includes() and update_modules(). Changed init_modules() in parser to accommodate the changes above. (ie. don't throw existing self.modules out). Moved OS based constants to their respective override classes. Refactored configurator class discovery in tests to help easier test case creation using distribution based override configurator class. tests.util.get_apache_configurator() now takes keyword argument os_info which is string of the desired mock OS fingerprint response that's used for picking the right override class. This PR includes two major generic additions that should vastly improve our parsing accuracy and quality: Includes are parsed from config dump from httpd binary. This is mandatory for some distributions (Like OpenSUSE) to get visibility over the whole configuration tree because of Include statements passed on in command line, and not via root httpd.conf file. Modules are parsed from config dump from httpd binary. This lets us jump into correct IfModule directives if for some reason we have missed the module availability (because of one being included on command line or such). Distribution specific changes Because of the generic changes, there are two distributions (or distribution families) that do not provide such functionality, so it had to be overridden in their respective override files. These distributions are: CentOS, because it deliberately limits httpd binary stdout using SELinux as a feature. We are doing opportunistic config dumps here however, in case SELinux enforcing is off. Gentoo, because it does not provide a way to invoke httpd with command line parsed from its specific configuration file. Gentoo relies heavily on Define statements that are passed over from APACHE2_OPTS variable /etc/conf.d/apache2 file and most of the configuration in root Apache configuration are dependent on these values. Debian Moved the Debian specific parts from configurator.py to Debian specific override. CentOS Parsing of /etc/sysconfig/httpd file for additional Define statements. This could hold other parameters too, but parsing everything off it would require a full Apache lexer. For CLI parameters, I think Defines are the most common ones. This is done in addition of opportunistic parsing of httpd binary config dump. Added CentOS default Apache configuration tree for realistic test cases. Gentoo Parsing Defines from /etc/conf.d/apache2 variable APACHE2_OPTS, which holds additional Define statements to enable certain functionalities, enabling parts of the configuration in the Apache2 DOM. This is done instead of trying to parse httpd binary configuration dumps. Added default Apache configuration from Gentoo to testdata, including /etc/conf.d/apache2 file for realistic test cases. * Distribution specific override functionality based on class inheritance * Need to patch get_systemd_os_like to as travis has proper os-release * Added pydoc * Move parser initialization to a method and fix Python 3 __new__ errors * Parser changes to parse HTTPD config * Try to get modules and includes from httpd process for better visibility over the configuration * Had to disable duplicate-code because of test setup (pylint-dev/pylint/issues/214) * CentOS tests and linter fixes * Gentoo override, tests and linter fixes * Mock the process call in all the tests that require it * Fix CentOS test mock * Restore reseting modules list functionality for cleanup * Move OS fingerprinting and constant mocks to parent class * Fixes requested in review * New entrypoint structure and started moving OS constants to override classes * OS constants move continued, test and linter fixes * Removed dead code * Apache compatibility test changest to reflect OS constant restructure * Test fix * Requested changes * Moved Debian specific tests to own test file * Removed decorator based override class registration in favor of entrypoint dict * Fix for update_includes for some versions of Augeas * Take fedora fix into account in tests * Review fixes
Revove this warning, at least for now, because it not disablable on-line and we do not want to factorize reported code this early pylint-dev/pylint#214
some of these took similar long... https://github.com/collectd/collectd/pulls?q=is%3Apr+author%3Adothebart+is%3Aclosed |
This works the same as any other disable in |
Default settings increased, they are too strict and it can't be ignored with comments: pylint-dev/pylint#214 this is fixed in 2.13.0.
Default settings increased, they are too strict and it can't be ignored with comments: pylint-dev/pylint#214 this is fixed in 2.13.0.
I am getting |
@famura Can you try |
@JulienPalard your suggestion (+ me putting it on top of the file) made it work. The latter was necessary since pylint got triggered by the import statements, too. Thank you. |
You might want to have a look at |
|
Could you add a reproducer and open a new bug issue @duanyutong, please ? |
I get flagged by R0801, when I have code like this in two files: return_value_0,
return_value_1,
return_value_2,
return_value_3 = \
my_function(
parameter_0,
parameter_1,
parameter_2,
parameter_3,
)
Note that while there are 10 lines in this example, it only contains a single statement, namely a single function call. Maybe R0801 should consider duplicate statements rather than duplicate lines? |
@Bengt I think it could be an option like |
Increase the value to suppress the warning for common context manager code. I would have liked to disable the warning R0801 locally, but it doesn't seem to be possible. See also pylint-dev/pylint#214 .
Since we cannot use # pylint: disable=duplicate-code according to pylint-dev/pylint#214, changing parameter name to remove duplication
* Add sync state into all sync flows * Pass in sync context instead of sync state * Refactoring to move sync context to be with other contexts * Update http_api_sync_flow.py Since we cannot use # pylint: disable=duplicate-code according to pylint-dev/pylint#214, changing parameter name to remove duplication
This PR modifies the mac_host_engine build config to build the FlutterEmbedder.framework for arm64, and adds a generator that creates a fat framework containing both the intel and arm64 dylibs. The fat framework is uploaded to the gcs bucket instead of the thin intel-only one. The script to create the lipo'd embedder framework is different enough from the desktop framework to have a separate script, but this still triggers the pylint duplicate-code check. Due to a bug in our version of pylint (pylint-dev/pylint#214), it isn't possible to disable per-file, so this PR also disables the check globally.
I’m a little unclear on how to disable the message for select occurrences, while keeping the option enabled in general. The docs don’t mention that detail either. For example, suppose I have
Adding a |
* Add extract single file * Disable duplicate-code check, seems not controllable: pylint-dev/pylint#214 * Tidy some excessive sets of positional args
this still seems to be an issue |
Originally reported by: Anonymous
It's seems like it's not possible to disable the duplicate code check on portions of a file. Looking at the source, I can see why as it's not a trivial thing to do (if you want to maintain the same scope semantics as other #pylint:enable/disable comments. This would be nice to have though (or I guess I could just cleanup my duplicate code).
The text was updated successfully, but these errors were encountered: