Skip to content
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

Message id 'W1601' cannot have both 'apply-builtin' and 'using-f-string-in-unsupported-version' as symbolic name. #5723

Closed
renardeinside opened this issue Jan 25, 2022 · 7 comments
Labels
Downstream Bug 🪲 The problem happens in a lib depending on pylint, not pylint Invalid Not a bug, already exists or already fixed
Milestone

Comments

@renardeinside
Copy link

Bug description

I've recently upgraded prospector and pylint and run into the following:

> prospector --profile prospector.yaml
Traceback (most recent call last):
  File "/Users/ivan.trusov/opt/anaconda3/bin/prospector", line 8, in <module>
    sys.exit(main())
  File "/Users/ivan.trusov/opt/anaconda3/lib/python3.7/site-packages/prospector/run.py", line 183, in main
    prospector.execute()
  File "/Users/ivan.trusov/opt/anaconda3/lib/python3.7/site-packages/prospector/run.py", line 56, in execute
    for tool in self.config.get_tools(found_files):
  File "/Users/ivan.trusov/opt/anaconda3/lib/python3.7/site-packages/prospector/config/__init__.py", line 41, in get_tools
    config_result = tool.configure(self, found_files)
  File "/Users/ivan.trusov/opt/anaconda3/lib/python3.7/site-packages/prospector/tools/pylint/__init__.py", line 125, in configure
    check_paths, config_messages, configured_by, ext_found, linter, prospector_config, pylint_options
  File "/Users/ivan.trusov/opt/anaconda3/lib/python3.7/site-packages/prospector/tools/pylint/__init__.py", line 214, in _get_pylint_configuration
    config_messages = self._prospector_configure(prospector_config, linter)
  File "/Users/ivan.trusov/opt/anaconda3/lib/python3.7/site-packages/prospector/tools/pylint/__init__.py", line 31, in _prospector_configure
    linter.load_default_plugins()
  File "/Users/ivan.trusov/opt/anaconda3/lib/python3.7/site-packages/pylint/lint/pylinter.py", line 579, in load_default_plugins
    checkers.initialize(self)
  File "/Users/ivan.trusov/opt/anaconda3/lib/python3.7/site-packages/pylint/checkers/__init__.py", line 133, in initialize
    register_plugins(linter, __path__[0])
  File "/Users/ivan.trusov/opt/anaconda3/lib/python3.7/site-packages/pylint/utils/utils.py", line 198, in register_plugins
    module.register(linter)
  File "/Users/ivan.trusov/opt/anaconda3/lib/python3.7/site-packages/pylint/checkers/unsupported_version.py", line 85, in register
    linter.register_checker(UnsupportedVersionChecker(linter))
  File "/Users/ivan.trusov/opt/anaconda3/lib/python3.7/site-packages/pylint/lint/pylinter.py", line 723, in register_checker
    self.msgs_store.register_messages_from_checker(checker)
  File "/Users/ivan.trusov/opt/anaconda3/lib/python3.7/site-packages/pylint/message/message_definition_store.py", line 39, in register_messages_from_checker
    self.register_message(message)
  File "/Users/ivan.trusov/opt/anaconda3/lib/python3.7/site-packages/pylint/message/message_definition_store.py", line 44, in register_message
    message.msgid, message.symbol, message.old_names
  File "/Users/ivan.trusov/opt/anaconda3/lib/python3.7/site-packages/pylint/message/message_id_store.py", line 44, in register_message_definition
    self.check_msgid_and_symbol(msgid, symbol)
  File "/Users/ivan.trusov/opt/anaconda3/lib/python3.7/site-packages/pylint/message/message_id_store.py", line 81, in check_msgid_and_symbol
    self._raise_duplicate_symbol(msgid, symbol, existing_symbol)
  File "/Users/ivan.trusov/opt/anaconda3/lib/python3.7/site-packages/pylint/message/message_id_store.py", line 90, in _raise_duplicate_symbol
    raise InvalidMessageError(error_message)
pylint.exceptions.InvalidMessageError: Message id 'W1601' cannot have both 'apply-builtin' and 'using-f-string-in-unsupported-version' as symbolic name.

Configuration

No response

Command used

prospector --profile prospector.yaml

Pylint output

pylint.exceptions.InvalidMessageError: Message id 'W1601' cannot have both 'apply-builtin' and 'using-f-string-in-unsupported-version' as symbolic name.

Expected behavior

Something more helpful/useful for debugging purposes.

Pylint version

pylint 2.12.2
astroid 2.9.3
Python 3.7.6 (default, Jan  8 2020, 13:42:34) 
[Clang 4.0.1 (tags/RELEASE_401/final)]

OS / Environment

macOS Big Sur 11.6.2

Additional dependencies

prospector==1.6.0

