Skip to content

Commit 64cdc84

Browse files
authored
Merge pull request #45 from taskbadger/sk/refresh-tooling
Refresh lint/format tooling
2 parents 3741de3 + bad3a07 commit 64cdc84

13 files changed

Lines changed: 23 additions & 90 deletions

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ default_language_version:
33
python: python3.12
44
repos:
55
- repo: https://github.com/astral-sh/ruff-pre-commit
6-
rev: v0.2.1
6+
rev: v0.15.12
77
hooks:
8-
- id: ruff
8+
- id: ruff-check
99
args: [ --fix ]
1010
- id: ruff-format
1111
- repo: https://github.com/pre-commit/pre-commit-hooks
12-
rev: v4.4.0
12+
rev: v6.0.0
1313
hooks:
1414
- id: check-added-large-files
1515
args: [ --maxkb=2048 ]

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ documentation = "https://docs.taskbadger.net/"
5757

5858
[dependency-groups]
5959
dev = [
60-
"black",
61-
"isort",
6260
"pre-commit",
6361
"pytest",
6462
"pytest-httpx",
@@ -100,4 +98,5 @@ skip-magic-trailing-comma = false
10098
line-ending = "auto"
10199

102100
[tool.ruff.lint.per-file-ignores]
103-
"taskbadger/internal/*" = ["E501"]
101+
# taskbadger/internal/ is generated by openapi-python-client; lint is best-effort
102+
"taskbadger/internal/*" = ["E501", "UP", "F"]

taskbadger/celery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def _maybe_create_task(signal_sender):
263263
inner_task = celery.current_app.tasks.get(task_name)
264264
items = signal_sender.request.kwargs.get("it", [])
265265
# Convert to list if needed for counting and potential recording
266-
items_list = list(items) if not isinstance(items, (list, tuple)) else items
266+
items_list = list(items) if not isinstance(items, list | tuple) else items
267267
item_count = len(items_list)
268268
# Append canvas type and item count to task name
269269
task_name = f"{task_name} ({canvas_type} {item_count})"

taskbadger/cli/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import json
22
from enum import Enum
3-
from typing import Optional
43

54
import typer
65
from rich import print
@@ -29,7 +28,7 @@ def get_actions(action_def: tuple[str, str, str]) -> list[Action]:
2928
return []
3029

3130

32-
def merge_kv_json(metadata_kv: Optional[list[str]], metadata_json: str) -> dict:
31+
def merge_kv_json(metadata_kv: list[str] | None, metadata_json: str) -> dict:
3332
metadata = {}
3433
for kv in metadata_kv or []:
3534
k, v = kv.strip().split("=", 1)

taskbadger/cli_main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ def info(ctx: typer.Context):
7272
@app.callback()
7373
def main(
7474
ctx: typer.Context,
75-
org: Optional[str] = typer.Option(
75+
org: str | None = typer.Option(
7676
None,
7777
"--org",
7878
"-o",
7979
metavar="TASKBADGER_ORG",
8080
show_default=False,
8181
help="Organization Slug. This will override values from the config file and environment variables.",
8282
),
83-
project: Optional[str] = typer.Option(
83+
project: str | None = typer.Option(
8484
None,
8585
"--project",
8686
"-p",

taskbadger/mug.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import dataclasses
2+
from collections.abc import Callable
23
from contextlib import ContextDecorator
34
from contextvars import ContextVar
45
from copy import deepcopy
5-
from typing import Callable, Optional, Union
66

77
from taskbadger.internal import AuthenticatedClient
88
from taskbadger.systems import System
99

1010
_local = ContextVar("taskbadger_client")
1111

1212

13-
Callback = Union[str, Callable[[dict], Optional[dict]]]
13+
Callback = str | Callable[[dict], dict | None]
1414

1515

1616
@dataclasses.dataclass
@@ -47,7 +47,7 @@ class Session(ContextDecorator):
4747
def __init__(self):
4848
self._session = None
4949

50-
def __enter__(self) -> Union[AuthenticatedClient, None]:
50+
def __enter__(self) -> AuthenticatedClient | None:
5151
if Badger.is_configured():
5252
self._session = Badger.current.session()
5353
return self._session.__enter__()
@@ -144,7 +144,7 @@ def client(self) -> AuthenticatedClient:
144144
def scope(self) -> Scope:
145145
return self._scope
146146

147-
def call_before_create(self, task: dict) -> Optional[dict]:
147+
def call_before_create(self, task: dict) -> dict | None:
148148
if self.settings and self.settings.before_create:
149149
return self.settings.before_create(task)
150150
return task

taskbadger/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def import_string(dotted_path):
55
try:
66
module_path, class_name = dotted_path.rsplit(".", 1)
77
except ValueError as err:
8-
raise ImportError("%s doesn't look like a module path" % dotted_path) from err
8+
raise ImportError(f"{dotted_path} doesn't look like a module path") from err
99

1010
module = import_module(module_path)
1111

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from taskbadger.mug import Badger, Settings
44

55

6-
@pytest.fixture()
6+
@pytest.fixture
77
def _bind_settings():
88
Badger.current.bind(Settings("https://taskbadger.net", "token", "org", "proj"))
99
yield

tests/test_celery_system_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _wait_for_mock_calls(mock_obj, expected_count, timeout=5):
3939
time.sleep(0.05)
4040

4141

42-
@pytest.fixture()
42+
@pytest.fixture
4343
def _bind_settings_with_system():
4444
systems = [CelerySystemIntegration()]
4545
Badger.current.bind(

tests/test_cli_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def mock_config_location():
2121
os.remove(config_path)
2222

2323

24-
@pytest.fixture()
24+
@pytest.fixture
2525
def _mock_config(mock_config_location):
2626
config = Config(
2727
organization_slug="test_org",

0 commit comments

Comments
 (0)