-
- Notifications
You must be signed in to change notification settings - Fork 339
Remove generic meta class from resource and async resource classes #490
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,13 @@ | ||
| """Resources module.""" | ||
| | ||
| import abc | ||
| import sys | ||
| from typing import TypeVar, Generic | ||
| | ||
| if sys.version_info < (3, 7): | ||
| from typing import GenericMeta | ||
| else: | ||
| class GenericMeta(type): | ||
| ... | ||
| | ||
| | ||
| T = TypeVar('T') | ||
| | ||
| | ||
| class ResourceMeta(GenericMeta, abc.ABCMeta): | ||
| def __getitem__(cls, item): | ||
| # Spike for Python 3.6 | ||
| return cls(item) | ||
| | ||
| | ||
| class Resource(Generic[T], metaclass=ResourceMeta): | ||
| class Resource(Generic[T]): | ||
| | ||
| @abc.abstractmethod | ||
| def init(self, *args, **kwargs) -> T: | ||
| | @@ -31,7 +18,7 @@ def shutdown(self, resource: T) -> None: | |
| ... | ||
| | ||
| | ||
| class AsyncResource(Generic[T], metaclass=ResourceMeta): | ||
| class AsyncResource(Generic[T]): | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this still not need to inherit from abc.ABC? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm... It probably needs to. I didn't have a test for unimplemented abc methods. I'll revise this later today. Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returned | ||
| | ||
| @abc.abstractmethod | ||
| async def init(self, *args, **kwargs) -> T: | ||
| | ||
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.
Does this still not need to inherit from abc.ABC?