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

Observe specific enables/disables even if followed by "all" #8819

Merged

Conversation

jacobtylerwalls
Copy link
Member

Type of Changes

Type
βœ“ πŸ› Bug fix
βœ“ ✨ New feature

Description

Let individual enables/disables take effect even if followed by --enable=all or --disable=all. Previously, this was order-specific, which is tolerable on the CLI but inconvenient for configuration files.

This means that for:

pylint my_module --enable=fixme --disable=all

...you'll now get the fixme messages, whereas before, you'd have to reverse the order of the arguments. (If the new result is not what you want, you can get the prior behavior by removing the superfluous first argument.)

Order-dependence still applies for message categories such as "R", "W", etc. This PR just moves the =all arguments to the front.

Providing both --enable=all and --disable=all in any order now raises an exception.

Closes #3696

@jacobtylerwalls jacobtylerwalls added the Configuration Related to configuration label Jul 4, 2023
@jacobtylerwalls jacobtylerwalls added this to the 3.0.0a7 milestone Jul 4, 2023
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@codecov
Copy link

codecov bot commented Jul 4, 2023

Codecov Report

Merging #8819 (b611931) into main (2e3798a) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #8819      +/-   ##
==========================================
+ Coverage   95.89%   95.90%   +0.01%     
==========================================
  Files         173      173              
  Lines       18511    18536      +25     
==========================================
+ Hits        17751    17777      +26     
+ Misses        760      759       -1     
Impacted Files Coverage Ξ”
pylint/config/config_initialization.py 98.88% <100.00%> (+0.50%) ⬆️

... and 1 file with indirect coverage changes

@github-actions

This comment has been minimized.

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 it make sense, great work ! We might want to extract the logic tp be able to use all in inline comment later ?

@github-actions
Copy link
Contributor

github-actions bot commented Jul 4, 2023

πŸ€– Effect of this PR on checked open source code: πŸ€–

Effect on coverage:
The following messages are now emitted:

  1. deprecated-typing-alias:
    'typing.Tuple' is deprecated, use 'tuple' instead
    https://github.com/nedbat/coveragepy/blob/7a32450257db47e10ac4f28451509a9a1577d564/coverage/sqlitedb.py#L160

The following messages are no longer emitted:

  1. deprecated-typing-alias:
    'typing.Tuple' is deprecated, use 'tuple' instead
    https://github.com/nedbat/coveragepy/blob/7a32450257db47e10ac4f28451509a9a1577d564/coverage/inorout.py#L124
  2. deprecated-typing-alias:
    'typing.Tuple' is deprecated, use 'tuple' instead
    https://github.com/nedbat/coveragepy/blob/7a32450257db47e10ac4f28451509a9a1577d564/coverage/inorout.py#L525
  3. deprecated-typing-alias:
    'typing.Tuple' is deprecated, use 'tuple' instead
    https://github.com/nedbat/coveragepy/blob/7a32450257db47e10ac4f28451509a9a1577d564/coverage/inorout.py#L540
  4. deprecated-typing-alias:
    'typing.Tuple' is deprecated, use 'tuple' instead
    https://github.com/nedbat/coveragepy/blob/7a32450257db47e10ac4f28451509a9a1577d564/coverage/misc.py#L83
  5. deprecated-typing-alias:
    'typing.Tuple' is deprecated, use 'tuple' instead
    https://github.com/nedbat/coveragepy/blob/7a32450257db47e10ac4f28451509a9a1577d564/coverage/execfile.py#L42
  6. deprecated-typing-alias:
    'typing.Tuple' is deprecated, use 'tuple' instead
    https://github.com/nedbat/coveragepy/blob/7a32450257db47e10ac4f28451509a9a1577d564/coverage/html.py#L80

This comment was generated for commit b611931

@@ -147,3 +154,48 @@ def _config_initialization(
for arg in parsed_args_list
)
)


def _order_all_first(config_args: list[str], *, joined: bool) -> list[str]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you consider making this part of ArgumentsManager? It feels like we want to make this the default behaviour and don't want it to be possible to parse arguments without this behaviour right?

Copy link
Member Author

Choose a reason for hiding this comment

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

To be honest, I didn't, since I'm not clear what the responsibility of the ArgumentsManager is and didn't step through it with a debugger. It doesn't seem to do any argument parsing; it seemed that was done in _config_initialization. Happy to take suggestions though.

It feels like we want to make this the default behaviour and don't want it to be possible to parse arguments without this behaviour right?

Is there a way to avoid going through _config_initialization? πŸ€”

Copy link
Collaborator

Choose a reason for hiding this comment

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

We do so here:

args = self._parse_command_line_configuration(args)

Although all isn't used here.

I also think we might skip in some test setups.

I'm not sure, we do quite a bit of parsing in config_initialization as well and perhaps ArgumentsManager should be kept small. Let's see what Pierre thinks.

Copy link
Member

Choose a reason for hiding this comment

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

I'm also not very clear on the design if the argument parser, I usually have simple argparse add_argument calls with custom type if required in my code. The current design might be due to optparse being used before or the need to pre-parse some if the arguments ? Anyway, it seems to work as is, so I don't think committing too much in the current design or a refactor of the current design or this merge request would be worth it.

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.

LGreatTM :)

@@ -43,6 +43,11 @@
str(path.relative_to(FUNCTIONAL_DIR))
for ext in ACCEPTED_CONFIGURATION_EXTENSIONS
for path in FUNCTIONAL_DIR.rglob(f"*.{ext}")
if (str_path := str(path))
# The enable/disable all tests are not practical with this framework.
# They require manually listing ~400 messages, which will
Copy link
Member

Choose a reason for hiding this comment

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

Hurgh, yeah, too bad.

@@ -147,3 +154,48 @@ def _config_initialization(
for arg in parsed_args_list
)
)


def _order_all_first(config_args: list[str], *, joined: bool) -> list[str]:
Copy link
Member

Choose a reason for hiding this comment

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

I'm also not very clear on the design if the argument parser, I usually have simple argparse add_argument calls with custom type if required in my code. The current design might be due to optparse being used before or the need to pre-parse some if the arguments ? Anyway, it seems to work as is, so I don't think committing too much in the current design or a refactor of the current design or this merge request would be worth it.

@jacobtylerwalls jacobtylerwalls merged commit 0560ddf into pylint-dev:main Jul 11, 2023
@jacobtylerwalls jacobtylerwalls deleted the specific-enable-before-all branch July 11, 2023 11:07
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.

enable/disable options in rcfile should not depend on the order with which they are specified
3 participants