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
24 changes: 12 additions & 12 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ install: sync
uv run pre-commit install

# Run the CLI, e.g. `just run user list`
run *ARGS:
uv run core {{ ARGS }}
run *ARGUMENTS:
uv run core {{ ARGUMENTS }}

# Run the test suite, e.g. `just test -k users`
test *ARGS:
uv run pytest {{ ARGS }}
test *ARGUMENTS:
uv run pytest {{ ARGUMENTS }}

# Run the test suite with a coverage report
test-cov:
test-coverage:
uv run pytest --cov=src

# Lint with ruff
Expand All @@ -34,15 +34,15 @@ lint-fix:
uv run ruff check . --fix

# Format with ruff
fmt:
format:
uv run ruff format .

# Report formatting problems without rewriting files
fmt-check:
format-check:
uv run ruff format . --check

# Static type analysis with ty
typecheck:
type-check:
uv run ty check

# Security scan only (bandit rules, already part of `just lint`)
Expand All @@ -54,18 +54,18 @@ hooks:
uv run pre-commit run --all-files

# Full read-only quality gate: lint (incl. security), formatting, types, tests
check: lint fmt-check typecheck test
check: lint format-check type-check test

# Reformat and autofix, then run the full quality gate
fix: fmt lint-fix check
fix: format lint-fix check

# Build the Docker image
docker-build:
docker buildx build -f {{ DOCKERFILE }} -t {{ IMAGE }} .

# Run the CLI inside the Docker image, e.g. `just docker-run user list`
docker-run *ARGS:
docker run -it --rm {{ IMAGE }} core {{ ARGS }}
docker-run *ARGUMENTS:
docker run -it --rm {{ IMAGE }} core {{ ARGUMENTS }}

# Refresh the lockfile without changing pinned versions
lock:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ just run user list

# Tests
just test
just test-cov
just test-coverage

# Individual quality checks
just lint
just fmt
just typecheck
just format
just type-check
just security

# Full quality gate: lint, formatting, types, security, tests
Expand Down
8 changes: 4 additions & 4 deletions src/core/src/core/clients/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def get(self, endpoint: str, params: dict[str, Any] | None = None) -> dict[str,
response = self.session.get(url, params=params)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
raise HttpError(f"HTTP request failed: {e}") from e
except ValueError as e:
raise HttpError(f"Invalid JSON response: {e}") from e
except requests.exceptions.RequestException as error:
raise HttpError(f"HTTP request failed: {error}") from error
except ValueError as error:
raise HttpError(f"Invalid JSON response: {error}") from error

def close(self):
self.session.close()
Expand Down
18 changes: 9 additions & 9 deletions src/core/src/core/commands/user_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ def get_user(
self.logger.info(f"User: {user.name} ({user.email})")
self.logger.info(f"Company: {user.company.name}")
self.logger.info(f"Address: {user.address.street}, {user.address.city}")
except (CoreError, ValidationError) as e:
self.logger.error(f"Error fetching user: {e}")
raise typer.Exit(1) from e
except (CoreError, ValidationError) as error:
self.logger.error(f"Error fetching user: {error}")
raise typer.Exit(1) from error

def list_users(self) -> None:
try:
users = self.user_service.get_all_users()
self.logger.info(f"Found {len(users)} users:")
for user in users:
self.logger.info(f" {user.id}: {user.name} ({user.email})")
except (CoreError, ValidationError) as e:
self.logger.error(f"Error fetching users: {e}")
raise typer.Exit(1) from e
except (CoreError, ValidationError) as error:
self.logger.error(f"Error fetching users: {error}")
raise typer.Exit(1) from error

def get_user_posts(
self, user_id: Annotated[int, typer.Option("--id", help="User ID")] = 1
Expand All @@ -55,6 +55,6 @@ def get_user_posts(
self.logger.info(f"Posts by {user.name}:")
for post in posts:
self.logger.info(f" - {post['title']}")
except (CoreError, ValidationError) as e:
self.logger.error(f"Error fetching posts: {e}")
raise typer.Exit(1) from e
except (CoreError, ValidationError) as error:
self.logger.error(f"Error fetching posts: {error}")
raise typer.Exit(1) from error
8 changes: 4 additions & 4 deletions src/core/src/core/config/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@


def command_group(name: str):
def decorator(cls):
cls._command_name = name
_command_registry.append(cls)
return cls
def decorator(command_class):
command_class._command_name = name
_command_registry.append(command_class)
return command_class

return decorator

Expand Down
4 changes: 2 additions & 2 deletions src/core/src/core/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def __init__(self):
if not config_path.exists():
raise FileNotFoundError(f"Config file not found: {config_path}")

with open(config_path, "r") as f:
config_data = yaml.load(f, Loader=SafeLoader)
with open(config_path, "r") as config_file:
config_data = yaml.load(config_file, Loader=SafeLoader)

super().__init__(**config_data)

Expand Down
Loading