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

Use ruff instead of isort and black #152

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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-not-ci
- 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
20 changes: 13 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,23 @@ python = "^3.9"
aiohttp = "^3.8.5"

[tool.poetry.group.dev.dependencies]
black = "^24.10.0"
isort = "^5.11.4"
pytest = "^8.1.1"
pytest-asyncio = "^0.23.6"

[tool.black]
line-length = 88
target-version = ['py39', 'py310', 'py311', 'py312', 'py313']
[tool.poetry.group.dev-not-ci.dependencies]
# Group for dev dependencies which don't require explicit installation in CI -
# implicitly installed by GitHub actions
ruff = "^0.6.9"

[tool.isort]
profile = "black"
[tool.ruff]
target-version = "py39" # Ruff doesn't yet infer this from [tool.poetry.dependencies]

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

[tool.ruff.lint.per-file-ignores]
"/*.py" = ["I"]

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
2 changes: 1 addition & 1 deletion spond/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Callable

import aiohttp

import dummy_import

class AuthenticationError(Exception):
pass
Expand Down
1 change: 0 additions & 1 deletion spond/spond.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class Spond(_SpondBase):

DT_FORMAT = "%Y-%m-%dT00:00:00.000Z"

_EVENT: ClassVar = "event"
Expand Down
1 change: 0 additions & 1 deletion tests/test_spond.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def mock_payload():


class TestEventMethods:

@pytest.fixture
def mock_events(self) -> list[JSONDict]:
"""Mock a minimal list of events."""
Expand Down
Loading