Skip to content

Commit b54d624

Browse files
authored
Pre commit lint and format update (#250)
* Update pre-commit and CI to ensure format and lint (#248) * Adding the changes we made in precommit, poetry, nox * add release.md * Update pre-commit to all files and Mypy setup (#247) * Update pre-commit and mypy .ini just like the main strawberry project * add a lint error on purpose to test lint * add a release md and add file attr to tmol pre-commit * fix test action to run when a PR is ready for review * test mappe * fix action * continue with tests in lint in nox file * remove pydantic.mypy plugin * made first lint ajustment, but still missing lint test * add ruff and black to lint te * Fix nox file and add ruff to pyptoject toml * fix poetry lock * fix command to raise error * make ruff output errors * bring back black to pre-commit * remove --diff from ruff because we want to run in all files, remove invalid rules in lint * update pre-commit to ruff run lint and formatter * separate ruff lint from formater in noxfile * remove test function from mapper * remove black and use only ruff * add lint tag to ruff format in nox * change test.yml to run lint and format divided * Run pre-commit in all files and made line-lenght 100 * updated ruff check * update pyproject.toml * Made sourcery fixes * remove unecessary else * bring back session._session
1 parent 7f2cbaf commit b54d624

28 files changed

+397
-516
lines changed

.alexrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"allow": [
3-
"black",
43
"hook",
54
"hooks",
65
"failure",

.devcontainer/devcontainer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,19 @@
1313
"python.linting.enabled": true,
1414
"python.linting.pylintEnabled": false,
1515
"python.linting.mypyEnabled": true,
16+
"python.linting.mypyPath": "${workspaceFolder}/.venv/bin/mypy",
1617
"[python]": {
1718
"editor.defaultFormatter": "charliermarsh.ruff"
1819
},
19-
"python.formatting.provider": "black",
20-
"python.formatting.blackPath": "${workspaceFolder}/.venv/bin/black",
21-
"python.linting.mypyPath": "${workspaceFolder}/.venv/bin/mypy"
20+
"python.formatting.provider": "none"
2221
},
2322
"extensions": [
2423
"ms-python.python",
2524
"ms-python.vscode-pylance",
2625
"ms-azuretools.vscode-docker",
2726
"eamodio.gitlens",
2827
"charliermarsh.ruff",
29-
// Dont install these extensions because they conflict with black lint
28+
// Dont install these extensions because they conflict with lint
3029
"-dbaeumer.vscode-eslint",
3130
"-ms-python.autopep8"
3231
]

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ updates:
99
all-dependencies:
1010
patterns:
1111
- "*"
12-
# Strawberry is an internal dependency,
12+
# Strawberry is an internal dependency,
1313
# let's keep an additional eye on this
1414
exclude-patterns:
1515
- "strawberry-graphql"

.github/pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
[tool.ruff]
22
extend = "../pyproject.toml"
3-
extend-ignore = [
4-
"T201",
5-
]
3+
lint.extend-ignore = ["T201"]

.github/workflows/test.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ on:
88
push:
99
branches: [main]
1010
pull_request:
11-
branches: [main]
11+
types: [synchronize, reopened, opened, ready_for_review]
12+
branches:
13+
- main
1214
paths:
1315
- "src/strawberry-sqlalchemy-mapper/**"
1416
- "tests/**"
@@ -29,7 +31,7 @@ jobs:
2931
- id: set-matrix
3032
shell: bash
3133
run: |
32-
. .venv/bin/activate
34+
. .venv/bin/activate
3335
pip install poetry nox nox-poetry
3436
echo sessions=$(
3537
nox --json -t tests -l |
@@ -103,7 +105,7 @@ jobs:
103105
run: poetry run pytest tests/benchmarks --codspeed
104106

105107
lint:
106-
name: ✨ Lint
108+
name: ✨ Lint and Format
107109
runs-on: ubuntu-latest
108110

109111
steps:
@@ -132,7 +134,9 @@ jobs:
132134
${{ runner.os }}-nox-lint-${{ env.pythonLocation }}
133135
134136
- run: pip install poetry nox nox-poetry uv
137+
- run: mkdir .mypy_cache
135138
- run: nox -r -t lint
139+
- run: nox -r -t format
136140

137141
unit-tests-on-windows:
138142
name: 🪟 Tests on Windows

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ cover/*
4949
MANIFEST
5050

5151
# Per-project virtualenvs
52+
venv*/
5253
.venv*/
5354
.conda*/

.isort.cfg

Lines changed: 0 additions & 3 deletions
This file was deleted.

.pre-commit-config.yaml

100644100755
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
repos:
2-
- repo: https://github.com/psf/black
3-
rev: 24.4.0
4-
hooks:
5-
- id: black
6-
exclude: ^tests/\w+/snapshots/
7-
82
- repo: https://github.com/astral-sh/ruff-pre-commit
9-
rev: v0.11.7
3+
# Ruff version.
4+
rev: v0.11.10
105
hooks:
11-
- id: ruff
12-
exclude: ^tests/\w+/snapshots/
6+
# Run the linter.
7+
- id: ruff-check
8+
args: [--fix]
9+
# Run the formatter.
10+
- id: ruff-format
1311

1412
- repo: https://github.com/patrick91/pre-commit-alex
1513
rev: aa5da9e54b92ab7284feddeaf52edf14b1690de3
@@ -37,3 +35,9 @@ repos:
3735
hooks:
3836
- id: blacken-docs
3937
args: [--skip-errors]
38+
39+
- repo: https://github.com/ComPWA/taplo-pre-commit
40+
rev: v0.9.3
41+
hooks:
42+
- id: taplo-format
43+
files: \.(toml)$

CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,3 @@ Contributed by [Layton Wedgeworth](https://github.com/asimov-layton) via [PR #24
152152
Dependency version changes needed for python 3.12 compatibility.
153153

154154
Contributed by [mattalbr](https://github.com/mattalbr) via [PR #35](https://github.com/strawberry-graphql/strawberry-sqlalchemy/pull/35/)
155-
156-

CONTRIBUTING.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ on PyPI_, the following steps can be used to release a new version for
353353
.. |tox| replace:: ``tox``
354354

355355

356-
.. _black: https://pypi.org/project/black/
357356
.. _CommonMark: https://commonmark.org/
358357
.. _contribution-guide.org: https://www.contribution-guide.org/
359358
.. _creating a PR: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request

0 commit comments

Comments
 (0)