-
-
Notifications
You must be signed in to change notification settings - Fork 381
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
Issue #1054 - unPythonicGetterSetterViolation #1185
Conversation
* Test: improves test for UnpythonicGetterSetterViolation to cover more cases from the requirements * Test: * Adds test with property getter and setter which should be allowed * Adds test with "private" class and instance attributes and correspondinding getter or setter
* Adds false positive test with module attribute, getter and setter * Adds test with attribute in parent and getter and setter in child * Changes formatting to more adhere to the linter
* ADD get_attributes function to logic * Refactor to use get_attributes in visitors * Add partial logic code for UnpythonicGetterSetterViolation * Fix: typo * Enable tests * Lower count to correct amount * Revert "Lower count to correct amount" This reverts commit 4e6698d. * Lower count to correct amount * Feat: New violaton unPythonicGetterSetterViolation(WPS614), closes #3 * Refactor: Change in with startswith() * Refactor: change regex to lstrip() Co-authored-by: ruwaid123 <43616385+ruwaid123@users.noreply.github.com>
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.
Awesome work! We need to polish it before I can get this merged.
There are also tests to write. Check out how we test our visitors inside tests/test_visitors
Pull Request Test Coverage Report for Build 2789
💛 - Coveralls |
@sobolevn we have now made the neccesary changes. |
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.
Awesome work on such a complex feature!
We need to add more tests (since, again, it is a complex feature) and we are ready to go. 🚀
tests/test_visitors/test_ast/test_classes/test_getter_setter.py
Outdated
Show resolved
Hide resolved
* test: added a new test that checks that methods named get/set are allowed if not containing the name of a class attribute or instance attribute. relates to #22 * fix: changed description * test: added a test for checking that correct use of dataclass with property annotation is valid. relates to #22 and wemake-services#1054 * test: added test with class attribute and instance getters/setters that should be prohibited. relates to #22 and wemake-services#1054 * test: added new test cases for test_nonmatching_attribute_getter_setter, such that different types of assignments are tested. relates to #22 and wemake-services#1054 * refactor: refactored test_class_mixed to use stacked test parameters to make it easier to test many combinations. Relates to #22 and wemake-services#1054 * refactor: added accessor as a new test parameter to ease the creation of different test combinations for test_nonmatching_attribute_getter_setter and test_instance_and_class_getter_setter. Relates to #22 and wemake-services#1054 * refactor: renamed parameters in test_instance_and_class_getter_setter and test_nonmatching_attribute_getter_setter to ease readability. relates to #22 and wemake-services#1054 * test: added tests that checks that invalid use of class attributes and getters and setters are prohbited. Relates to #22, wemake-services#1054 * test: added test to ensure that class attributes with non-matching getters and setters is allowed. relates to #22, wemake-services#1054 * test: added a test for dataclass that uses explicit getters and setters on an instance attribute. This should be prohibited. Right now the test is failing, which indicates that something in the implementation needs to be looked at. Relates to #22, wemake-services#1054 * Feat: add checks for AnnAssign * Refactor: rename variable ´asd´ to ´attribute´ * Test: Adds 3 tests * Refactor: Renames some tests * Refactor: Cleans up the tests * Fix: test in wrong location * Feat: seperate class and instance methods * Fix: some linter errors * Test: Moves test and readds deleted test * test: added a test that checks that correct use of dataclass with the propert annotation is allowed relates to #22 and wemake-services#1054 * Fix: linter violations Co-authored-by: fwald <38955346+fwald@users.noreply.github.com> Co-authored-by: ruwaid123 <43616385+ruwaid123@users.noreply.github.com>
@sobolevn Here is our progress. |
@sobolevn You are a great maintaner, thank you for the feedback! Awesome project! |
Line too long.
Codecov Report
@@ Coverage Diff @@
## master #1185 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 107 107
Lines 5958 5983 +25
Branches 1330 1338 +8
=========================================
+ Hits 5958 5983 +25
Continue to review full report at Codecov.
|
I have made things!
Checklist
CHANGELOG.md
Related issues
🙏 Please, if you or your company is finding wemake-python-styleguide valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/wemake-python-styleguide. As a thank you, your profile/company logo will be added to our main README which receives hundreds of unique visitors per day.