Pylint: Require enums to be named IN_ALL_CAPS

Created on 14 Sep 2020  路  9Comments  路  Source: PyCQA/pylint

https://bugs.python.org/issue40721

For Python code at least, Guido has proclaimed:

https://mail.python.org/pipermail/python-ideas/2016-September/042340.html

I recommend naming all enums UPPER_CASE. They're constants (within a
namespace) and that's the rule for constants. It's helpful for the
reader of the code to realize what they are when passed around -- they
have a similar status to literal constants, you know they stand for a
unique value and not for some computed quantity.
contributor friendly enhancement help wanted

All 9 comments

@socketpair thanks for the suggestion.
As it is not right now in a PEP but just a recommendation, i think we need to discuss with other maintainers and users to decide whether or not we adopt this for pylint. @AWhetter @Pierre-Sassoulas @PCManticore what do you think about it?

Personally I write all my enums in UPPER_CASE and I think the Enums should not be changed, so its always a constant, and I think pep8 already says constants should be in uppercase. This is my interpretation though, I think we can wait for the ongoing discussion on Issue40721 to be resolved before rushing to implement something.

I think we should check for this for the same reasons that Guido gives. I'd argue that PEP-8 does cover the them because they're constants, but I'm happy to wait for Issue40721 to come to some consensus.

Totally agree with you. Let's wait for Issue40721 for now.

I put the label blocked just to ease the triage.

@hippo91 Issue40721 is closed (resolved) now.

@socketpair thanks! I removed the blocked label.

Hello! I would like to try to solve this issue.

@Hee-San Just make a pull request ! You are welcome.

Was this page helpful?
0 / 5 - 0 ratings