Skip to content

Commit 1eff11b

Browse files
author
Mauko Quiroga
committed
Add doc to enums module
1 parent e05e859 commit 1eff11b

File tree

1 file changed

+47
-22
lines changed

1 file changed

+47
-22
lines changed
Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,51 @@
1-
# Transitional imports to ensure non-breaking changes.
2-
# Could be deprecated in the next major release.
3-
#
4-
# How imports are being used today:
5-
#
6-
# >>> from openfisca_core.module import symbol
7-
#
8-
# The previous example provokes cyclic dependency problems
9-
# that prevent us from modularizing the different components
10-
# of the library so to make them easier to test and to maintain.
11-
#
12-
# How could them be used after the next major release:
13-
#
14-
# >>> from openfisca_core import module
15-
# >>> module.symbol()
16-
#
17-
# And for classes:
18-
#
19-
# >>> from openfisca_core.module import Symbol
20-
# >>> Symbol()
21-
#
22-
# See: https://www.python.org/dev/peps/pep-0008/#imports
1+
"""Enumerations for variables with a limited set of possible values.
2+
3+
These include:
4+
* Highest academic level: high school, associate degree, bachelor’s
5+
degree, master’s degree, doctorate…
6+
* A household housing occupancy status: owner, tenant, free-lodger,
7+
homeless…
8+
* The main occupation of a person: employee, freelancer, retired, student,
9+
unemployed…
10+
11+
Official Public API:
12+
* :attr:`.ENUM_ARRAY_DTYPE`
13+
* :class:`.EnumArray`
14+
* :class:`.Enum`
15+
16+
Note:
17+
How imports are being used today::
18+
19+
from openfisca_core.indexed_enums import * # Bad
20+
from openfisca_core.indexed_enums.config import ENUM_ARRAY_DTYPE # Bad
21+
from openfisca_core.ndexed_enums.Enum import Enum # Bad
22+
23+
The previous examples provoke cyclic dependency problems, that prevents us
24+
from modularizing the different components of the library, so as to make
25+
them easier to test and to maintain.
26+
27+
How could them be used after the next major release::
28+
29+
from openfisca_core import indexed_enums
30+
from openfisca_core.indexed_enums import Enum
31+
32+
Enum() # Good: import classes as publicly exposed
33+
indexed_enums.ENUM_ARRAY_DTYPE # Good: use attrs as publicly exposed
34+
35+
.. seealso:: `PEP8#Imports`_ and `OpenFisca's Styleguide`_.
36+
37+
.. _PEP8#Imports:
38+
https://www.python.org/dev/peps/pep-0008/#imports
39+
40+
.. _OpenFisca's Styleguide:
41+
https://github.com/openfisca/openfisca-core/blob/master/STYLEGUIDE.md
42+
43+
"""
44+
45+
# Official Public API
2346

2447
from .config import ENUM_ARRAY_DTYPE # noqa: F401
2548
from .enum_array import EnumArray # noqa: F401
2649
from .enum import Enum # noqa: F401
50+
51+
__all__ = ["ENUM_ARRAY_DTYPE", "EnumArray", "Enum"]

0 commit comments

Comments
 (0)