WIP: make pylint happy#561
Conversation
pylint does not see Enum members exposed from modules via globals().update(Algorithm.__members__) This leads to tons of complains from pylint in third-party code which uses trivial expressions like e.g. dns.flags.DO leads to error E1101: Module 'dns.flags' has no 'DO' member (no-member) This change exports Enum values statically so pylint can see them. New test code verifies that all Enums in specified modules actually export all its members so we omissions will be caught. It re-introduces some duplication but I believe it is good tradeoff as it allows static checkers to work again.
|
Hi @rthalley @bwelling! I realize this is a bit controversial but I cannot see other way to enable static code checkers to work with dnspython 2.y.z. What do you think? |
Codecov Report
@@ Coverage Diff @@
## master #561 +/- ##
=======================================
Coverage 98.31% 98.32%
=======================================
Files 108 108
Lines 8032 8062 +30
=======================================
+ Hits 7897 7927 +30
Misses 135 135
Continue to review full report at Codecov.
|
|
Example of pylint failures caused by "too much dynamic magic" in 2.0.0: https://gitlab.nic.cz/knot/deckard/pipelines/66674/failures |
|
First, let me say I hear what you're saying, and it's a good point. Introducing noise into other people's static checking is not something I want to do. I have traditionally used very high warning levels and warnings-are-errors in other projects, and it has been very helpful. And if you're doing that, you really want "zero warnings" to be the norm, as otherwise you miss the content in the noise. On the other hand, I have been deeply annoyed with pylint many times. Probably I should do another pass to get dnspython back to zero warnings. I think there are three basic approaches:
I don't like 3), but am listing it for completeness. I don't like it as it's making N people cope with noise instead of just us, so it wastes more time. 1) and 2) are pretty much equally ugly and have the same danger level. 2) might be less tedious, though it might still take longer :) |
|
Example generator code |
|
(The generator code is stuffing all the generated files into a "constants" directory so I don't have the listing of the "dns" directory cluttered by them.) |
pylint does not see Enum members exposed from modules via
globals().update(Algorithm.members)
This leads to tons of complains from pylint in third-party code which
uses trivial expressions like e.g. dns.flags.DO leads to error
E1101: Module 'dns.flags' has no 'DO' member (no-member)
This change exports Enum values statically so pylint can see them.
New test code verifies that all Enums in specified modules actually
export all its members so we omissions will be caught.
It re-introduces some duplication but I believe it is good tradeoff as
it allows static checkers to work again.