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

Update Tox settings for easier use & better performance #193

Merged
merged 7 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
38 changes: 17 additions & 21 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ this case, the [Apache Software License v2](LICENSE).

To contribute to Sygnal, ensure you have Python 3.7 or newer and then run:

```
```bash
python3 -m venv venv
./venv/bin/pip install -e .
./venv/bin/pip install -U black flake8 isort mypy mypy-zope tox
```

This creates an isolated virtual Python environment ("virtualenv") just for
use with Sygnal, then installs Sygnal along with its dependencies, and lastly
installs a handful of useful tools
installs a handful of useful tools

Finally, activate the virtualenv by running:

```
```bash
source ./venv/bin/activate
```

Expand All @@ -37,7 +37,7 @@ the virtualenv.

To make sure everything is working as expected, run the unit tests:

```
```bash
tox -e py
```

Expand Down Expand Up @@ -88,27 +88,23 @@ Sygnal follows the [Synapse code style].
Many of the conventions are enforced by scripts which are run as part of the
[continuous integration system](#continuous-integration-and-testing).

To help check and fix adherence to the code style, you can run `scripts-dev/lint.sh`
locally. You'll need Python 3.7 or later, and to install a number of tools:

```
# Install the dependencies
pip install -U black flake8 isort mypy mypy-zope

# Run the linter script
./scripts-dev/lint.sh
```
To help check and fix adherence to the code style, you can run `tox`
locally. You'll need Python 3.7 or later, and a virtual environment configured and
active:

**Note that the script does not just test/check, but also reformats code, so you
may wish to ensure any new code is committed first**.
```bash
# Activate the virtual environment
source ./venv/bin/activate

By default, this script checks all files and can take some time; if you alter
only certain files, you might wish to specify paths as arguments to reduce the
run-time:
# Run the code style check
tox -e check_codestyle

# Run the types check
tox -e check_types
```
./scripts-dev/lint.sh path/to/file1.py path/to/file2.py path/to/folder
```

These commands will consider the paths and files related to the project (i.e.
everything in `sygnal/` and in `tests/` as well as the `setup.py` file).

Before pushing new changes, ensure they don't produce linting errors. Commit any
files that were corrected.
Expand Down
1 change: 1 addition & 0 deletions changelog.d/193.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update CONTRIBUTING.md to specify how to run code style and type checks with Tox, and add formatting to code block samples.
1 change: 1 addition & 0 deletions changelog.d/193.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated Tox to run in the installed version of Python (instead of specifying Python 3.7) and to consider specific paths and folders while running checks, instead of the whole repository (potentially including unwanted files and folders, e.g. the virtual environment).
26 changes: 0 additions & 26 deletions scripts-dev/lint.sh

This file was deleted.

10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py37, check_codestyle, check_types
envlist = py, check_codestyle, check_types

[testenv]

Expand All @@ -22,13 +22,13 @@ deps =
black==19.10b0
isort~=5.0
commands =
flake8 .
black --check --diff .
isort --check-only --diff .
flake8 sygnal/ tests/ setup.py
black --check --diff sygnal/ tests/ setup.py
isort --check-only --diff sygnal/ tests/ setup.py

[testenv:check_types]
deps =
mypy==0.780
mypy-zope==0.2.7
commands =
mypy .
mypy sygnal/ tests/ setup.py