From 39fc9a632cbc2d02fcfd73cb8a26e4a13fe0ca18 Mon Sep 17 00:00:00 2001 From: Mauko Quiroga Date: Wed, 16 Oct 2024 15:53:06 +0200 Subject: [PATCH 1/3] build: add spell check (#305) --- .github/workflows/validate.yaml | 3 +++ Makefile | 11 ++++++++--- pyproject.toml | 3 +++ requirements.txt | 1 + source/coding-the-legislation/20_input_variables.md | 4 ++-- .../40_legislation_evolutions.md | 2 +- .../bootstrapping_a_new_country_package.md | 2 +- .../coding-the-legislation/legislation_parameters.md | 12 ++++++------ source/conf.py | 4 ++-- source/installation/access-countrys-source-code.md | 2 +- source/openfisca-python-api/openfisca_serve.rst | 2 +- 11 files changed, 29 insertions(+), 17 deletions(-) create mode 100644 pyproject.toml diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 0e33d4a2..7f0be3f5 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -45,3 +45,6 @@ jobs: - name: Lint Markdown files run: make lint + + - name: Spell check + run: make spellcheck diff --git a/Makefile b/Makefile index a28637d6..1d246447 100644 --- a/Makefile +++ b/Makefile @@ -16,16 +16,21 @@ install: test: @${MAKE} lint + @${MAKE} spellcheck @${MAKE} test-build -test-build: - @${MAKE} dummy SPHINXOPTS="--quiet --fail-on-warning" - lint: # requires Node and NPM to be installed @npx --yes markdownlint-cli "**/*.md" +spellcheck: # check for spelling errors + @codespell + +test-build: + @${MAKE} dummy SPHINXOPTS="--quiet --fail-on-warning" + format: # requires Node and NPM to be installed @npx --yes markdownlint-cli --fix "**/*.md" + @codespell --write-changes # Serve the documentation in dev mode. dev: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..74191402 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[tool.codespell] +ignore-words-list = [ "Calculs", "moteur", "ressource", "ALS" ] +skip = "*.js,./build" diff --git a/requirements.txt b/requirements.txt index b9a917a6..3e8f7450 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ --editable git+https://github.com/openfisca/openfisca-core.git@master#egg=OpenFisca-Core[dev] +codespell==2.3.0 guzzle_sphinx_theme==0.7.11 myst-parser==3.0.1 sphinx-autobuild==2024.4.16 diff --git a/source/coding-the-legislation/20_input_variables.md b/source/coding-the-legislation/20_input_variables.md index d5430f91..e18ff734 100644 --- a/source/coding-the-legislation/20_input_variables.md +++ b/source/coding-the-legislation/20_input_variables.md @@ -113,7 +113,7 @@ class housing_tax(Variable): def formula(household, period, legislation): accommodation_size = household('accomodation_size', period) housing_occupancy_status = household('housing_occupancy_status', period) - HousingOccupancyStatus = housing_occupancy_status.possible_values # "Import" the enum type. Careful: do not use python imports accross variables files: comparisons would not work! + HousingOccupancyStatus = housing_occupancy_status.possible_values # "Import" the enum type. Careful: do not use python imports across variables files: comparisons would not work! tenant = (housing_occupancy_status == HousingOccupancyStatus.tenant) owner = (housing_occupancy_status == HousingOccupancyStatus.owner) @@ -124,7 +124,7 @@ class housing_tax(Variable): You can now test the formula in a YAML test: ```yaml -- name: Household with free lodger status living in a 100 sq.meters accomodation +- name: Household with free lodger status living in a 100 sq.meters accommodation period: 2017 input: accomodation_size: diff --git a/source/coding-the-legislation/40_legislation_evolutions.md b/source/coding-the-legislation/40_legislation_evolutions.md index 5ff8cc05..024e173e 100644 --- a/source/coding-the-legislation/40_legislation_evolutions.md +++ b/source/coding-the-legislation/40_legislation_evolutions.md @@ -56,7 +56,7 @@ After this change, in a formula: ## Formula evolution -Some fiscal or benefit mechanism significantly evolve over time and call for a change in the formula that computes them. In this case, a simple parameter adjustement is not enough. +Some fiscal or benefit mechanism significantly evolve over time and call for a change in the formula that computes them. In this case, a simple parameter adjustment is not enough. For instance, let's assume that from the 1st of Jan. 2017, the `flat_tax_on_salary` is not applied anymore on the first `1000` earned by a person. diff --git a/source/coding-the-legislation/bootstrapping_a_new_country_package.md b/source/coding-the-legislation/bootstrapping_a_new_country_package.md index 0e15314c..92f1be6e 100644 --- a/source/coding-the-legislation/bootstrapping_a_new_country_package.md +++ b/source/coding-the-legislation/bootstrapping_a_new_country_package.md @@ -1,4 +1,4 @@ -# Bootstraping a new country package +# Bootstrapping a new country package If you want to use OpenFisca to run simulations about your own country's legislation, our [country package template](https://github.com/openfisca/country-template/) will provide you all the instructions and boilerplate code you need to quickly get something working. diff --git a/source/coding-the-legislation/legislation_parameters.md b/source/coding-the-legislation/legislation_parameters.md index 3d63f487..41b6668e 100644 --- a/source/coding-the-legislation/legislation_parameters.md +++ b/source/coding-the-legislation/legislation_parameters.md @@ -166,7 +166,7 @@ Sometimes, the value of a parameter depends on a variable (e.g. a housing benefi To be more specific, let's assume that: -* Households who rent their accomodation can get a `housing_benefit` +* Households who rent their accommodation can get a `housing_benefit` * The amount of this benefit depends on which `zone` the household lives in. The `zone` can take only three values: `zone_1`, `zone_2` or `zone_3`. * The amount also depends on the composition of the household. @@ -223,7 +223,7 @@ zone_3: value: 50 ``` -Then the formula calculting `housing_benefit` can be implemented with: +Then the formula calculating `housing_benefit` can be implemented with: ```py def formula(household, period, parameters): @@ -240,15 +240,15 @@ def formula(household, period, parameters): If there are many households in your simulation, this parameter will be **vectorial**: it may have a different value for each household of your entity. -To be able to use this notation, all the children node of the parameter node `housing_benefit` must be **homogenous**. In the previous example, `housing_benefit.zone_1`, `housing_benefit.zone_2`, `housing_benefit.zone_3` are homogenous, as they have the same subnodes. +To be able to use this notation, all the children node of the parameter node `housing_benefit` must be **homogeneous**. In the previous example, `housing_benefit.zone_1`, `housing_benefit.zone_2`, `housing_benefit.zone_3` are homogeneous, as they have the same subnodes. -However, let's imagine that `housing_benefit.yaml` had another subnode named `coeff_furnished`, which described a coefficient to apply to the benefit is the accomodation is rented furnished: +However, let's imagine that `housing_benefit.yaml` had another subnode named `coeff_furnished`, which described a coefficient to apply to the benefit is the accommodation is rented furnished: `housing_benefit.yaml` content: ```yaml coeff_furnished: - description: "Coefficient to apply if the accomodation is rented furnished" + description: "Coefficient to apply if the accommodation is rented furnished" values: 2015-01-01: value: 0.75 @@ -269,7 +269,7 @@ To solve this issue, the good practice would be to create an intermediate node ` ```yaml coeff_furnished: - description: "Coefficient to apply if the accomodation is rented furnished" + description: "Coefficient to apply if the accommodation is rented furnished" values: 2015-01-01: value: 0.75 diff --git a/source/conf.py b/source/conf.py index 03e243ce..d114c848 100644 --- a/source/conf.py +++ b/source/conf.py @@ -59,10 +59,10 @@ github_doc_root = 'https://github.com/openfisca/openfisca-doc/tree/main/' -# 'config-cache' supresses: Warning cannot cache unpickable configuration value: 'recommonmark_config' (because it contains a function, class, or module object) +# 'config-cache' suppresses: Warning cannot cache unpickable configuration value: 'recommonmark_config' (because it contains a function, class, or module object) suppress_warnings = ['image.nonlocal_uri','config.cache'] -# Supresses warning "more than one target found for cross-reference" affecting: +# Suppresses warning "more than one target found for cross-reference" affecting: # - openfisca_core.periods.Instant # - openfisca_core.simulations.simulation_builder.SimulationBuilder -> TaxBenefitSystem autodoc_default_options = { diff --git a/source/installation/access-countrys-source-code.md b/source/installation/access-countrys-source-code.md index 021c4059..45711cfd 100644 --- a/source/installation/access-countrys-source-code.md +++ b/source/installation/access-countrys-source-code.md @@ -14,7 +14,7 @@ The `OpenFisca-Country-Template` installation instructions are in its `README` [ Generally when making changes to legislation, there is a need to test the changes with a situation that works with the country's tax and benefit system. -Sometimes, these situations can be quite complicated to model. Instead of rewriting them everytime, they can be packaged in different formats: +Sometimes, these situations can be quite complicated to model. Instead of rewriting them every time, they can be packaged in different formats: * As [YAML tests](./../coding-the-legislation/writing_yaml_tests.md) when the expected output result should be registered. * As [JSON requests](./../openfisca-web-api/input-output-data.md#describing-the-situation) when the output isn't being tested. Refer to [these examples](https://github.com/openfisca/country-template/tree/main/openfisca_country_template/situation_examples) in the `OpenFisca-Country-Template` repository. These can be adapted as requests to be sent to the OpenFisca web API. diff --git a/source/openfisca-python-api/openfisca_serve.rst b/source/openfisca-python-api/openfisca_serve.rst index 9bed974a..3d221d50 100644 --- a/source/openfisca-python-api/openfisca_serve.rst +++ b/source/openfisca-python-api/openfisca_serve.rst @@ -69,7 +69,7 @@ You can setup ``openfisca serve`` using a configuration file. Be careful as para Using gunicorn directly ^^^^^^^^^^^^^^^^^^^^^^^ -If for any reason you nedd to run ``gunicorn`` directly, you can. See this example of ``gunicorn`` application: +If for any reason you need to run ``gunicorn`` directly, you can. See this example of ``gunicorn`` application: **app.py:** From 78ec3e8e529f2ac35ffe6df6e2e47d354f2deab7 Mon Sep 17 00:00:00 2001 From: Mauko Quiroga Date: Wed, 16 Oct 2024 16:59:43 +0200 Subject: [PATCH 2/3] ci: move spell check to build --- .github/workflows/build.yaml | 3 +++ .github/workflows/validate.yaml | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 80c8ac66..90dd6113 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -26,6 +26,9 @@ jobs: - name: Install dependencies run: make install + - name: Spell check + run: make spellcheck + - name: Check syntax run: make test-build diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 7f0be3f5..0e33d4a2 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -45,6 +45,3 @@ jobs: - name: Lint Markdown files run: make lint - - - name: Spell check - run: make spellcheck From c88f5af85643a081cf374196f7d6a0785c60f0b0 Mon Sep 17 00:00:00 2001 From: Mauko Quiroga Date: Wed, 16 Oct 2024 17:02:25 +0200 Subject: [PATCH 3/3] ci: ignore spell checks to core --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 74191402..6c85f2ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [tool.codespell] ignore-words-list = [ "Calculs", "moteur", "ressource", "ALS" ] -skip = "*.js,./build" +skip = "*.js,./build,./src/openfisca-core"