@renardeinside renardeinside added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jan 25, 2022
@DanielNoord
Copy link
Collaborator

Could you post your pylint configuration? apply-builtin isn't coming from the pylint codebase and I couldn't find a match for it in prospector as well. Are you using a plugin that defines the apply-builtin message?

@Pierre-Sassoulas Pierre-Sassoulas added Downstream Bug 🪲 The problem happens in a lib depending on pylint, not pylint and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jan 26, 2022
@renardeinside
Copy link
Author

hi @DanielNoord ,

I don't have a separate .pylintrc file, prospector.yml looks like this:

strictness: high
test-warnings: True
doc-warnings: false

ignore-paths:
  - build
  - tests
  - dbx/templates

max-line-length: 120

pylint:
  disable:
    - too-many-statements
    - too-many-instance-attributes
    - cyclic-import
    - len-as-condition
    - invalid-name
    - no-else-return
    - no-self-use
    - protected-access
    - too-many-arguments
    - too-many-locals # TBD: this rule is actually a good one, we need to enable it and refactor code
    - inconsistent-return-statements
    - import-outside-toplevel
    - consider-using-set-comprehension
    - useless-object-inheritance
    - unnecessary-pass

pep8:
  disable: W293 # disabled because we have newlines in docstrings

mccabe:
  disable:
    - MC0001

@DanielNoord
Copy link
Collaborator

I opened prospector-dev/prospector#481 to see what is causing this. This also showed me a potential incompatibility with pylint and prospector which I have also mentioned in that issue, so that's a good thing to come from this either way.

@carlio
Copy link

carlio commented Jan 26, 2022

@renardeinside How did you run and install the repository? I checked out dbx locally to try to reproduce, but it worked fine with:

pylint==2.12.2
astroid==2.9.3
prospector==1.6.0
python==3.7.12

This was starting from a fresh checkout and virtualenvironment; on the dbx repo I ran:

pip install -e .
pip install -r dev-requirements.txt
make lint
prospector -X --profile prospector.yaml

And I did not get this stack trace.

@carlio
Copy link

carlio commented Jan 26, 2022

I noticed that dev-requirements does not specify a pylint version: https://github.com/databrickslabs/dbx/blob/main/dev-requirements.txt

Which means that the pip install -U in the CI file: https://github.com/databrickslabs/dbx/blob/main/.github/workflows/onpush.yml#L39

Will only upgrade things including prospector to their latest versions but will not upgrade prospector dependencies beyond the range specified:
https://github.com/PyCQA/prospector/blob/master/pyproject.toml#L42

Which means that given the CI caches the virtualenvironment, you probably still have an older version of pylint perhaps as old as 2.8.3
https://github.com/databrickslabs/dbx/blob/main/.github/workflows/onpush.yml#L26

Since the cache uses the contents of requirements.txt as the key and the change you made to dev-requirements.txt will not invalidate that cache (in the dependabot PR here - databrickslabs/dbx#133)

Prospector is very backwards-compatible with pylint and I suspect that has caused your CI process having an older version of pylint still hanging around.

@renardeinside
Copy link
Author

hi @carlio ,

I was debugging the latest issues from prospector and wanted to run the linter locally - this is when I've met the error.

I've noticed that probably I was using another conda env (base) locally which led to this error, thank you for the pointers (on the CI part as well)!

Just as a side note, in the base conda env, it's still failing (although it has slightly different versions). It's not a blocker for me, but might be a topic for exploration.

Here are the versions in the local, non-working env (base):

> pylint --version 
pylint 2.12.2
astroid 2.9.3
Python 3.7.6 (default, Jan  8 2020, 13:42:34) 
[Clang 4.0.1 (tags/RELEASE_401/final)]

> prospector --version
prospector 1.6.0

new env (working):

> pylint --version
pylint --version
pylint 2.12.2
astroid 2.9.3
Python 3.7.7 (default, May  6 2020, 04:59:01) 
[Clang 4.0.1 (tags/RELEASE_401/final)]

> prospector --version
prospector 1.6.0

@DanielNoord
Copy link
Collaborator

DanielNoord commented Mar 1, 2022

After discussion and investigation with @carlio in prospector (see prospector-dev/prospector#481) I think we're going to close this. This was most likely the result of an old pylint version somewhere in a cache.
I don't know how messages from a removed checker could be registered in 2.12.2.

Do note that we have added additional checks against re-using deprecated message ids so warnings like these should be better avoided in the future.

@DanielNoord DanielNoord added the Invalid Not a bug, already exists or already fixed label Mar 1, 2022
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.13.0 milestone Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Downstream Bug 🪲 The problem happens in a lib depending on pylint, not pylint Invalid Not a bug, already exists or already fixed
Projects
None yet
Development

No branches or pull requests

4 participants