Skip to content

Commit

Permalink
docs: Document strategy for incremental adoption of static typing (me…
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Sep 7, 2022
1 parent d8c5540 commit 49942e8
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions docs/src/_contribute/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ Python:
Flake8 is a python tool that glues together `pycodestyle`, `pyflakes`, `mccabe`, and third-party plugins to check the style and quality of python code,
and `wemake-python-styleguide` is a plugin for Flake8 that offers an extensive set of opinionated rules that encourage clean and correct code.

[MyPy is being adopted incrementally by this codebase](https://github.com/meltano/meltano/issues/6491). If you are adding new code, please use type hints.
To enable type checks for an existing module, _de-glob_ it in the whitelist in `pyproject.toml` and fix any errors.

Javascript:

- [ESLint](https://eslint.org/docs/rules/)
Expand All @@ -33,6 +30,43 @@ Javascript:

You may use `make lint` to automatically lint all your code, or `make show_lint` if you only want to see what needs to change.

### Static typing

[MyPy is being adopted incrementally by this codebase](https://github.com/meltano/meltano/issues/6715). If you are adding new code, please use type hints.

If you are making changes to existing Python modules, you are encouraged to enable type checks. To do so,

- if you are fixing a single `.py` file inside a sub-package, e.g. `meltano.core.plugin.command`, _de-glob_ the sub-package in `pyproject.toml` and enumerate the files you are not touching. This will allow you to run `nox -rs mypy` and catch type errors only in the files you are touching.

```diff
[[tool.mypy.overrides]]
module = [
...
"meltano.core.m5o.*",
- "meltano.core.plugin.*",
+ "meltano.core.plugin.airflow",
+ "meltano.core.plugin.base",
+ # Note that meltano.core.plugin.command is not included here
+ "meltano.core.plugin.config_service",
+ "meltano.core.plugin.dbt.*",
+ "meltano.core.plugin.error",
+ "meltano.core.plugin.factory",
+ "meltano.core.plugin.file",
+ "meltano.core.plugin.meltano_file",
+ "meltano.core.plugin.model.*",
+ "meltano.core.plugin.project_plugin",
+ "meltano.core.plugin.requirements",
+ "meltano.core.plugin.settings_service",
+ "meltano.core.plugin.singer.*",
+ "meltano.core.plugin.superset",
+ "meltano.core.plugin.utility",
"meltano.core.runner.*",
...
]
```

- if you are fixing an entire sub-package, simply remove it from the ignore list.

### Mantra

> A contributor should know the exact line-of-code to make a change based on convention
Expand Down

0 comments on commit 49942e8

Please sign in to comment.