-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix doc & type definitions in the entities module (#1220)
- Loading branch information
Showing
15 changed files
with
190 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,61 @@ | ||
from __future__ import annotations | ||
|
||
from collections.abc import Iterable | ||
from typing import Protocol, TypedDict | ||
from typing import NewType, Protocol | ||
from typing_extensions import Required, TypedDict | ||
|
||
from openfisca_core import types as t | ||
|
||
class Entity(Protocol): | ||
# Entities | ||
|
||
#: For example "person". | ||
EntityKey = NewType("EntityKey", str) | ||
|
||
#: For example "persons". | ||
EntityPlural = NewType("EntityPlural", str) | ||
|
||
#: For example "principal". | ||
RoleKey = NewType("RoleKey", str) | ||
|
||
#: For example "parents". | ||
RolePlural = NewType("RolePlural", str) | ||
|
||
|
||
class CoreEntity(t.CoreEntity, Protocol): | ||
key: EntityKey | ||
plural: EntityPlural | None | ||
|
||
|
||
class SingleEntity(t.SingleEntity, Protocol): | ||
... | ||
|
||
|
||
class GroupEntity(Protocol): | ||
class GroupEntity(t.GroupEntity, Protocol): | ||
... | ||
|
||
|
||
class Role(Protocol): | ||
max: int | None | ||
class Role(t.Role, Protocol): | ||
subroles: Iterable[Role] | None | ||
|
||
@property | ||
def key(self) -> str: | ||
... | ||
|
||
|
||
class RoleParams(TypedDict, total=False): | ||
key: str | ||
key: Required[str] | ||
plural: str | ||
label: str | ||
doc: str | ||
max: int | ||
subroles: list[str] | ||
|
||
|
||
# Tax-Benefit systems | ||
|
||
|
||
class TaxBenefitSystem(t.TaxBenefitSystem, Protocol): | ||
... | ||
|
||
|
||
# Variables | ||
|
||
|
||
class Variable(t.Variable, Protocol): | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.