-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
part:typingAffects the typing moduleAffects the typing moduletype:enhancementNew feature or enhancement visitble to usersNew feature or enhancement visitble to users
Milestone
Description
What's needed?
It is sometimes useful when working with dataclasses in a generic way to be able to have a type-hint that will detect passing non-dataclasses by mypy instead of at runtime.
Proposed solution
Add a new class to frequenz.core.typing like:
from typing import Protocol
class Dataclass(Protocol):
__dataclass_fields__: dictUse cases
Wrappers using marshmallow_dataclass, where we want to make sure we take a dataclass, for example for loading as if it where a schema.
Alternatives and workarounds
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
part:typingAffects the typing moduleAffects the typing moduletype:enhancementNew feature or enhancement visitble to usersNew feature or enhancement visitble to users