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

convert many manual NotImplementedError() calls to use @abstractmethod #7310

Merged

Conversation

Projects
None yet
3 participants
@cosmicexplorer
Copy link
Contributor

commented Mar 3, 2019

Problem

It turns out that @abstractmethod can be used with @classmethod and friends (see https://github.com/python/cpython/blob/master/Doc/library/abc.rst and search "innermost"), but we manually raise NotImplementedError in several places.

Solution

  • Replace many raise NotImplementedError('') boilerplate calls with the use of @abstractmethod!
  • Add AbstractClass to classes which don't already subclass that as it is required to use @abstractmethod.

Result

Less boilerplate is used to create classes with abstract @classpropertys!

@cosmicexplorer cosmicexplorer requested review from stuhood and jsirois Mar 3, 2019

@cosmicexplorer cosmicexplorer force-pushed the cosmicexplorer:abstract-classproperty branch from f9395eb to 205e791 Mar 4, 2019

cosmicexplorer added some commits Mar 4, 2019

@stuhood

stuhood approved these changes Mar 4, 2019

@Eric-Arellano
Copy link
Contributor

left a comment

Cool! I recommend also updating PR description with brief explanation of the AbstractClass changes.

@cosmicexplorer cosmicexplorer merged commit fb04321 into pantsbuild:master Mar 5, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.