Skip to content

Commit

Permalink
Run Mypy checks locally, too (#1177)
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek authored Aug 17, 2023
1 parent 73374ba commit 985ce76
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
26 changes: 14 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,26 @@ jobs:
allow-prereleases: true
cache: pip

- name: Prepare tox & run tests
- name: Prepare tox
run: |
V=${{ matrix.python-version }}
if [[ "$V" = pypy-* ]]; then
V=pypy3
IS_PYPY=1
else
V=py$(echo $V | tr -d .)
IS_PYPY=0
fi
echo IS_PYPY=$IS_PYPY >>$GITHUB_ENV
echo TOX_PYTHON=$V >>$GITHUB_ENV
python -Im pip install tox
python -Im tox run -f $V
- run: python -Im tox run -e mypy
if: ${{ !startsWith(matrix.python-version, 'pypy-') }}
- run: python -Im tox run -e ${{ env.TOX_PYTHON }}-tests
- run: python -Im tox run -e ${{ env.TOX_PYTHON }}-mypy
if: env.IS_PYPY == '0'

- name: Upload coverage data
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -116,10 +122,8 @@ jobs:
python-version: "3.11"
cache: pip

- name: Prepare & run tox
run: |
python -Im pip install tox
python -Im tox run -e docs,changelog
- run: python -Im pip install tox
- run: python -Im tox run -e docs,changelog

pyright:
name: Check types using pyright
Expand All @@ -131,10 +135,8 @@ jobs:
python-version-file: .python-version-default
cache: pip

- name: Prepare & run tox
run: |
python -Im pip install tox
python -Im tox run -e pyright
- run: python -Im pip install tox
- run: python -Im tox run -e pyright

install-dev:
name: Verify dev env
Expand Down
24 changes: 11 additions & 13 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
min_version = 4
env_list =
pre-commit,
py3{7,8,9,10,11,12},
py3{7,8,9,10,11,12}-{tests,mypy},
pypy3,
mypy,
pyright,
docs,
changelog,
Expand All @@ -18,21 +17,27 @@ pass_env = SETUPTOOLS_SCM_PRETEND_VERSION
[testenv]
package = wheel
wheel_build_env = .pkg
extras = tests
commands = pytest {posargs:-n auto}
pass_env =
FORCE_COLOR
NO_COLOR
extras =
tests: tests
deps =
mypy: mypy
commands =
tests: pytest {posargs:-n auto}
mypy: mypy tests/typing_example.py
mypy: mypy src/attrs/__init__.pyi src/attr/__init__.pyi src/attr/_typing_compat.pyi src/attr/_version_info.pyi src/attr/converters.pyi src/attr/exceptions.pyi src/attr/filters.pyi src/attr/setters.pyi src/attr/validators.pyi


[testenv:py3{7,10,11}]
[testenv:py3{7,10,11}-tests]
extras = cov
# Python 3.6+ has a number of compile-time warnings on invalid string escapes.
# PYTHONWARNINGS=d and --no-compile below make them visible during the tox run.
install_command = python -Im pip install --no-compile {opts} {packages}
set_env =
COVERAGE_PROCESS_START={toxinidir}/pyproject.toml
PYTHONWARNINGS=d
install_command = python -Im pip install --no-compile {opts} {packages}
commands_pre = python -c 'import pathlib; pathlib.Path("{env_site_packages_dir}/cov.pth").write_text("import coverage; coverage.process_startup()")'
commands = coverage run -m pytest {posargs:-n auto}

Expand Down Expand Up @@ -89,13 +94,6 @@ skip_install = true
commands = towncrier build --version main --draft


[testenv:mypy]
deps = mypy>=0.991
commands =
mypy src/attrs/__init__.pyi src/attr/__init__.pyi src/attr/_typing_compat.pyi src/attr/_version_info.pyi src/attr/converters.pyi src/attr/exceptions.pyi src/attr/filters.pyi src/attr/setters.pyi src/attr/validators.pyi
mypy tests/typing_example.py


[testenv:pyright]
extras = tests
deps = pyright
Expand Down

0 comments on commit 985ce76

Please sign in to comment.