Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/[email protected]
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 =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lack of specified Python versions here will cause tox to run using the default system interpreter.

# 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>> should be > IIUC. Otherwise we'd repeatedly append to the same file.

pyright test/test_typing_strict.py

[testenv:typecheck]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this environment, we can call the individual ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intended to replace needing an alias to run all of the typechecks in a single command.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, it is possible then to compose this to use the deps and commands of the other envs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Figured it out, fixed!

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}