Skip to content

Commit 127c6bb

Browse files
authored
Merge pull request #1 from pamelafox/ruff-updates
Ruff and 3.10 updates
2 parents ec99798 + 77c9d82 commit 127c6bb

File tree

6 files changed

+38
-51
lines changed

6 files changed

+38
-51
lines changed

.github/dependabot.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "pip" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"

.github/workflows/python.yaml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,15 @@ jobs:
1414
- name: Set up Python 3
1515
uses: actions/setup-python@v3
1616
with:
17-
python-version: 3.9
17+
python-version: "3.10"
1818
- name: Install dependencies
1919
run: |
2020
python -m pip install --upgrade pip
2121
pip install -r requirements-dev.txt
2222
- name: Lint with ruff
23-
run: |
24-
ruff . --select=E9,F63,F7,F82
25-
ruff . --exit-zero
26-
- name: Check pyupgrade
27-
run: pyupgrade --py310-plus *.py tests/*.py
23+
run: ruff .
2824
- name: Check formatting with black
29-
uses: psf/black@stable
30-
with:
31-
src: ". tests/"
32-
options: "--check --verbose"
33-
- name: Check Python import sorting
34-
run: isort --check .
25+
run: black . --check --verbose
3526
- name: Run unit tests
3627
run: |
3728
pytest

.pre-commit-config.yaml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v2.3.0
3+
rev: v4.4.0
44
hooks:
55
- id: check-yaml
66
- id: end-of-file-fixer
77
- id: trailing-whitespace
8+
- repo: https://github.com/charliermarsh/ruff-pre-commit
9+
rev: v0.0.252
10+
hooks:
11+
- id: ruff
812
- repo: https://github.com/psf/black
9-
rev: 22.3.0
13+
rev: 23.1.0
1014
hooks:
1115
- id: black
1216
args: ['--config=./pyproject.toml']
13-
- repo: https://github.com/pycqa/isort
14-
rev: 5.10.1
15-
hooks:
16-
- id: isort
17-
name: isort (python)
18-
- repo: https://github.com/charliermarsh/ruff-pre-commit
19-
rev: v0.0.116
20-
hooks:
21-
- id: ruff
22-
- repo: https://github.com/asottile/pyupgrade
23-
rev: v3.1.0
24-
hooks:
25-
- id: pyupgrade
26-
args: ['--py310-plus']

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22

33
This is a template repository for any Python project that comes with the following dev tools:
44

5+
* `ruff`: identifies many errors and style issues (`flake8`, `isort`, `pyupgrade`)
56
* `black`: auto-formats code
6-
* `isort`: sorts the imports
7-
* `ruff`: looks for common errors
8-
* `pyupgrade`: upgrades Python syntax
97

10-
All of those checks are run as pre-commit hooks using the `pre-commit` library.
8+
Those checks are run as pre-commit hooks using the `pre-commit` library.
119

1210
It includes `pytest` for testing plus the `pytest-cov` plugin to measure coverage.
1311

1412
The checks and tests are all run using Github actions on every pull request and merge to main.
1513

16-
This repository is setup for Python 3.10. To customize that, change the `VARIANT` argument in `.devcontainer/devcontainer.json`, and change the flag passed into `pyupgrade` in `.precommit-config.yaml` and `.github/workflows/python.yaml`.
14+
This repository is setup for Python 3.10. To customize that, change the `VARIANT` argument in `.devcontainer/devcontainer.json`, change the config options in `.precommit-config.yaml` and change the version number in `.github/workflows/python.yaml`.
1715

1816
## Development instructions
1917

@@ -35,7 +33,7 @@ source .venv/bin/activate
3533
Then install the dev tools and pre-commit hooks:
3634

3735
```
38-
pip3 install --user -r requirements-dev.txt
36+
python3 -m pip install --user -r requirements-dev.txt
3937
pre-commit install
4038
```
4139

@@ -45,10 +43,10 @@ This repository starts with a very simple `main.py` and a test for it at `tests/
4543
You'll want to replace that with your own code, and you'll probably want to add additional files
4644
as your code grows in complexity.
4745

48-
When you're ready to run tests, just run:
46+
When you're ready to run tests, run:
4947

5048
```
51-
pytest
49+
python3 -m pytest
5250
```
5351

5452
# File breakdown

pyproject.toml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1+
[tool.ruff]
2+
line-length = 100
3+
target-version = "py310"
4+
select = ["E", "F", "I", "UP"]
5+
ignore = ["D203"]
6+
show-source = true
7+
18
[tool.black]
29
line-length = 100
3-
target-version = ['py39']
10+
target-version = ["py310"]
11+
12+
[tool.pylint.messages_control]
13+
disable = "C0114,C0115,C0116"
414

515
[tool.pytest.ini_options]
616
addopts = "-ra --cov"
717
testpaths = ["tests"]
818
pythonpath = ['.']
9-
10-
[tool.pylint.messages_control]
11-
disable = "C0114,C0115,C0116"
12-
13-
[tool.isort]
14-
profile = "black"
15-
16-
[tool.ruff]
17-
line-length = 100
18-
ignore = ["D203"]
19-
show-source = true

requirements-dev.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
-r requirements.txt
22
pre-commit
3-
black
4-
isort
53
ruff
6-
pyupgrade
4+
black
75
pytest
86
coverage
97
pytest-cov

0 commit comments

Comments
 (0)