-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Show why snake_case errors is emitted on single word variables (might be too small) #2018
Comments
Hi, thanks for creating this issue! Can you also post your |
Is there a way to configure the minimum length of the variable name? |
@eight04 Not quite, the only thing you could do is to change the |
I tried setting
EDIT: Oh I found out, I got this error for a function argument, and that's a different option:
This works for me :)! |
Why is variable length important at all? |
I agree with @filips123 - I've been using Python to do physics calculations and I use vars like |
@pedro-w and @filips123 If |
Is it possible to specify |
No, that's not possible. |
Why? Can you add support for this? It would be useful if only one file contains that variables. |
Because it requires changing how we do configuration, it's a high effort project that is not worth it for almost all the cases. |
To give more specific solution for people who will run into this bug:
will stop complaining about perfectly good names. BTW, it would be nice to have solution similar to Rubocop config files - where it is easy to exclude complaints about names that make perfect sense (and some like See matkoniecz/matkoniecz-ruby-style@e2df9de (how people may configure allowed names) and rubocop/rubocop#6137 "Allow |
@matkoniecz That's most likely an use case for good-names |
Reading the above discussion, I learned about the I'm using a freshly installed pylint (using pip under python3.7):
With this version, variable name I may be remembering wrong, but it seems to me that some time ago, pylint would not report about |
I just ask a clarification. I thought it was standard name to use |
@demongolem Reading above, I think you just need to Add |
I got this warning even for stuff like |
@chrissshe Not by default, |
@PCManticore That's probably the case. I edited |
I understand that it may be a high effort project, thus remain patient for it to stay on the long-term road map for implementation. The remark about not worth it for almost all the cases is opinion and is at odds with a substantial community. In physics, common coding practice will often adopt names used in textbooks or published literature as being best choice. These names are recognized internationally, even though they rely on domain-specific jargon, it is exactly the entirety of that community they reach. As we recommend value-added steps, such as linting, to coding practice for our non-programmer peers, we must advise them which of these findings to either heed or ignore. For sure, none of these pylint novices will apply local configurations or regexp rules. As it stands now, a pylint report is rife with such false positive findings. We insist to our novices that these reports are only advisory. A command-line option would be of great benefit to a significant community. |
@prjemian Thanks for the comment, but I'm not sure why Also I'm not sure you're quoting me on the right context. The quoted answer was related to #2018 (comment), which suggests to add inline comments for I'm not sure what your comment is suggesting though. Is it the inline comment support? Is it something else? Right now this issue is about showing why a short variable might not match the naming style, namely because it is too short, not because it does not match the chosen naming style. |
@PCManticore : This was your quote, right? I missed that it referred to markup in the python file that identified potential good names. Thanks to your reply, investigated further the
That's about as good as I can hope for. |
|
there are some names in the standard library that are camelCase eg like maxDiff |
Can I add one more case? @dataclass
class Track(DownloadItem):
"""
Track class represents a track and its album.
Track class implements DownloadItem protocol, so it can be downloaded.
"""
album: Album
id_: Id
info: dict[str, Any] = field(default_factory=dict)
meta: dict[str, Any] = field(default_factory=dict)
# v- This part is highlighted in PyCharm (I'm using standard external tool - Pylint (latest version, on Python 3.10.5))
###
def id(self) -> int:
"""
Retrieves id from Id object.
Returns:
int: The id value of track.
"""
return self.id_.value This is very strange to get such kind of warnings. If you check conform criterion by length that you should exclude all short words |
@Pierre-Sassoulas I'd be happy to help here since it's high priority, but given all the back and forth I can't figure out what the decision is here? What's the ask that would close this issue? |
The short answer is that we need to create a new message |
In the mean time, if you use Flake8, you can try out https://github.com/PyCQA/pep8-naming . Personally it fit my needs better than pylint for naming convention. Since I tend to follow PEP8 naming conventions anyway. |
(Not affiliated with pylint, only providing a hint for people like me looking for workarounds) |
I have a proposal I'd appreciate feedback on. I think we need a fast fix for this that does not require thinking through a new spec as discussed in #7305. Why?
In 3.0, if we just remove the length requirements from the default regexes, and explain in the release notes how to regain a check for length if wanted (via existing regexes), that would be good enough. #2018 is a blocker for 3.0, I think. We can always do #7305 later. There is likely not time for significant new features in 3.0; we need to move to beta this summer. Is there an easy way for users to regain the 3+ character requirement if we change the default regexes?
Either way, for the user that wants pylint to continue to fail names like |
Sounds good to me! Are you also working on a PR, I'd be happy to help with review. I think (like you said) this can be put clearly in the changelog, but we might also want to put this info a little bit more explicitly in the documentation. Can just be in the |
I'll put up a PR very shortly |
amazing 👏 |
Steps to reproduce
Current behavior
I'm getting an error saying that 'no' doesn't conform the camel_case style, even though it's only one word.
Expected behavior
There should be no error.
pylint --version output
pylint 1.8.4,
astroid 1.6.3
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)]
The text was updated successfully, but these errors were encountered: