Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: replace isort . and black . for import sorting + formatting, replicating current behaviour, including CI #118

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,19 @@ jobs:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Install project
run: poetry install
- name: Lint imports with isort
# Use command line due to bugs/docs gaps with official `isort/isort-action`.
# Exit with error if the code is not properly formatted; show diffs;
# `black` compatibility.
# Only target files in `spond` and `test` due to unreliable behaviour on files in
# root directory.
# Diffs reported for these files should be the same as fixes made by running
# `isort .` in the root project folder, which picks up config from
# Don't install dependencies that are handled within actions
run: poetry install --without dev
- name: Lint with ruff
# By default, exit with error if rule violations, report issues.
# Equivalent to `ruff check`. Picks up config from `pyproject.toml`.
uses: chartboost/ruff-action@v1
- name: Check format with ruff
# By default, exit with error if the code is not properly formatted.
# Equivalent to `ruff format --check --diff`. Picks up config from
# `pyproject.toml`.
run: |
source $VENV
isort spond --check-only --diff --profile black
isort tests --check-only --diff --profile black
- name: Lint with black
# by default: exit with error if the code is not properly formatted; show diffs
uses: psf/black@stable
uses: chartboost/ruff-action@v1
with:
args: format --check --diff
- name: Test with pytest
run: |
source $VENV
Expand Down
18 changes: 10 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ repository = 'https://github.com/Olen/Spond'
python = "^3.8"
aiohttp = "^3.8.5"

[tool.poetry.group.dev.dependencies]
black = "^24.4.0"
isort = "^5.11.4"
[tool.poetry.group.dev.dependencies] # not required by CI
ruff = "^0.4"

[tool.poetry.group.test.dependencies]
pytest = "^8.1.1"
pytest-asyncio = "^0.23.6"

[tool.black]
line-length = 88
target-version = ['py38', 'py39', 'py310', 'py311', 'py312']
[tool.ruff]
target-version = "py38" # Ruff doesn't yet infer this from [tool.poetry.dependencies]
include = ["tests/*.py", "spond/*.py"] # Match existing behaviour

[tool.isort]
profile = "black"
[tool.ruff.lint]
# Enable only isort rules
select = ["I"]

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
Loading