diff --git a/openfisca_core/populations/_core_population.py b/openfisca_core/populations/_core_population.py index cead5687b..0f0d968ce 100644 --- a/openfisca_core/populations/_core_population.py +++ b/openfisca_core/populations/_core_population.py @@ -28,7 +28,7 @@ class CorePopulation: """Base class to build populations from. Args: - entity: The :class:`.CoreEntity` of the population. + entity: The :class:`~entities.CoreEntity` of the population. *__args: Variable length argument list. **__kwds: Arbitrary keyword arguments. @@ -43,7 +43,7 @@ class CorePopulation: #: A pseudo index for the members of the population. ids: Sequence[str] = [] - #: The :class:`.Simulation` for which the population is calculated. + #: The :class:`~simulations.Simulation` for which the population is calculated. simulation: None | t.Simulation = None #: The holders of the variables. @@ -67,7 +67,7 @@ def __call__( options: The options to use for the calculation. Returns: - None: If there is no :class:`.Simulation`. + None: If there is no :class:`~simulations.Simulation`. ndarray[generic]: The result of the calculation. Raises: diff --git a/openfisca_core/populations/_errors.py b/openfisca_core/populations/_errors.py index a8c64916f..69bda1a5a 100644 --- a/openfisca_core/populations/_errors.py +++ b/openfisca_core/populations/_errors.py @@ -1,11 +1,13 @@ from openfisca_core import types as t +from ._enums import Option + class IncompatibleOptionsError(ValueError): """Raised when two options are incompatible.""" def __init__(self, variable_name: t.VariableName) -> None: - add, divide = t.Option + add, divide = Option msg = ( f"Options {add} and {divide} are incompatible (trying to compute " f"variable {variable_name})." diff --git a/openfisca_core/reforms/reform.py b/openfisca_core/reforms/reform.py index 76e715233..1f0b0ed38 100644 --- a/openfisca_core/reforms/reform.py +++ b/openfisca_core/reforms/reform.py @@ -71,7 +71,8 @@ def modify_parameters(self, modifier_function): Call this function in `apply()` if the reform asks for legislation parameter modifications. Args: - modifier_function: A function that takes a :obj:`.ParameterNode` and should return an object of the same type. + modifier_function: A function that takes a :obj:`~parameters.ParameterNode` and should return an object of + the same type. """ baseline_parameters = self.baseline.parameters diff --git a/openfisca_core/types.py b/openfisca_core/types.py index 50f3b5e85..4d781e122 100644 --- a/openfisca_core/types.py +++ b/openfisca_core/types.py @@ -321,9 +321,6 @@ def __getitem__(self, __index: str | VarArray, /) -> ParameterNodeChild: ... #: For example 2020. PeriodInt = NewType("PeriodInt", int) -#: Type alias for a period-like object. -PeriodLike: TypeAlias = Union["Period", "PeriodStr", PeriodInt] - class _InstantStrMeta(type): def __instancecheck__(self, arg: object) -> bool: @@ -406,15 +403,15 @@ def offset( ) -> Period: ... +#: Type alias for a period-like object. +PeriodLike: TypeAlias = Union[Period, PeriodStr, PeriodInt] + + # Populations #: Type alias for a population's holders. HolderByVariable: TypeAlias = MutableMapping["VariableName", Holder[_N]] -# TODO(Mauko Quiroga-Alvarado): I'm not sure if this type alias is correct. -# https://openfisca.org/doc/coding-the-legislation/50_entities.html -Members: TypeAlias = Iterable["SinglePopulation"] - class MemoryUsageByVariable(TypedDict, total=False): by_variable: dict[VariableName, MemoryUsage] @@ -448,6 +445,11 @@ def members_entity_id(self, /) -> StrArray: ... def nb_persons(self, /, __role: None | Role = ...) -> int: ... +# TODO(Mauko Quiroga-Alvarado): I'm not sure if this type alias is correct. +# https://openfisca.org/doc/coding-the-legislation/50_entities.html +Members: TypeAlias = Iterable[SinglePopulation] + + # Simulations @@ -507,9 +509,6 @@ def instantiate_entities(self, /) -> dict[str, CorePopulation]: ... #: A type representing a mapping of serialized traces. SerializedNodeMap: TypeAlias = dict["NodeKey", "SerializedTraceMap"] -#: A stack of simple traces. -SimpleStack: TypeAlias = list["SimpleTraceMap"] - #: Key of a trace. NodeKey = NewType("NodeKey", str) @@ -587,6 +586,10 @@ def formula_time(self, /) -> Time: ... def append_child(self, __node: TraceNode, /) -> None: ... +#: A stack of simple traces. +SimpleStack: TypeAlias = list[SimpleTraceMap] + + # Variables #: For example "salary".