Skip to content

Commit

Permalink
PYTHON-2963 Add tox config in preparation for migration from setup.py (
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahStapp committed Jun 16, 2023
1 parent 37202c0 commit 374250d
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 11 deletions.
19 changes: 8 additions & 11 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Install dependencies
run: |
pip install tox
- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.7.0
with:
mongodb-version: 4.4
- name: Run tests
run: |
python setup.py test
tox -e test
mypytest:
name: Run mypy
Expand All @@ -58,22 +61,16 @@ jobs:
cache-dependency-path: 'setup.py'
- name: Install dependencies
run: |
python -m pip install -U pip mypy==1.2
pip install -e ".[zstd, encryption, ocsp]"
pip install tox
- name: Run mypy
run: |
mypy --install-types --non-interactive bson gridfs tools pymongo
mypy --install-types --non-interactive --disable-error-code var-annotated --disable-error-code attr-defined --disable-error-code union-attr --disable-error-code assignment --disable-error-code no-redef --disable-error-code index --allow-redefinition --allow-untyped-globals --exclude "test/mypy_fails/*.*" test
python -m pip install -U typing_extensions
mypy --install-types --non-interactive test/test_typing.py test/test_typing_strict.py
tox -e typecheck-mypy
- name: Run pyright
run: |
python -m pip install -U pip pyright==1.1.290
pyright test/test_typing.py test/test_typing_strict.py
tox -e typecheck-pyright
- name: Run pyright strict
run: |
echo '{"strict": ["tests/test_typing_strict.py"]}' >> pyrightconfig.json
pyright test/test_typing_strict.py
tox -e typecheck-pyright-strict
linkcheck:
name: Check Links
Expand Down
77 changes: 77 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
[tox]
requires =
tox>=4
envlist =
# Test using the system Python.
test,
# Run pre-commit on all files.
lint,
# Run pre-commit on all files, including stages that require manual fixes.
lint-manual,
# Typecheck all files.
typecheck

[testenv:test]
description = run unit tests
commands =
python --version
python setup.py test {posargs}

[testenv:lint]
description = run pre-commit
deps =
pre-commit
commands =
pre-commit run --all-files

[testenv:lint-manual]
description = run all pre-commit stages, including those that require manual fixes
deps =
pre-commit
commands =
pre-commit run --all-files --hook-stage manual

[testenv:typecheck-mypy]
description = run mypy and pyright to typecheck
deps =
mypy
zstandard
certifi; platform_system == "win32" or platform_system == "Darwin"
typing_extensions
pyopenssl>=17.2.0
requests<3.0.0
service_identity>=18.1.0
pymongocrypt>=1.6.0,<2.0.0
pymongo-auth-aws<2.0.0
commands =
mypy --install-types --non-interactive bson gridfs tools pymongo
mypy --install-types --non-interactive --disable-error-code var-annotated --disable-error-code attr-defined --disable-error-code union-attr --disable-error-code assignment --disable-error-code no-redef --disable-error-code index --allow-redefinition --allow-untyped-globals --exclude "test/mypy_fails/*.*" test
mypy --install-types --non-interactive test/test_typing.py test/test_typing_strict.py

[testenv:typecheck-pyright]
description = run pyright to typecheck
deps =
mypy
pyright==1.1.290
commands =
pyright test/test_typing.py test/test_typing_strict.py

[testenv:typecheck-pyright-strict]
description = run pyright with strict mode to typecheck
deps =
{[testenv:typecheck-pyright]deps}
allowlist_externals=echo
commands =
echo '{"strict": ["tests/test_typing_strict.py"]}' > pyrightconfig.json
pyright test/test_typing_strict.py

[testenv:typecheck]
description = run mypy and pyright to typecheck
deps =
{[testenv:typecheck-mypy]deps}
{[testenv:typecheck-pyright]deps}
allowlist_externals=echo
commands =
{[testenv:typecheck-mypy]commands}
{[testenv:typecheck-pyright]commands}
{[testenv:typecheck-pyright-strict]commands}

0 comments on commit 374250d

Please sign in to comment.