Skip to content

Commit 83e383f

Browse files
Move mypy config to pyproject.toml , update action file for mypy step & file versions (#53)
* Move mypy config to pyproject.toml * Remove mypy config file flag from action step * Update config file and action file version * Cosmetic change * Update README.md * Temp fix test * add python version * ddrop explicit pointing to toml * add init files so mypy finds what's needed * try mypy * fix intentional mypy error Co-authored-by: Timothy Chklovski <[email protected]>
1 parent 92c55d2 commit 83e383f

File tree

7 files changed

+27
-22
lines changed

7 files changed

+27
-22
lines changed

.github/workflows/pm-gh-actions.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright (C) 2021 Prediction Machine Advisers, LLC
33
# This file is available under MIT license
44
# based on https://github.com/predictionmachine/pm-github-actions/blob/main/.github/workflows/pm-gh-actions.yml
5-
# pm-version 0.3.8
5+
# pm-version 0.3.9
66
############################################################################################
77

88
name: PM CI workflow
@@ -161,6 +161,7 @@ jobs:
161161
flake8_args: '--config=setup.cfg'
162162
reporter: github-pr-review
163163
fail_on_error: true
164+
164165
interrogate:
165166
name: 'Docstrings coverage check (interrogate)'
166167
runs-on: ubuntu-latest
@@ -238,11 +239,12 @@ jobs:
238239
if [ requirements.txt ]; then pip install -r requirements.txt; fi
239240
if [ requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
240241
- name: mypy type check
241-
uses: tsuyoshicho/action-mypy@v3.0.1
242+
uses: tsuyoshicho/action-mypy@v3
242243
with:
243244
github_token: '${{ secrets.GITHUB_TOKEN }}'
245+
level: info
244246
reporter: github-pr-review
245-
mypy_flags: '--config-file=setup.cfg'
247+
# mypy_flags: '--config-file=pyproject.toml'
246248
fail_on_error: true
247249

248250
test-and-coverage:

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The expected layout is:
4040
│ └── example.py
4141
├── .codeclimate.yml # Configuration file for codeclimate analysis
4242
├── .pre-commit-config.yaml # pre-commit configuration file, see https://pre-commit.com
43-
├── pyproject.toml # Configuration file for black, interrogate & pytest
43+
├── pyproject.toml # Configuration file for black, interrogate, mypy & pytest
4444
├── requirements-dev.txt # Development requirements file
4545
├── requirements.txt # Requirements file
4646
├── setup.cfg # Configuration file for flake8, mypy
@@ -73,14 +73,14 @@ The expected layout is:
7373
Copy [.pre-commit-config.yaml](.pre-commit-config.yaml) to the root directory of your repo and follow the [installation](https://pre-commit.com/#installation) instructions to run it.
7474

7575
Take the workflow for a spin by making a PR in your repo.
76-
- `black`, `flake8`, and `mypy` configurations are in [setup.cfg](setup.cfg); `interrogate`, and `pytest` are in [pyproject.toml](pyproject.toml); code climate configurations are in [.codeclimate.yml](.codeclimate.yml), update as needed.
77-
- **UPDATE** in [setup.cfg](setup.cfg), in `[mypy]` section, `files = ./tests,./projectname`
76+
- `black` and `flake8` configurations are in [setup.cfg](setup.cfg); `interrogate`, `mypy` and `pytest` are in [pyproject.toml](pyproject.toml); code climate configurations are in [.codeclimate.yml](.codeclimate.yml), update as needed.
77+
- **UPDATE** in [pyproject.toml](pyproject.toml), added `[tool.mypy]` and `[[tool.mypy.overrides]]` section.
7878
- For more config tips see the FAQ below or raise an issue labeled "question".
7979

8080
- - -
8181
### How it works:
8282

83-
- This workflow uses the configuration files for black, flake8, mypy from the [setup.cfg](setup.cfg); interrogate and pytest from [pyproject.toml](pyproject.toml) and for code analysis from [.codeclimate.yml](.codeclimate.yml) respectively.
83+
- This workflow uses the configuration files for black and flake8 from the [setup.cfg](setup.cfg); interrogate, mypy and pytest from [pyproject.toml](pyproject.toml) and for code analysis from [.codeclimate.yml](.codeclimate.yml) respectively.
8484
- This workflow also creates intermediate output files during the CI build, under `output/` folder, mentioned below:
8585
- `output/coverage.xml` - contains the coverage report - generated by coverage.py.
8686
- `output/docstring_report.txt` - contains the docstring report - generated by interrogate.

projectname/__init__.py

Whitespace-only changes.

pyproject.toml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# based on https://github.com/predictionmachine/pm-gh-actions/blob/main/pyproject.toml
2-
# pm-version 0.1.3
2+
# pm-version 0.1.4
33

44
[tool.black]
55
# see https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-format
@@ -21,6 +21,22 @@ quiet = false
2121
color = true
2222
ignore-nested-functions = true
2323

24+
[tool.mypy]
25+
python_version = "3.8"
26+
# see https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml-file
27+
files = ['.']
28+
disallow_untyped_defs = true
29+
no_implicit_optional = true
30+
warn_return_any = true
31+
warn_unused_configs = true
32+
warn_unused_ignores = true
33+
pretty = false
34+
35+
# mypy per-module options:
36+
[[tool.mypy.overrides]]
37+
module = ['numpy', 'pandas.*', 'pyarrow.*', 'pytest.*', 'pytest_mock', 'setuptools']
38+
ignore_missing_imports = true
39+
2440
[tool.pytest.ini_options]
2541
# see https://docs.pytest.org/en/6.2.x/customize.html#pyproject-toml
2642
addopts = "-n2 --strict-markers -vv"

setup.cfg

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pm-version 0.1.4
1+
# pm-version 0.1.5
22
[coverage:run]
33
# https://coverage.readthedocs.io/en/latest/config.html
44
omit = tests/*
@@ -14,16 +14,3 @@ ignore = E731,W503,E501
1414
count = True
1515
statistics = True
1616
max-line-length = 120
17-
18-
[mypy]
19-
# see https://mypy.readthedocs.io/en/stable/config_file.html#config-file-format
20-
files = ./tests,./projectname
21-
disallow_untyped_defs = True
22-
no_implicit_optional = True
23-
warn_return_any = True
24-
warn_unused_configs = True
25-
warn_unused_ignores = True
26-
pretty = True
27-
28-
[mypy-numpy,pandas.*,pyarrow.*,pytest.*,pytest_mock,setuptools]
29-
ignore_missing_imports = True

tests/__init__.py

Whitespace-only changes.

tests/projectname/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)