Skip to content

Commit

Permalink
ci: move over from flake8, autopep8 and isort to ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
MultifokalHirn committed Nov 15, 2023
1 parent de258f1 commit c9c0276
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 140 deletions.
30 changes: 18 additions & 12 deletions .github/workflows/python-checks.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Run Checks on Code
---
name: Test

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
paths-ignore:
- "docs/**"
- "mypyc/doc/**"
- "**/*.rst"
- "**/*.md"
- .gitignore
- CREDITS
- LICENSE
workflow_dispatch:

permissions:
Expand All @@ -18,8 +24,8 @@ jobs:
name: Lint & Test for ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
max-parallel: 2
# fail-fast: true
max-parallel: 1
fail-fast: true
matrix:
python-version: [3.8, 3.11, 3.12]

Expand All @@ -29,15 +35,15 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Setup environment
run: make bootstrap
- name: Install dependencies
run: |
make bootstrap
make dev
- name: Lint
run: make lint
continue-on-error: true
run: make dev

- name: Test with pytest
run: make test
- name: Lint
run: make lint
# - uses: actions/checkout@v4
# - name: Set up Python ${{ matrix.python-version }}
# uses: pdm-project/setup-pdm@v3
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ repos:
hooks:
# Run the linter.
- id: ruff
args: [--fix]
args: [--fix, --config=./pyproject.toml]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
Expand Down
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
"[properties]": {
"editor.formatOnSave": false,
},
"[yaml]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "redhat.vscode-yaml"
},
"python.analysis.typeCheckingMode": "basic",
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.fontFamily": "\"Geist Mono Medium\", \"LigaSFMonoNerdFont\",\"Hack Nerd Font\", \"Noto Mono\", \"Jetbrains Mono Regular\", Menlo, Monaco, 'Courier New', monospace",
Expand Down
23 changes: 14 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,24 @@ update: venv ## update lock file if needed
run: app ## Run the application
.PHONY: run

lint-fix: venv ## Run autopep8 and isort
lint-fix:
# Run auto-formatters...
$(VENV)/autopep8 **/*.py --in-place --recursive --aggressive --aggressive
$(VENV)/isort **/*.py
.PHONY: lint-fix

lint: lint-fix ## Runs flake8 on src, exit if critical rules are broken
# lint-fix: venv ## Run autopep8 and isort
# lint-fix:
# # Run auto-formatters...
# $(VENV)/autopep8 **/*.py --in-place --recursive --aggressive --aggressive
# $(VENV)/isort **/*.py
# .PHONY: lint-fix
lint: ## Runs lint on src, exit if critical rules are broken
lint:
$(VENV)/ruff check src/ tests/ --config=./pyproject.toml
.PHONY: lint


flake8: ## Runs flake8 on src, exit if critical rules are broken
flake8:
# Run flake8...
$(VENV)/flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --max-line-length=127
$(VENV)/flake8 . --count --exit-zero --statistics
.PHONY: lint
.PHONY: flake8

mypy: venv ## Runs mypy on src, exit if critical rules are broken
mypy:
Expand Down
209 changes: 102 additions & 107 deletions pdm.lock

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,10 @@ base = [
"tox-pdm"
]
lint = [
# "flake8",
"ruff",
"mypy",
"mypy-extensions",
]
lint-fix = [
# "autopep8",
# "isort",
]
test = [
"pytest",
"pytest-cov",
Expand Down
8 changes: 4 additions & 4 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ platformdirs==3.11.0
pluggy==1.3.0
pre-commit==3.5.0
prompt-toolkit==3.0.36
pydantic==2.4.2
pydantic-core==2.10.1
pydantic==2.5.0
pydantic-core==2.14.1
pygments==2.16.1
pyproject-api==1.6.1
pytest==7.4.3
Expand All @@ -50,11 +50,11 @@ six==1.16.0
structlog==23.2.0
termcolor==2.3.0
tokenize-rt==5.2.0
tomlkit==0.12.2
tomlkit==0.12.3
tox==4.11.3
tox-pdm==0.7.0
types-mock==5.1.0.2
typing-extensions==4.8.0
virtualenv==20.24.6
wcwidth==0.2.9
wcwidth==0.2.10
zipp==3.17.0
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ annotated-types==0.6.0
asttokens==2.4.1
devtools==0.12.2
executing==2.0.1
pydantic==2.4.2
pydantic-core==2.10.1
pydantic==2.5.0
pydantic-core==2.14.1
pygments==2.16.1
ruamel-yaml==0.18.5
ruamel-yaml-clib==0.2.8
Expand Down

0 comments on commit c9c0276

Please sign in to comment.