-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Changes from all commits
589ebd1
8c32abe
8bdd581
423643d
88c919a
afb851f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
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] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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} |
There was a problem hiding this comment.
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.