Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ default_language_version:
python: python3.12
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.15.12
hooks:
- id: ruff
- id: ruff-check
args: [ --fix ]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v6.0.0
hooks:
- id: check-added-large-files
args: [ --maxkb=2048 ]
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ documentation = "https://docs.taskbadger.net/"

[dependency-groups]
dev = [
"black",
"isort",
"pre-commit",
"pytest",
"pytest-httpx",
Expand Down Expand Up @@ -100,4 +98,5 @@ skip-magic-trailing-comma = false
line-ending = "auto"

[tool.ruff.lint.per-file-ignores]
"taskbadger/internal/*" = ["E501"]
# taskbadger/internal/ is generated by openapi-python-client; lint is best-effort
"taskbadger/internal/*" = ["E501", "UP", "F"]
2 changes: 1 addition & 1 deletion taskbadger/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def _maybe_create_task(signal_sender):
inner_task = celery.current_app.tasks.get(task_name)
items = signal_sender.request.kwargs.get("it", [])
# Convert to list if needed for counting and potential recording
items_list = list(items) if not isinstance(items, (list, tuple)) else items
items_list = list(items) if not isinstance(items, list | tuple) else items
item_count = len(items_list)
# Append canvas type and item count to task name
task_name = f"{task_name} ({canvas_type} {item_count})"
Expand Down
3 changes: 1 addition & 2 deletions taskbadger/cli/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
from enum import Enum
from typing import Optional

import typer
from rich import print
Expand Down Expand Up @@ -29,7 +28,7 @@ def get_actions(action_def: tuple[str, str, str]) -> list[Action]:
return []


def merge_kv_json(metadata_kv: Optional[list[str]], metadata_json: str) -> dict:
def merge_kv_json(metadata_kv: list[str] | None, metadata_json: str) -> dict:
metadata = {}
for kv in metadata_kv or []:
k, v = kv.strip().split("=", 1)
Expand Down
4 changes: 2 additions & 2 deletions taskbadger/cli_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ def info(ctx: typer.Context):
@app.callback()
def main(
ctx: typer.Context,
org: Optional[str] = typer.Option(
org: str | None = typer.Option(
None,
"--org",
"-o",
metavar="TASKBADGER_ORG",
show_default=False,
help="Organization Slug. This will override values from the config file and environment variables.",
),
project: Optional[str] = typer.Option(
project: str | None = typer.Option(
None,
"--project",
"-p",
Expand Down
8 changes: 4 additions & 4 deletions taskbadger/mug.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import dataclasses
from collections.abc import Callable
from contextlib import ContextDecorator
from contextvars import ContextVar
from copy import deepcopy
from typing import Callable, Optional, Union

from taskbadger.internal import AuthenticatedClient
from taskbadger.systems import System

_local = ContextVar("taskbadger_client")


Callback = Union[str, Callable[[dict], Optional[dict]]]
Callback = str | Callable[[dict], dict | None]


@dataclasses.dataclass
Expand Down Expand Up @@ -47,7 +47,7 @@ class Session(ContextDecorator):
def __init__(self):
self._session = None

def __enter__(self) -> Union[AuthenticatedClient, None]:
def __enter__(self) -> AuthenticatedClient | None:
if Badger.is_configured():
self._session = Badger.current.session()
return self._session.__enter__()
Expand Down Expand Up @@ -144,7 +144,7 @@ def client(self) -> AuthenticatedClient:
def scope(self) -> Scope:
return self._scope

def call_before_create(self, task: dict) -> Optional[dict]:
def call_before_create(self, task: dict) -> dict | None:
if self.settings and self.settings.before_create:
return self.settings.before_create(task)
return task
Expand Down
2 changes: 1 addition & 1 deletion taskbadger/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def import_string(dotted_path):
try:
module_path, class_name = dotted_path.rsplit(".", 1)
except ValueError as err:
raise ImportError("%s doesn't look like a module path" % dotted_path) from err
raise ImportError(f"{dotted_path} doesn't look like a module path") from err

module = import_module(module_path)

Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from taskbadger.mug import Badger, Settings


@pytest.fixture()
@pytest.fixture
def _bind_settings():
Badger.current.bind(Settings("https://taskbadger.net", "token", "org", "proj"))
yield
Expand Down
2 changes: 1 addition & 1 deletion tests/test_celery_system_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _wait_for_mock_calls(mock_obj, expected_count, timeout=5):
time.sleep(0.05)


@pytest.fixture()
@pytest.fixture
def _bind_settings_with_system():
systems = [CelerySystemIntegration()]
Badger.current.bind(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def mock_config_location():
os.remove(config_path)


@pytest.fixture()
@pytest.fixture
def _mock_config(mock_config_location):
config = Config(
organization_slug="test_org",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_project_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_init_legacy_key_emits_deprecation_warning(self):
init("org", "project", "legacy-token")

def test_init_legacy_key_still_works(self):
with pytest.warns(DeprecationWarning):
with pytest.warns(DeprecationWarning, match="Legacy API keys are deprecated"):
init("org", "project", "legacy-token")
settings = Badger.current.settings
assert settings.organization_slug == "org"
Expand Down Expand Up @@ -152,7 +152,7 @@ def test_project_key_is_valid(self):
runner = CliRunner()


@pytest.fixture()
@pytest.fixture
def mock_config_location():
config_path = Path(__file__).parent / "_mock_config_project_key"
with mock.patch("taskbadger.config._get_config_path", return_value=config_path):
Expand Down
8 changes: 4 additions & 4 deletions tests/test_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ def _init_skd():
init("org", "project", "token")


@pytest.fixture()
@pytest.fixture
def settings():
return Badger.current.settings


@pytest.fixture()
@pytest.fixture
def patched_get():
with mock.patch("taskbadger.sdk.task_get.sync") as get:
yield get


@pytest.fixture()
@pytest.fixture
def patched_create():
with mock.patch("taskbadger.sdk.task_create.sync_detailed") as create:
yield create


@pytest.fixture()
@pytest.fixture
def patched_update():
with mock.patch("taskbadger.sdk.task_partial_update.sync_detailed") as update:
yield update
Expand Down
65 changes: 0 additions & 65 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.