diff --git a/CHANGELOG.md b/CHANGELOG.md index 43d8d9d6b7..e746ad57a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,34 @@ # Changelog +# 44.0.0 [#1015](https://github.com/openfisca/openfisca-core/pull/1015) + +#### Technical changes + +- Add `pyproject.toml` to the repository. +- Add `poetry` to manage dependencies. +- Add `tox` to manage isolated tests. + +#### Deprecations + +- `openfisca_core.commons.Dummy` => `openfisca_core.commons.empty_clone` +- `openfisca_core.errors.ParameterNotFound` => `openfisca_core.errors.ParameterNotFoundError` +- `openfisca_core.errors.VariableNameConflict` => `openfisca_core.errors.VariableNameConflictError` +- `openfisca_core.errors.VariableNotFound` => `openfisca_core.errors.VariableNotFoundError` +- `openfisca_core.formula_helpers.py` => `openfisca_core.commons` +- `openfisca_core.memory_config.py` => `openfisca_core.experimental` +- `openfisca_core.parameters.Bracket` => `openfisca_core.errors.ParameterScaleBracket` +- `openfisca_core.parameters.ParameterNotFound` => `openfisca_core.errors.ParameterNotFoundError` +- `openfisca_core.parameters.ParameterParsingError` => `openfisca_core.errors.ParameterParsingError` +- `openfisca_core.parameters.Scale` => `openfisca_core.errors.ParameterScale` +- `openfisca_core.rates` => `openfisca_core.commons` +- `openfisca_core.simulation_builder` => `openfisca_core.simulations` +- `openfisca_core.simulations.CycleError` => `openfisca_core.errors.CycleError` +- `openfisca_core.simulations.NaNCreationError` => `openfisca_core.errors.NaNCreationError` +- `openfisca_core.simulations.SpiralError` => `openfisca_core.errors.SpiralError` +- `openfisca_core.taxbenefitsystems.VariableNameConflict` => `openfisca_core.errors.VariableNameConflictError` +- `openfisca_core.taxbenefitsystems.VariableNotFound` => `openfisca_core.errors.VariableNotFoundError` +- `openfisca_core.taxscales.EmptyArgumentError` => `openfisca_core.errors.EmptyArgumentError` + ### 43.2.2 [#1280](https://github.com/openfisca/openfisca-core/pull/1280) #### Documentation diff --git a/openfisca_core/commons/__init__.py b/openfisca_core/commons/__init__.py index 550088141e..d7bdff5f71 100644 --- a/openfisca_core/commons/__init__.py +++ b/openfisca_core/commons/__init__.py @@ -1,13 +1,11 @@ """Common tools for contributors and users.""" from . import types -from .dummy import Dummy from .formulas import apply_thresholds, concat, switch from .misc import empty_clone, eval_expression, stringify_array from .rates import average_rate, marginal_rate __all__ = [ - "Dummy", "apply_thresholds", "average_rate", "concat", diff --git a/openfisca_core/commons/dummy.py b/openfisca_core/commons/dummy.py deleted file mode 100644 index b9fc31d89f..0000000000 --- a/openfisca_core/commons/dummy.py +++ /dev/null @@ -1,25 +0,0 @@ -import warnings - - -class Dummy: - """A class that did nothing. - - Examples: - >>> Dummy() - None: - message = [ - "The 'Dummy' class has been deprecated since version 34.7.0,", - "and will be removed in the future.", - ] - warnings.warn(" ".join(message), DeprecationWarning, stacklevel=2) - - -__all__ = ["Dummy"] diff --git a/openfisca_core/commons/tests/test_dummy.py b/openfisca_core/commons/tests/test_dummy.py deleted file mode 100644 index 4dd13eabab..0000000000 --- a/openfisca_core/commons/tests/test_dummy.py +++ /dev/null @@ -1,9 +0,0 @@ -import pytest - -from openfisca_core.commons import Dummy - - -def test_dummy_deprecation() -> None: - """Dummy throws a deprecation warning when instantiated.""" - with pytest.warns(DeprecationWarning): - assert Dummy() diff --git a/openfisca_core/errors/__init__.py b/openfisca_core/errors/__init__.py index 2c4d438116..afe88980d9 100644 --- a/openfisca_core/errors/__init__.py +++ b/openfisca_core/errors/__init__.py @@ -24,35 +24,23 @@ from .cycle_error import CycleError from .empty_argument_error import EmptyArgumentError from .nan_creation_error import NaNCreationError -from .parameter_not_found_error import ( - ParameterNotFoundError, - ParameterNotFoundError as ParameterNotFound, -) +from .parameter_not_found_error import ParameterNotFoundError from .parameter_parsing_error import ParameterParsingError from .period_mismatch_error import PeriodMismatchError from .situation_parsing_error import SituationParsingError from .spiral_error import SpiralError -from .variable_name_config_error import ( - VariableNameConflictError, - VariableNameConflictError as VariableNameConflict, -) -from .variable_not_found_error import ( - VariableNotFoundError, - VariableNotFoundError as VariableNotFound, -) +from .variable_name_config_error import VariableNameConflictError +from .variable_not_found_error import VariableNotFoundError __all__ = [ "CycleError", "EmptyArgumentError", "NaNCreationError", - "ParameterNotFound", # Deprecated alias for "ParameterNotFoundError "ParameterNotFoundError", "ParameterParsingError", "PeriodMismatchError", "SituationParsingError", "SpiralError", - "VariableNameConflict", # Deprecated alias for "VariableNameConflictError" "VariableNameConflictError", - "VariableNotFound", # Deprecated alias for "VariableNotFoundError" "VariableNotFoundError", ] diff --git a/openfisca_core/formula_helpers.py b/openfisca_core/formula_helpers.py deleted file mode 100644 index e0c755348e..0000000000 --- a/openfisca_core/formula_helpers.py +++ /dev/null @@ -1,9 +0,0 @@ -# The formula_helpers module has been deprecated since X.X.X, -# and will be removed in the future. -# -# The helpers have been moved to the commons module. -# -# The following are transitional imports to ensure non-breaking changes. -# Could be deprecated in the next major release. - -from openfisca_core.commons import apply_thresholds, concat, switch # noqa: F401 diff --git a/openfisca_core/memory_config.py b/openfisca_core/memory_config.py deleted file mode 100644 index 18c4cebcdc..0000000000 --- a/openfisca_core/memory_config.py +++ /dev/null @@ -1,9 +0,0 @@ -# The memory config module has been deprecated since X.X.X, -# and will be removed in the future. -# -# Module's contents have been moved to the experimental module. -# -# The following are transitional imports to ensure non-breaking changes. -# Could be deprecated in the next major release. - -from openfisca_core.experimental import MemoryConfig # noqa: F401 diff --git a/openfisca_core/rates.py b/openfisca_core/rates.py deleted file mode 100644 index 9dfbbefcf0..0000000000 --- a/openfisca_core/rates.py +++ /dev/null @@ -1,9 +0,0 @@ -# The formula_helpers module has been deprecated since X.X.X, -# and will be removed in the future. -# -# The helpers have been moved to the commons module. -# -# The following are transitional imports to ensure non-breaking changes. -# Could be deprecated in the next major release. - -from openfisca_core.commons import average_rate, marginal_rate # noqa: F401 diff --git a/openfisca_core/simulation_builder.py b/openfisca_core/simulation_builder.py deleted file mode 100644 index 189bba3bcb..0000000000 --- a/openfisca_core/simulation_builder.py +++ /dev/null @@ -1,16 +0,0 @@ -# The simulation builder module has been deprecated since X.X.X, -# and will be removed in the future. -# -# Module's contents have been moved to the simulation module. -# -# The following are transitional imports to ensure non-breaking changes. -# Could be deprecated in the next major release. - -from openfisca_core.simulations import ( # noqa: F401 - Simulation, - SimulationBuilder, - calculate_output_add, - calculate_output_divide, - check_type, - transform_to_strict_syntax, -) diff --git a/requirements/common b/requirements/common new file mode 100644 index 0000000000..5599db953a --- /dev/null +++ b/requirements/common @@ -0,0 +1,8 @@ +# These are dependencies to build the library, so we always want the latest +# versions. + +# For managing dependencies. +pip + +# For packaging the package. +setuptools diff --git a/requirements/compatibility b/requirements/compatibility new file mode 100644 index 0000000000..3dcf417557 --- /dev/null +++ b/requirements/compatibility @@ -0,0 +1,6 @@ +# These are constraint versions to ensure the compatibility of distributions. +# +# Normally, we want to add here the pinned lower-bound supported versions of +# dependencies critical to OpenFisca's usability. + +numpy == 1.17 diff --git a/requirements/coverage b/requirements/coverage new file mode 100644 index 0000000000..9dcd97d83d --- /dev/null +++ b/requirements/coverage @@ -0,0 +1,5 @@ +# These are dependencies to upload test coverage statistics, so we always want +# the latest versions. + +# For sending test statistics to the Coveralls third-party service. +coveralls diff --git a/requirements/dev b/requirements/dev new file mode 100644 index 0000000000..5c367e8ae0 --- /dev/null +++ b/requirements/dev @@ -0,0 +1,38 @@ +# Please make sure to pin all dependency versions, in order to avoid unwanted +# functional and integration breaks caused by external code updates. +# +# General Rule +# ============ +# +# * Pin them. +# +# Exceptions +# ========== +# +# * openfisca-country-template should not be constrained (circular dep). +# * openfisca-extension-template should not be constrained (circular dep). + +# For automatic style formatting. +autopep8 == 1.6.0 + +# For style & code checking. +darglint == 1.8.0 +flake8 == 4.0.1 +flake8-bugbear == 21.9.2 +flake8-docstrings == 1.6.0 +flake8-print == 4.0.0 +flake8-rst-docstrings == 0.2.3 +pylint == 2.11.1 + +# For PyTest test coverage integration. +pytest-cov == 3.0.0 + +# For optional duck & static type checking. +mypy == 0.910 + +# For testing: parameters, variables, etc. +openfisca-country-template +openfisca-extension-template + +# Include Web API dependencies for development +-r web-api diff --git a/requirements/install b/requirements/install new file mode 100644 index 0000000000..cd4a27a25a --- /dev/null +++ b/requirements/install @@ -0,0 +1,69 @@ +# Please make sure to cap all dependency versions, in order to avoid unwanted +# functional and integration breaks caused by external code updates. +# +# These dependencies are always installed, so: +# +# * the ranges should be broad, and +# * the number of them kept low. +# +# If a dependency seems redundant, please propose a pull request to remove it. +# +# General Rule +# ============ +# +# * Cap to latest major. +# +# Exceptions +# ========== +# +# * Avoiding a version (document why). +# * Pinning a version (document why). + +# For globbing over dictionaries as if they were filesystems. +# +# We support from 1.3.2 on because it is the first version published +# following the semantic versioning specification. +# +# We do not support 2 yet because of a bug introduced to period parsing in +# OpenFisca's Web API: https://github.com/openfisca/openfisca-core/pull/948 +dpath >= 1.3.2, < 2 + +# For Numpy type-hints. +nptyping >= 1, < 2 + +# For evaluating numerical expressions +# +# We support numexpr >= 2.7.1 because it is the first version compatible with +# Python 3.7. +numexpr >= 2.7.1, < 3 + +# For vectorial support +# +# We support the latest four minors because NumPy is generally a transitive +# dependency that users rely on within the projects where OpenFisca is +# depended on by. +numpy >= 1.17, < 1.21 + +# Memory monitoring for caching. +# +# We support psutil >= 5.4.7 because it is the first version compatible with +# Python 3.7. +psutil >= 5.4.7, < 6 + +# For openfisca test +# +# We support pytest >= 5.4.2 because `openfisca test` relies on the signature of +# `pytest.Item.from_module()` introduced since 5.4.2. +# +# We do not support 6 yet because it requires fixing some tests before. +# See: https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent +pytest >= 5.4.2, < 6 + +# For parameters and tests parsing. +PyYAML >= 5.1, < 6 + +# For sorting formulas by period. +sortedcontainers >= 2, < 3 + +# For typing backports. +typing-extensions >= 3, < 4 diff --git a/requirements/publication b/requirements/publication new file mode 100644 index 0000000000..1711493b6d --- /dev/null +++ b/requirements/publication @@ -0,0 +1,8 @@ +# These are dependencies to publish the library, so we always want the latest +# versions. + +# For publishing on PyPI. +twine + +# For building the package. +build diff --git a/requirements/tracker b/requirements/tracker new file mode 100644 index 0000000000..c0c8ce0599 --- /dev/null +++ b/requirements/tracker @@ -0,0 +1,7 @@ +# Dependencies for tracking are optional, so we always want the latest +# versions. + +# For sending usage statistics to the Matomo third-party service. +# +# We start from the currently supported version forward. +openfisca-tracker >= 0.4.0 diff --git a/requirements/web-api b/requirements/web-api new file mode 100644 index 0000000000..5034026bcd --- /dev/null +++ b/requirements/web-api @@ -0,0 +1,14 @@ +# These are dependencies to serve the Web-API, so we always want to support +# the latest versions. + +# For OpenFisca's Web API. +# +# We start from the currently supported versions forward. +flask >= 1.1.2 +gunicorn >= 20.1.0 + +# For OpenFisca's Web API users requiring CORS. +# +# We start from the currently supported versions forward. +flask-cors >= 3.0.10 +werkzeug >= 1.0.1