Skip to content

Allow disabling bad-option-value and unrecognized-option with --disable=all #6691

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

Merged

Conversation

jacobtylerwalls
Copy link
Member

@jacobtylerwalls jacobtylerwalls commented May 24, 2022

Type of Changes

Type
βœ“ πŸ› Bug fix

Description

Previously, due to the order in which options are parsed (config file, then command line), any unrecognized or bad options in the config file would emit messages unconditionally, even if suppressed on the CLI.

Closes #6565

…disable=all`

Previously, due to the order in which options are parsed (config file, then command line), any unrecognized or bad options in the config file would emit messages unconditionally, even if suppressed on the CLI.
@jacobtylerwalls jacobtylerwalls added this to the 2.14.0 milestone May 24, 2022
@coveralls
Copy link

coveralls commented May 25, 2022

Pull Request Test Coverage Report for Build 2397585660

  • 20 of 20 (100.0%) changed or added relevant lines in 4 files are covered.
  • 21 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.003%) to 95.423%

Files with Coverage Reduction New Missed Lines %
pylint/checkers/utils.py 21 95.53%
Totals Coverage Status
Change from base Build 2378134557: 0.003%
Covered Lines: 16242
Relevant Lines: 17021

πŸ’› - Coveralls

@jacobtylerwalls jacobtylerwalls marked this pull request as ready for review May 25, 2022 00:25
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could have a mechanism in place to signal that the configuration is parsed (boolean config_is_parsed ?) and use a stash directly in add_message for any message if the configuration is not parsed yet.

@jacobtylerwalls
Copy link
Member Author

I think we could have a mechanism in place to signal that the configuration is parsed (boolean config_is_parsed ?) and use a stash directly in add_message for any message if the configuration is not parsed yet.

I guess I didn't want to generalize it because the use case is so niche and we don't want to encourage or suggest using it for other messages (these are the only messages that it makes sense to emit before configuration is finished). There's also the matter of needing to stashing the location if we generalize it, which increases complexity (and might needlessly change the signature of add_message.)

Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done getting this to work @jacobtylerwalls

Just one question:
Not sure if you thought about this but what about making stashed_bad_option_value_messages a dictionary with keys reflecting the current module. We could use linter.current_name to look up the correct name in the dictionary to put the message under in the callback action and then just iterate over the keys in emit_bad_option_value (and reset current_name there).

At some point I want to be able to parse multiple configuration files at once to create different config namespaces for sub-directories. So, just messages_from_config_file might not be enough as we would need access to the different config file names.

Besides it would remove the need for L61-64 which is arguably a bit hacky. (The need for set_module before add_message is horrible anyway).

Another thing is that stashed_bad_option_value_messages should probably be _stashed_bad_option_value_messages to avoid any future deprecation issues.

@jacobtylerwalls
Copy link
Member Author

Nice. Yeah I went that direction and paused as I wasn't sure of the use case, so that's helpful to hear it would be used! Will do.

@Pierre-Sassoulas Pierre-Sassoulas self-requested a review May 27, 2022 11:07
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@jacobtylerwalls jacobtylerwalls merged commit a7ff1fd into pylint-dev:main May 27, 2022
@jacobtylerwalls jacobtylerwalls deleted the disable-config-file-linting branch May 27, 2022 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow disabling bad-option-value and unrecognized-option with --disable=all
4 participants