Skip to content

Conversation

@llucax
Copy link
Contributor

@llucax llucax commented Jun 14, 2024

  • Add more keywords to the project metadata
  • Remove the generated dummy code
  • Add a typing module with a decorator to disable __init__
  • Add a new asyncio module with general purpose async tools
  • Add a datetime module with a UNIX_EPOCH constant

llucax added 2 commits June 14, 2024 17:55
Signed-off-by: Leandro Lucarella <[email protected]>
@llucax llucax requested a review from a team as a code owner June 14, 2024 16:19
@llucax llucax requested a review from Marenz June 14, 2024 16:19
@github-actions github-actions bot added part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) part:typing Affects the typing module part:asyncio Affects the asyncio module part:datetime Affects the datetime module labels Jun 14, 2024
@llucax llucax added the cmd:skip-release-notes It is not necessary to update release notes for this PR label Jun 14, 2024
@llucax
Copy link
Contributor Author

llucax commented Jun 14, 2024

I derailed a bit while importing the non-default constructible part 😬

There are still a couple more modules I want to include: math with is_close_to_zero() (but I want to write some basic tests) and collections with Bounds (but I want to get the PR finalized in the SDK first).

Copy link

@daniel-zullo-frequenz daniel-zullo-frequenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@llucax
Copy link
Contributor Author

llucax commented Jun 19, 2024

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

@llucax llucax enabled auto-merge June 19, 2024 13:34
@llucax llucax added this to the v1.0.0 milestone Jun 19, 2024
Copy link

@daniel-zullo-frequenz daniel-zullo-frequenz left a 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

llucax added 3 commits June 20, 2024 09:07
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]>
@llucax llucax force-pushed the initial-version branch from fe59abf to 4d25d17 Compare June 20, 2024 07:08
@llucax
Copy link
Contributor Author

llucax commented Jun 20, 2024

Thanks, updated!

@llucax llucax added this pull request to the merge queue Jun 20, 2024
Merged via the queue into frequenz-floss:v1.x.x with commit fe4551b Jun 20, 2024
@llucax llucax deleted the initial-version branch June 20, 2024 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmd:skip-release-notes It is not necessary to update release notes for this PR part:asyncio Affects the asyncio module part:datetime Affects the datetime module part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) part:typing Affects the typing module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants