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

Improve --dummy-variables-rgx and --ignored-argument-names documentation #8013

Open
nortti opened this issue Jan 2, 2023 · 2 comments
Open
Labels
Documentation 📗 Enhancement ✨ Improvement to a component Needs specification 🔐 Accepted as a potential improvement, and needs to specify edge cases, message names, etc.

Comments

@nortti
Copy link

nortti commented Jan 2, 2023

Question

Could the documentation be made more helpful for people trying to ignore dummy arguments?

Documentation for future user

Suppose that I'm looking to suppress unused-argument for all function arguments starting with "mock_".

I might find the option --dummy-variables-rgx:

A regular expression matching the name of dummy variables (i.e. expected to not be used). (default: _+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_)

But wait, it doesn't work. Even though arguments are variables.

I might then find the option --ignored-argument-names:

Argument names that match this expression will be ignored. (default: re.compile('_.*|^ignored_|^unused_'))

The default value looks promising. But wait, why isn't it named --dummy-arguments-rgx? And why is the documentation so different? Is it because this is actually going to suppress a bunch of messages other than unused-variable, such as invalid_name? What does it actually do? Even regular maintainers are confused.

Eventually I learn that it will (at least) suppress unused-variable, too-many-args, and some docstring message(s).

My suggestion is to

  • clarify that --dummy-variables-rgx will not work for dummy arguments and point the user towards --ignored-argument-names, and
  • make the documentation of --ignored-argument-names clear about what it actually does (what messages it might suppress).

Additional context

No response

@nortti nortti added Documentation 📗 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling Question labels Jan 2, 2023
@Pierre-Sassoulas Pierre-Sassoulas added Enhancement ✨ Improvement to a component Needs specification 🔐 Accepted as a potential improvement, and needs to specify edge cases, message names, etc. and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling Question labels Jan 2, 2023
@Pierre-Sassoulas
Copy link
Member

Thank you for opening the issue. There's three aspect to this:

@treyra
Copy link

treyra commented May 15, 2023

Wanted to bump this as another user that expected dummy-variables-rgx to affect arguments, and was surprised and confused when it didn't.

The current FAQ also suggests that they should (see here) so I think it would be most straight forward to have arguments matching dummy-variables-rgx excluded from unused-argument, if that wouldn't break other checks. It's worth noting prefixing the methods name as also suggested in the FAQ works, but I think there are use cases beyond call backs where this feature would be useful, and where blanket suppressing other argument warnings by adding "dummy" to --ignored-argument-names might ignore more than desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation 📗 Enhancement ✨ Improvement to a component Needs specification 🔐 Accepted as a potential improvement, and needs to specify edge cases, message names, etc.
Projects
None yet
Development

No branches or pull requests

3 participants