Skip to content

Commit

Permalink
Update tox.ini with all linting commands under lint env
Browse files Browse the repository at this point in the history
Added a new environement that runs all the linting commands at once.
Added a new environement that format source code according the the expected
linting format.
  • Loading branch information
lavigne958 committed Sep 18, 2021
1 parent 23d983f commit 68bb955
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
21 changes: 21 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
Run the test suite using your current python version, in offline mode.
This will use the curently recorded HTTP requests + responses. It does not make any HTTP call, does not require an active internet connection.

**Note:** the CI runs that command, if it fail you won't be able to merge
your changes in GSpread.

```
tox -e py
```
Expand All @@ -48,6 +51,24 @@ You can control vcrpy's [Record Mode](https://vcrpy.readthedocs.io/en/latest/usa
GS_RECORD_MODE=all GS_CREDS_FILENAME=<YOUR_CREDS.json> tox -e py
```

3. Format your code:

Use the following command to format your code. Doing so will ensure
all code respects the same format.

```
tox -e format
```

Then run the linter to validate change, if any.

**Note:** the CI runs that command, if it fail you won't be able to merge
your changes in GSpread.

```
tox -e lint
```

## Render Documentation

The documentation uses [reStructuredText](http://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html#rst-index) markup and is rendered by [Sphinx](http://www.sphinx-doc.org/).
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/lint_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- run: pip install bandit black codespell flake8 isort mypy pytest pyupgrade safety tox
- run: pip install bandit mypy pyupgrade safety tox
- run: bandit --recursive --skip B105,B110,B311,B605,B607 --exclude ./.tox .
if: ${{ matrix.python >= '3.8' }}
- run: black --check .
- run: codespell # --ignore-words-list="" --skip=""
- run: flake8 --ignore=E203 --max-complexity=10 --max-line-length=255
--show-source --statistics .
- run: isort --check-only --profile black .
- run: tox -e lint
- run: tox -e py
- run: mypy --ignore-missing-imports . || true # Need Python >= 3.6
- run: shopt -s globstar && pyupgrade --py3-only **/*.py # --py36-plus
Expand Down
5 changes: 5 additions & 0 deletions lint-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bandit==1.7.0
black==21.7b0
codespell==2.1.0
flake8==3.9.2
isort==5.9.3
16 changes: 16 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,23 @@
envlist = py36,py37,py38,py39
skip_missing_interpreters = true

# Used to run tests, **do not** set GS_CREDS_FILENAME to run off-line tests
[testenv]
passenv = GS_RECORD_MODE GS_CREDS_FILENAME
deps = -r test-requirements.txt
commands = pytest tests/

# Used by the CI to check code format/security
[testenv:lint]
deps = -r lint-requirements.txt
commands = black --check .
codespell --skip=".tox,.git" .
flake8 --ignore=E203 --max-complexity=10 --max-line-length=255 \
--show-source --statistics .
isort --check-only --profile black .

# Used by developers to format code, best advised to be run before commit
[testenv:format]
deps = -r lint-requirements.txt
commands = black .
isort --profile black .

0 comments on commit 68bb955

Please sign in to comment.