Skip to content

Commit

Permalink
Clean up pyproject / precommit (#920)
Browse files Browse the repository at this point in the history

Use uv instead of pip-tools and clean up the surrounding code

Update precommit things, add mypy, clean up surrounding code
  • Loading branch information
michaelboulton committed Mar 27, 2024
1 parent a759194 commit 3b7120b
Show file tree
Hide file tree
Showing 13 changed files with 419 additions and 859 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ jobs:
matrix:
include:
# 'Basic' tests and checks
- TOXENV: py3mypy
TOXCFG: tox.ini
- TOXENV: py3
TOXCFG: tox.ini

Expand Down Expand Up @@ -66,7 +64,8 @@ jobs:

- name: install deps
run: |
pip install tox -c constraints.txt
pip install uv
uv pip install --system -r requirements.txt
- name: tox
run: |
Expand Down Expand Up @@ -133,7 +132,8 @@ jobs:

- name: install deps
run: |
pip install tox -c constraints.txt
pip install uv
uv pip install --system -r requirements.txt
- name: tox
run: |
Expand Down
13 changes: 10 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.15.2
hooks:
- id: pyupgrade
args:
- --py38-plus
files: "tavern/.*"
- repo: https://github.com/rhysd/actionlint
rev: v1.6.26
rev: v1.6.27
hooks:
- id: actionlint
args: ["-shellcheck="]
Expand All @@ -16,7 +16,7 @@ repos:
hooks:
- id: pycln
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.1.14"
rev: "v0.3.4"
hooks:
- id: ruff-format
- id: ruff
Expand All @@ -26,5 +26,12 @@ repos:
hooks:
- id: prettier
types_or: [yaml]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
hooks:
- id: mypy
additional_dependencies:
[types-requests, types-protobuf, types-PyYAML, mypy-extensions]
exclude: tests

exclude: (docs/|example/)
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ If on Windows, you should be able to just run the 'tox' commands in that file.

1. Add or update the dependency in [pyproject.toml](/pyproject.toml)

1. Update requirements files (BOTH of them)
1. Update constraints and requirements file

```shell
pip-compile --all-extras --resolver=backtracking pyproject.toml --output-file requirements.txt --reuse-hashes --generate-hashes -U
pip-compile --all-extras --resolver=backtracking pyproject.toml --output-file constraints.txt --strip-extras -U
uv pip compile --all-extras pyproject.toml --output-file constraints.txt -U
uv pip compile --all-extras pyproject.toml --output-file requirements.txt -U --generate-hashes
```

1. Run tests as above
Expand All @@ -46,7 +46,7 @@ Run every so often to update the pre-commit hooks

### Fixing Python formatting issue

black tavern/ tests/
ruff format tavern/ tests/
ruff --fix tavern/ tests/

### Fix yaml formatting issues
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ If you want to develop things in tavern, enter your virtualenv and run
`pip install -r requirements.txt` to install the library, any requirements,
and other useful development options.

Tavern uses [black](https://github.com/ambv/black) to keep all of the code
formatted consistently. There is a pre-commit hook to run black which can
Tavern uses [ruff](https://pypi.org/project/ruff/) to keep all of the code
formatted consistently. There is a pre-commit hook to run `ruff format` which can
be enabled by running `pre-commit install`.

If you want to add a feature to get merged back into mainline Tavern:
Expand Down
Loading

0 comments on commit 3b7120b

Please sign in to comment.