Constants generation at end of file approach#564
Conversation
Codecov Report
@@ Coverage Diff @@
## master #564 +/- ##
==========================================
+ Coverage 98.33% 98.39% +0.06%
==========================================
Files 108 108
Lines 8027 8170 +143
==========================================
+ Hits 7893 8039 +146
+ Misses 134 131 -3
Continue to review full report at Codecov.
|
|
As far as I can tell this makes pylint and mypy happy again. Nevertheless I suggest to pull in also tests from https://github.com/rthalley/dnspython/pull/561/files#diff-502f75666576bfedda27c30bfead1f9d . IMHO it is not a good idea to use the same code to generate the constants and also to check it. Test from PR #561 should independently verify that something terrible did not happen when generating the constants. |
| module_name = enum_name[:dot] | ||
| type_name = enum_name[dot + 1:] | ||
| mod = import_module(module_name) | ||
| enum = getattr(mod, type_name) |
There was a problem hiding this comment.
This name parsing is duplicate of lines 25-32. Worth splitting it into a function?
There was a problem hiding this comment.
I'm just getting rid of the whole check() function as the independent test you suggest is a good idea. I took your code and made just a slight change to it so that we can ignore the things in dns.dnssec that are ONLY enums (i.e. NSEC3Hash and DSDigest) and don't have module-level aliases.
There was a problem hiding this comment.
I've also put the tests into their own module, test_constants.py
Here's code generation and auditing that just adds aliases for the enums to the end of the file.