-
Couldn't load subscription status.
- Fork 2
Initial version of the code #10
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
Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
|
I derailed a bit while importing the non-default constructible part 😬 There are still a couple more modules I want to include: |
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.
LGTM
|
@daniel-zullo-frequenz thanks to your comment I found some issues when subclassing, the custom error wasn't used. I updated the PR to use a more consistent default exception (before we used 3 different ones depending on when it was raised) and to fix the issue with subclassing, but looking up for the exception to raise in the base classes if not found in the current class. I will enable auto-merge. |
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.
A minor suggestion to clarify docs in tests, LGTM
This commit adds a new module `frequenz.core.typing` with a decorator
`disable_init` that can be used to disable the `__init__` constructor of
a class. This is useful when a class doesn't provide a default
constructor and requires the use of a factory method to create
instances.
The code is loosely based on the `_NoDefaultConstructible` class in the
SDK [`frequenz.sdk.timeseries._quantities`][1], but it was completely
rewritten to be more generic and to use a decorator instead of
inheritance, which makes also much easier to use.
```python
@disable_init
class MyClass(Super):
pass
```
Versus:
```python
class MyClass(
Super,
metaclass=_NoDefaultConstructible,
):
pass
```
Also it is safer to use, as it will raise an error as soon as a class is
declared with an `__init__` method.
[1]: https://github.com/frequenz-floss/frequenz-sdk-python/blob/88bd28e2f21b930279d66c1daf3deeaf6f9bb07a/src/frequenz/sdk/timeseries/_quantities.py#L505-L522
Signed-off-by: Leandro Lucarella <[email protected]>
This module provides general purpose async tools that can be used to simplify the development of asyncio-based applications. The code and tests were imported from the SDK: * https://github.com/frequenz-floss/frequenz-sdk-python/blob/88bd28e2f21b930279d66c1daf3deeaf6f9bb07a/src/frequenz/sdk/actor/_background_service.py * https://github.com/frequenz-floss/frequenz-sdk-python/blob/88bd28e2f21b930279d66c1daf3deeaf6f9bb07a/src/frequenz/sdk/_internal/_asyncio.py We need to ignore type hints for async-solipsism because we start using it now and it doesn't provide type hints. Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
|
Thanks, updated! |
__init__asynciomodule with general purpose async toolsdatetimemodule with aUNIX_EPOCHconstant