-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Can't disable bad-option-value #3312
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 for the report, this is definitely something we should be able to fix. |
Hi. It seems to work when it's on the same line but not globally (which could be useful but I didn't found anything on the documentation). So I have to do: |
My (unwarranted) two cents: I don't quite see the point of allowing to run different versions of pylint on the same code base. Different versions of pylint are likely to yield different warnings, because checks are added (and sometimes removed) between versions, and bugs (such as false positives) are fixed. So if your teammate does not run the same version as you do, they may have a "perfect pylint score", while your version gets warnings. Surely you'd rather have a reproducible output, and the best way to achieve that is to warrant a specific version of pylint across the team and your CI environment. |
@dbaty Running different versions of pylint helps when porting code from Python2 to Python3 |
So, what's the status ? |
Dropping support for an option, and also having a bad-option-value be an error makes pylint not backwards compatible. It looks like you expect everyone to be able to atomically update their pylint version and all of their code annotations in all of their environments at the same time. I maintain packages supporting python 2.7, 3.4-3.10, and since pylint no longer supports all of those, I'm forced to use older versions of pylint in some environments, which now are not compatible with the latest. I don't know if this is a new behavior or has always been this way, but today was the first time I've had any problem with pylint , and am going to have to disable it in CI now. |
@jacobtylerwalls I have a fix, but it requires changing the signature of The issue is that we need to call diff --git a/pylint/lint/pylinter.py b/pylint/lint/pylinter.py
index 7c40f4bf2..4b00ba5ac 100644
--- a/pylint/lint/pylinter.py
+++ b/pylint/lint/pylinter.py
@@ -527,7 +527,9 @@ class PyLinter(
# block level option handling #############################################
# see func_block_disable_msg.py test case for expected behaviour
- def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
+ def process_tokens(
+ self, tokens: list[tokenize.TokenInfo], node: nodes.Module
+ ) -> None:
"""Process tokens from the current module to search for module/block level
options.
"""
@@ -595,6 +597,7 @@ class PyLinter(
l_start -= 1
try:
meth(msgid, "module", l_start)
+ self.file_state.collect_block_lines(self.msgs_store, node)
except exceptions.UnknownMessageError:
msg = f"{pragma_repr.action}. Don't recognize message {msgid}."
self.add_message(
@@ -1043,7 +1046,7 @@ class PyLinter(
# assert astroid.file.endswith('.py')
# invoke ITokenChecker interface on self to fetch module/block
# level options
- self.process_tokens(tokens)
+ self.process_tokens(tokens, node)
if self._ignore_file:
return False
# walk ast to collect line numbers
diff --git a/tests/functional/b/bad_option_value_disable.py b/tests/functional/b/bad_option_value_disable.py
new file mode 100644
index 000000000..cde604411
--- /dev/null
+++ b/tests/functional/b/bad_option_value_disable.py
@@ -0,0 +1,6 @@
+"""Tests for the disabling of bad-option-value."""
+# pylint: disable=invalid-name
+
+# pylint: disable=bad-option-value
+
+var = 1 # pylint: disable=a-removed-option |
The PyLinter is pylint's internal god class, I think if we don't dare to modify it it's a problem. On the other hand, it might be possible to make the node - self.file_state.collect_block_lines(self.msgs_store, node)
+ if node is not None:
+ self.file_state.collect_block_lines(self.msgs_store, node)
+ else:
+ warnings.warn(" process_tokens... deprecation... 3.0.. bad option value won't be disablable...") |
Yeah, just making it optional and immediately deprecating it sounds good. Let's add a test for a disabling a message by ID also. |
I found some issue while working on this so it will take a little longer. However, would you guys be okay with one refactor before this to create a
For now I would only:
Edit: A preparing PR has been opened with #6537. |
Before I look closer to come up with an opinion, I just remember we have #5156, so we should keep it in mind or close it. |
I think #5156 is compatible with the proposition Daniel made, it can be a first step as it's better to inherit from |
@DanielNoord sounds good to me! |
Well, the refactor turned out to be rather pointless as I ran into multiple subtle regressions with my first approach. I'm now looking into a different solution: modifying |
Thank you for looking into it! |
Maybe a setting is enough? |
Allow lint to not fail for all version from Python 3.6 latest one to python 3.10 latest one. See also [1]. 1. pylint-dev/pylint#3312 Part of #270
See [1] about global bad-option-value fail to work. 1. pylint-dev/pylint#3312 Part of #270
See [1] about global bad-option-value fail to work. 1. pylint-dev/pylint#3312 Part of #270
See [1] about global bad-option-value fail to work. 1. pylint-dev/pylint#3312 Part of #270
Allow lint to not fail for all version from Python 3.6 latest one to python 3.10 latest one. See also [1]. 1. pylint-dev/pylint#3312 Part of #270
See [1] about global bad-option-value fail to work. 1. pylint-dev/pylint#3312 Part of #270
Steps to reproduce
useless-object-inheritance
that I want to ignore, as I'm writing code compatible with python2 and python3.# pylint: disable=useless-object-inheritance
.# pylint: disable=bad-option-value
Current behavior
# pylint: disable=bad-option-value
is ignored# pylint: disable=E0012
is ignoredExpected behavior
To be able to write code that works on several versions of pylint and not having to make sure every computer in the company and every docker container has the same pylint version.
The text was updated successfully, but these errors were encountered: