Skip to content

PYTHON-2963 Add tox config in preparation for migration from setup.py #1240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 16, 2023
Merged
Changes from 2 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
43 changes: 43 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[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]
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 to typecheck
deps =
mypy
zstandard
certifi; platform_system == "win32" or platform_system == "Darwin"
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