-
Notifications
You must be signed in to change notification settings - Fork 134
OnePerClass linter rules for identifier and key attributes
#2921
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
Conversation
| Each attribute of this class represents a rule that can be enabled and possibly | ||
| configured by a configuration file. | ||
| attributes: | ||
| canonical_prefixes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put these in alphabetical order, hence the large diff in this and the generated file.
| validator = validator_cls(meta_json_schema, format_checker=validator_cls.FORMAT_CHECKER) | ||
| return validator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to create a variable if you return it immediately.
| class OnePerClass(LinterRule): | ||
| """Ensures that there is only one slot with the specified attribute per class.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both checks are very similar so can create a more generic function to test.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2921 +/- ##
==========================================
+ Coverage 80.41% 83.82% +3.41%
==========================================
Files 140 140
Lines 15588 15611 +23
Branches 3167 3171 +4
==========================================
+ Hits 12535 13086 +551
+ Misses 2399 1833 -566
- Partials 654 692 +38 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a9d3dc5 to
d49ef03
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test function is quite complex and difficult to review without running it. I have another look tomorrow.
|
LMK if there is extra documentation or more comments that I can add to the tests to make it clearer how I'm generating the schemas. It makes perfect sense when you're writing the code but isn't always easy to decode when reading it. |
88a233a to
55b7a7e
Compare
| - id_slot_false | ||
| - key_slot_false | ||
| This allows the testing of a large number of combinations without having to generate them all manually. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To help grasp the pytest trick you could be explicit: "This and the stacked parametrize decorators allow testing of all combinations (2**6=64) ..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the additional comments. They helped to understand what will happen in the test. I first read the code and then ran it with some print-statements to verify my understanding.
Adding linter rules to enforce rules that ensure that
identifierandkeyonly appear once per class