Skip to content

Commit 86d5447

Browse files
committed
chore(entities): cleanup (#1254)
1 parent 094058f commit 86d5447

File tree

6 files changed

+4
-51
lines changed

6 files changed

+4
-51
lines changed

openfisca_core/entities/__init__.py

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,4 @@
1-
"""Provide a way of representing the entities of a rule system.
2-
3-
Each rule system is comprised by legislation and regulations to be applied upon
4-
"someone". In legal and economical terms, "someone" is referred to as people:
5-
individuals, families, tax households, companies, and so on.
6-
7-
People can be either human or non-human, that is a legal entity, also referred
8-
to as a legal person. Human or non-human, a person is an atomic element of a
9-
rule system: for example, in most legislations, a salary is invariably owed
10-
to an individual, and payroll taxes by a company, as a juridical person. In
11-
OpenFisca, that atomic element is represented as an ``Entity``.
12-
13-
In other cases, legal and regulatory rules are defined for groups or clusters
14-
of people: for example, income tax is usually due by a tax household, that is
15-
a group of individuals. There may also be fiduciary entities where the members,
16-
legal entities, are collectively liable for a property tax. In OpenFisca, those
17-
cluster elements are represented as a ``GroupEntity``.
18-
19-
In the latter case, the atomic members of a given group may have a different
20-
``Role`` in the context of a specific rule: for example, income tax
21-
is due, in some legislations, by a tax household, where we find different
22-
roles as the declarant, the spouse, the children, and so on…
23-
24-
What's important is that each rule, or in OpenFisca, a ``Variable``
25-
is defined either for an ``.Entity`` or for a ``GroupEntity``,
26-
and in the latter case, the way the rule is going to be applied depends
27-
on the attributes and roles of the members of the group.
28-
29-
Finally, there is a distinction to be made between the "abstract" entities
30-
described in a rule system, for example an individual, as in "any"
31-
individual, and an actual individual, like Mauko, Andrea, Mehdi, Seiko,
32-
or José.
33-
34-
This module provides tools for modelling the former. For the actual
35-
"simulation" or "application" of any given ``Variable`` to a
36-
concrete individual or group of individuals, see ``Population``
37-
and ``GroupPopulation``.
38-
39-
"""
1+
"""Provide a way of representing the entities of a rule system."""
402

413
from . import types
424
from ._core_entity import CoreEntity

openfisca_core/entities/_core_entity.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ def get_variable(
113113
<openfisca_core.entities._core_entity.tax object at ...>
114114
115115
"""
116-
117116
if self._tax_benefit_system is None:
118117
msg = "You must set 'tax_benefit_system' before calling this method."
119118
raise ValueError(
@@ -127,10 +126,6 @@ def check_variable_defined_for_entity(self, variable_name: t.VariableName) -> No
127126
Args:
128127
variable_name: The ``Variable`` to be found.
129128
130-
Returns:
131-
Variable: When the ``Variable`` exists.
132-
None: When the :attr:`_tax_benefit_system` is not set.
133-
134129
Raises:
135130
ValueError: When the ``Variable`` exists but is defined
136131
for another ``Entity``.
@@ -172,7 +167,6 @@ def check_variable_defined_for_entity(self, variable_name: t.VariableName) -> No
172167
>>> this.check_variable_defined_for_entity("tax")
173168
174169
"""
175-
176170
entity: None | t.CoreEntity = None
177171
variable: None | t.Variable = self.get_variable(
178172
variable_name,
@@ -216,7 +210,6 @@ def check_role_validity(role: object) -> None:
216210
ValueError: hey! is not a valid role
217211
218212
"""
219-
220213
if role is not None and not isinstance(role, Role):
221214
msg = f"{role} is not a valid role"
222215
raise ValueError(msg)

openfisca_core/entities/_description.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
@dataclasses.dataclass(frozen=True)
88
class _Description:
9-
"""A ``Role``'s description.
9+
r"""A ``Role``'s description.
1010
1111
Examples:
1212
>>> data = {

openfisca_core/entities/entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class Entity(CoreEntity):
10-
"""An entity (e.g. a person, a household) on which calculations can be run.
10+
r"""An entity (e.g. a person, a household) on which calculations can be run.
1111
1212
Args:
1313
key: A key to identify the ``Entity``.

openfisca_core/entities/group_entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
class GroupEntity(CoreEntity):
15-
"""Represents an entity containing several others with different roles.
15+
r"""Represents an entity containing several others with different roles.
1616
1717
A ``GroupEntity`` represents an ``Entity`` containing several other entities,
1818
with different roles, and on which calculations can be run.

openfisca_core/entities/helpers.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ def build_entity(
7070
TypeError: 'Role' object is not subscriptable
7171
7272
"""
73-
7473
if is_person:
7574
return SingleEntity(key, plural, label, doc)
7675

@@ -151,7 +150,6 @@ def find_role(
151150
Role(first_parent)
152151
153152
"""
154-
155153
for role in roles:
156154
if role.subroles:
157155
for subrole in role.subroles:

0 commit comments

Comments
 (0)