Skip to content
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

Clearly differentiate between venv and tox setups in CONTRIBUTING.md #16067

Merged
merged 2 commits into from
Sep 8, 2023

Conversation

posita
Copy link
Contributor

@posita posita commented Sep 7, 2023

Documentation changes are visible here. Commit message below.


The blurb on how to use tox existed in the middle of the Running tests section, and was bookended without headings by non-tox workflow material. This more clearly delineates between tox and non-tox workflows for the newcomer.

This also non-invasively allows running arbitrary commands using testenv:dev.

% tox -e dev
# ... works as before
% tox -e dev -- mypy runtests.py
# ... runs dev commands and then runs mypy on runtests.py
dev: commands[2]> mypy runtests.py
Success: no issues found in 1 source file
# ...
% tox -e dev --override testenv:dev.allowlist_externals+=env -- env
# ... runs dev commands and then runs env in dev environment
test_case.py
dev: commands[2]> env
HOME=/home/posita
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF8
TERM=xterm-256color
PATH=/home/posita/dev/3p/mypy/.tox/dev/bin:/home/posita/dev/3p/mypy/venv/bin:...
PYTHONHASHSEED=...
PIP_DISABLE_PIP_VERSION_CHECK=1
PYTHONIOENCODING=utf-8
TOX_ENV_NAME=dev
TOX_WORK_DIR=/home/posita/dev/3p/mypy/.tox
TOX_ENV_DIR=/home/posita/dev/3p/mypy/.tox/dev
VIRTUAL_ENV=/home/posita/dev/3p/mypy/.tox/dev
TOX_PACKAGE=/home/posita/dev/3p/mypy/.tox/.tmp/package/28/mypy-1.7.0+dev.6d19f9ddf110d4ad3af63d472e8d7aaf69e6260c.dirty-0.editable-py3-none-any.whl
# ...

The blurb on how to use `tox` existed in the middle of the [**Running tests** section](/mypy/blob/master/CONTRIBUTING.md#running-tests), and was bookended without headings by non-`tox` workflow material. This more clearly delineates between `tox` and non-`tox` workflows for the newcomer.

This also non-invasively allows running arbitrary commands using `testenv:dev`.

``` sh
% tox -e dev
# ... works as before
% tox -e dev -- mypy runtests.py
# ... runs dev commands and then runs mypy on runtests.py
dev: commands[2]> mypy runtests.py
Success: no issues found in 1 source file
# ...
% tox -e dev --override testenv:dev.allowlist_externals+=env -- env
# ... runs dev commands and then runs env in dev environment
test_case.py
dev: commands[2]> env
HOME=/home/posita
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF8
TERM=xterm-256color
PATH=/home/posita/dev/3p/mypy/.tox/dev/bin:/home/posita/dev/3p/mypy/venv/bin:...
PYTHONHASHSEED=...
PIP_DISABLE_PIP_VERSION_CHECK=1
PYTHONIOENCODING=utf-8
TOX_ENV_NAME=dev
TOX_WORK_DIR=/home/posita/dev/3p/mypy/.tox
TOX_ENV_DIR=/home/posita/dev/3p/mypy/.tox/dev
VIRTUAL_ENV=/home/posita/dev/3p/mypy/.tox/dev
TOX_PACKAGE=/home/posita/dev/3p/mypy/.tox/.tmp/package/28/mypy-1.7.0+dev.6d19f9ddf110d4ad3af63d472e8d7aaf69e6260c.dirty-0.editable-py3-none-any.whl
# ...
```
@posita
Copy link
Contributor Author

posita commented Sep 7, 2023

The failing check in this PR also seems present on the parent commit in master.

@AlexWaygood
Copy link
Member

@github-actions

This comment has been minimized.

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thank you, one small comment!

CONTRIBUTING.md Outdated
tox -e dev --override testenv:dev.allowlist_externals+=env -- env # inspect the environment
```

If you don't already have `tox` installed, you can use a virtual environment.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we don't need this last bit, since it's covered above

```

If you don't already have `tox` installed, you can use a virtual environment as
described above to install `tox` via `pip` (e.g., ``python3 -m pip install tox``).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hauntsaninja, please let me know if this addresses your #16067 (comment), or you think this should be even shorter or eliminated altogether.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

Diff from mypy_primer, showing the effect of this PR on open source code:

vision (https://github.com/pytorch/vision): typechecking got 1.23x slower (43.3s -> 53.3s)
(Performance measurements are based on a single noisy sample)

@hauntsaninja
Copy link
Collaborator

Thank you!

@hauntsaninja hauntsaninja merged commit 4941983 into python:master Sep 8, 2023
18 of 19 checks passed
@posita posita deleted the posita/0/tweak-contributing-docs branch September 8, 2023 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants