Skip to content
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

use abc stdlib module to mark abstract classes #1122

Merged
merged 2 commits into from
Jan 26, 2020

Conversation

skarzi
Copy link
Collaborator

@skarzi skarzi commented Jan 25, 2020

I have made things!

Checklist

  • I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)
  • I have created at least one test case for the changes I have made
  • I have updated the documentation for the changes I have made
  • I have added my changes to the CHANGELOG.md

Related issues

Closes #1121

🙏 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.

@coveralls
Copy link

coveralls commented Jan 25, 2020

Pull Request Test Coverage Report for Build 2513

  • 14 of 14 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 2506: 0.0%
Covered Lines: 5031
Relevant Lines: 5031

💛 - Coveralls

@skarzi
Copy link
Collaborator Author

skarzi commented Jan 25, 2020

abc.ABC is just small helper - it is object's subclass that use abc.ABCMeta metaclass, so it just makes most common abstract classes definitions more concise.
Generally any class that subclass some ABC class and do NOT override all abstract methods is also ABC class, that's the reason I haven't add metaclass=abc.ABCMeta to BaseFilenameVisitor however I have used @abc.abstractmethod decorator on visit_filename().

We can add metaclass=abc.ABCMeta to other classes, however they aren't real ABC classes, because they already implement run() method (which is the only abstract method they need to implement), so it will be just an information to developers

@skarzi
Copy link
Collaborator Author

skarzi commented Jan 25, 2020

Similar story with all violations' base classes, but there even BaseViolation is not a real ABC class, because it doesn't declare any abstract method, however still we can make its class attributes abstract by using 2nd or 3rd solution that I have mentioned in issue #1121 comment

@sobolevn
Copy link
Member

sobolevn commented Jan 25, 2020

so it will be just an information to developers

Yes, please! That was the main idea behind this change.
Sometimes developers what to see what classes are base ones (that how this task was originally born). And this (I hope) is going to help them.

@sobolevn sobolevn merged commit 88756fe into wemake-services:master Jan 26, 2020
@sobolevn
Copy link
Member

Thanks a lot! 😄

@skarzi skarzi deleted the issue-1121 branch January 26, 2020 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make abstract classes abstract
3 participants