Skip to content

Commit 4d2c29b

Browse files
committed
Move options to pyproject.toml
Most options can be specified in the pyproject.toml file and this have some advantages. The tool can be used more easily from the command-line directly (without using `nox`) without having to remember the options, including having other integrations that call mypy on their own. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 7a6802f commit 4d2c29b

File tree

8 files changed

+48
-3
lines changed

8 files changed

+48
-3
lines changed

cookiecutter/{{cookiecutter.github_repo_name}}/pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ testpaths = ["pytests"]
167167
{%- endif %}
168168
{%- if cookiecutter.type != "api" %}
169169

170+
[tool.mypy]
171+
explicit_package_bases = true
172+
namespace_packages = true
173+
strict = true
174+
170175
[[tool.mypy.overrides]]
171176
module = ["async_solipsism", "async_solipsism.*", "sybil", "sybil.*"]
172177
ignore_missing_imports = true

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ disable = [
149149
"unsubscriptable-object",
150150
]
151151

152+
[tool.mypy]
153+
explicit_package_bases = true
154+
namespace_packages = true
155+
strict = true
156+
152157
[[tool.mypy.overrides]]
153158
module = ["cookiecutter", "cookiecutter.*", "sybil", "sybil.*"]
154159
ignore_missing_imports = true

src/frequenz/repo/config/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@
5252
nox.configure(config)
5353
```
5454
55+
!!! note
56+
57+
When possible, it is recommended to define options in the `pyproject.toml` file
58+
(most tools can do this), so they can be consistently used even if the tool is used
59+
outside of `nox`.
60+
5561
If you need further customization or to define new sessions, you can use the
5662
following modules:
5763
@@ -167,6 +173,18 @@
167173
]
168174
```
169175
176+
## `mypy` (static type checking)
177+
178+
To configure `mypy` you can add the recommended options to the `pyproject.toml` file as
179+
follows:
180+
181+
```toml
182+
[tool.mypy]
183+
explicit_package_bases = true
184+
namespace_packages = true
185+
strict = true
186+
```
187+
170188
## `mkdocs` (generating documentation)
171189
172190
### API reference generation

src/frequenz/repo/config/nox/default.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@
3737
],
3838
mypy=[
3939
"--install-types",
40-
"--namespace-packages",
4140
"--non-interactive",
42-
"--explicit-package-bases",
43-
"--strict",
4441
],
4542
# SDK: pylint "--extension-pkg-whitelist=pydantic"
4643
pytest=[

tests_golden/integration/test_cookiecutter_generation/actor/frequenz-actor-test/pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ testpaths = ["tests", "src"]
139139
asyncio_mode = "auto"
140140
required_plugins = ["pytest-asyncio", "pytest-mock"]
141141

142+
[tool.mypy]
143+
explicit_package_bases = true
144+
namespace_packages = true
145+
strict = true
146+
142147
[[tool.mypy.overrides]]
143148
module = ["async_solipsism", "async_solipsism.*", "sybil", "sybil.*"]
144149
ignore_missing_imports = true

tests_golden/integration/test_cookiecutter_generation/app/frequenz-app-test/pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ testpaths = ["tests", "src"]
138138
asyncio_mode = "auto"
139139
required_plugins = ["pytest-asyncio", "pytest-mock"]
140140

141+
[tool.mypy]
142+
explicit_package_bases = true
143+
namespace_packages = true
144+
strict = true
145+
141146
[[tool.mypy.overrides]]
142147
module = ["async_solipsism", "async_solipsism.*", "sybil", "sybil.*"]
143148
ignore_missing_imports = true

tests_golden/integration/test_cookiecutter_generation/lib/frequenz-test-python/pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ testpaths = ["tests", "src"]
135135
asyncio_mode = "auto"
136136
required_plugins = ["pytest-asyncio", "pytest-mock"]
137137

138+
[tool.mypy]
139+
explicit_package_bases = true
140+
namespace_packages = true
141+
strict = true
142+
138143
[[tool.mypy.overrides]]
139144
module = ["async_solipsism", "async_solipsism.*", "sybil", "sybil.*"]
140145
ignore_missing_imports = true

tests_golden/integration/test_cookiecutter_generation/model/frequenz-model-test/pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ testpaths = ["tests", "src"]
139139
asyncio_mode = "auto"
140140
required_plugins = ["pytest-asyncio", "pytest-mock"]
141141

142+
[tool.mypy]
143+
explicit_package_bases = true
144+
namespace_packages = true
145+
strict = true
146+
142147
[[tool.mypy.overrides]]
143148
module = ["async_solipsism", "async_solipsism.*", "sybil", "sybil.*"]
144149
ignore_missing_imports = true

0 commit comments

Comments
 (0)