Commit 2d33fca4 authored by Dimitrios Gogos's avatar Dimitrios Gogos
Browse files

fix: code structure for improved readability and maintainability

parent 7745c4c4
Loading
Loading
Loading
Loading
+1 −0
Changes for .gitignore: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
.cache/
*.egg-info/
__pycache__/
.coverage
*.py[cod]

# Local environment
+25 −17
Changes for Makefile: 25 added lines, 17 removed lines.
Original line number Diff line number Diff line
.PHONY: install clean lint format type precommit architecture test integration run
.PHONY: install clean lint format precommit architecture type test integration coverage run

PIP := .venv/bin/pip
SRC := src/portal_service
TEST := tests
DEV ?= false

# Trust the OS certificate store (uv does not by default, unlike pip) so
# installs work behind corporate TLS-inspecting proxies.
export UV_SYSTEM_CERTS := 1

## Dev tools Packages Handling
ifeq ($(DEV),true)
	EXTRAS := dev
	EXTRAS := --extra dev
else
	EXTRAS :=
endif

ifeq ($(EXTRAS),)
PIP_INSTALL = $(PIP) install -e .
else
PIP_INSTALL = $(PIP) install -e .[$(EXTRAS)]
endif
## Uv sync command
# --locked fails fast if uv.lock is out of sync with pyproject.toml, instead of
# silently re-resolving, so local dev and CI always install the same versions.
UV_SYNC = uv sync --locked $(EXTRAS)

## Make Commands
install:
	python3 -m venv .venv
	$(PIP) install --upgrade pip setuptools wheel
	$(PIP_INSTALL)
	$(UV_SYNC)

clean:
	rm -rf .venv
@@ -27,15 +31,11 @@ clean:

lint:
	make install DEV=true
	.venv/bin/ruff check --fix
	.venv/bin/ruff check --fix $(SRC) $(TEST)

format:
	make install DEV=true
	.venv/bin/ruff format

type:
	make install DEV=true
	.venv/bin/mypy src/ tests/
	.venv/bin/ruff format $(SRC) $(TEST)

precommit:
	make install DEV=true
@@ -45,6 +45,10 @@ architecture:
	make install DEV=true
	.venv/bin/lint-imports --cache-dir .cache/import-linter

type:
	make install DEV=true
	.venv/bin/mypy $(SRC) $(TEST)

test:
	make install DEV=true
	.venv/bin/pytest
@@ -53,6 +57,10 @@ integration:
	make install DEV=true
	.venv/bin/pytest -m integration

coverage:
	make install DEV=true
	.venv/bin/pytest --cov=$(SRC) --cov-branch --cov-report=term-missing

run:
	make install
	.venv/bin/uvicorn "portal_service.main:create_app" --factory --reload --port 8000
+27 −1
Changes for pyproject.toml: 27 added lines, 1 removed line.
Original line number Diff line number Diff line
[build-system]
requires = ["setuptools>=61"]
build-backend = "setuptools.build_meta"

[project]
name = "portal-backend"
version = "1.0.0"
description = "OOP Portal backend"
readme = "README.md"
authors = [
    {name = "OOP Team"},
]
dynamic = ["version"]
requires-python = "==3.12.*"
dependencies = [
    "fastapi[standard]>=0.115.0",
@@ -25,10 +29,14 @@ dev = [
    "pre-commit>=4.5.0",
    "pytest>=8.0.0",
    "pytest-asyncio>=0.25.0",
    "pytest-cov>=6.0.0",
    "ruff>=0.11.0",
    "testcontainers>=4.0.0",
]

[tool.setuptools.packages.find]
where = ["src"]

[tool.ruff]
line-length = 100
target-version = "py312"
@@ -46,6 +54,7 @@ python_version = "3.12"
cache_dir = ".cache/mypy"
strict = true
ignore_missing_imports = true
mypy_path = "src"

[tool.importlinter]
root_package = "portal_service"
@@ -72,3 +81,20 @@ addopts = "-m 'not integration'"
markers = [
    "integration: needs a live Keycloak reachable at KEYCLOAK_ISSUER",
]

[tool.coverage.run]
branch = true
omit = [
    "*/tests/*",
    "*/__main__.py",
]

[tool.coverage.report]
show_missing = true
skip_covered = false
precision = 1
exclude_lines = [
    "pragma: no cover",
    "if TYPE_CHECKING:",
    "raise NotImplementedError",
]

uv.lock

0 → 100644
+1321 −0

File added.

Preview size limit exceeded, changes collapsed.