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
16 changes: 14 additions & 2 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,32 @@ name: "Formatting"

on: [push]
jobs:
# The matrix "tool" values ("black", "isort") and the job's required-check names they produce
# ("black (3.11, ubuntu-latest, black)", "black (3.11, ubuntu-latest, isort)") are kept unchanged
# on purpose, even though both now run ruff under the hood - renaming them would leave the
# required status checks configured on the branch protection ruleset permanently pending.
# Renaming these labels for real requires updating that ruleset in the same change, which is an
# admin-level, org-visible change to what blocks merges and is intentionally out of scope here.
black:
name: black (${{ matrix.python-version }}, ${{ matrix.os }}, ${{ matrix.tool }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.11"]
os: [ubuntu-latest]
tool: ["black", "isort"]
include:
- tool: "black"
command: "ruff format --check ."
- tool: "isort"
command: "ruff check --select I ."
steps:
- uses: actions/checkout@v7
- name: Install uv
uses: astral-sh/setup-uv@v9.0.0
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --group formatting
run: uv sync --group linting
- name: ${{ matrix.tool }} Code Formatter
run: uv run ${{ matrix.tool }} . --check
run: uv run ${{ matrix.command }}
6 changes: 2 additions & 4 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@
cd bo4e_schemas
uv run bost -t v202401.0.1 -o ./
uv run bo4e-generator -i ./ -o ../src/borm/models -ot sql_model
- name: Run pylint
- name: Run ruff check
run: |
uv run pylint src/borm --disable R0801 --ignore-paths 'src/borm/models'
uv run pylint src/borm/models --rcfile=./.pylintrc_autogen_code
uv run pylint tests --rcfile=tests/.pylintrc
uv run ruff check src/borm tests

# coverage
- name: Install Dependencies (coverage)
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/pythonlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ jobs:
cd bo4e_schemas
uv run bost -t v202401.0.1 -o ./
uv run bo4e-generator -i ./ -o ../src/borm/models -ot sql_model
- name: Run pylint
- name: Run ruff check
if: matrix.linter-env == 'linting'
run: |
uv run pylint src/borm --disable R0801 --ignore-paths 'src/borm/models'
uv run pylint src/borm/models --rcfile=./.pylintrc_autogen_code
uv run pylint tests --rcfile=tests/.pylintrc
uv run ruff check src/borm tests
- name: Run mypy
if: matrix.linter-env == 'type_check'
run: |
Expand Down
20 changes: 5 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,12 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 25.1.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
- id: isort
name: isort (cython)
types: [cython]
- id: isort
name: isort (pyi)
types: [pyi]
- id: ruff-check
args: [--fix]
- id: ruff-format
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.11.32
hooks:
Expand Down
11 changes: 0 additions & 11 deletions .pylintrc_autogen_code

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
![Unittests status badge](https://github.com/Hochfrequenz/bo4e-python-orm/workflows/tests/badge.svg)
![Coverage status badge](https://github.com/Hochfrequenz/bo4e-python-orm/workflows/Coverage/badge.svg)
![Linting status badge](https://github.com/Hochfrequenz/bo4e-python-orm/workflows/Linting/badge.svg)
![Black status badge](https://github.com/Hochfrequenz/bo4e-python-orm/workflows/Formatting/badge.svg)
![Formatting status badge](https://github.com/Hochfrequenz/bo4e-python-orm/workflows/Formatting/badge.svg)

At this point this repository serves only as an exemplary implementation of a BO4E ORM. The main work (i.e. the generation of SQL Model code) will be done in the [BO4E-CLI-Tool](https://github.com/bo4e/BO4E-CLI)

Expand Down
37 changes: 24 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,32 @@ dynamic = ["readme", "version"]
Changelog = "https://github.com/Hochfrequenz/bo4e-python-orm/releases"
Homepage = "https://github.com/Hochfrequenz/bo4e-python-orm"

[tool.black]
[tool.ruff]
line-length = 120
extend-exclude = ["*.md"]

[tool.isort]
line_length = 120
profile = "black"
[tool.ruff.lint]
select = ["E", "W", "F", "I", "UP", "B", "N", "PL", "RUF"]
ignore = [
"PLR0913", # too-many-arguments
"PLR0917", # too-many-positional-arguments
"PLR0912", # too-many-branches
"PLR0915", # too-many-statements
"RUF001", # ambiguous-unicode-character-string
"RUF002", # ambiguous-unicode-character-docstring
"RUF003", # ambiguous-unicode-character-comment
]

[tool.ruff.lint.isort]
# src/borm/models is only generated by some CI jobs' "Generate BO4E models" step, so whether
# "borm.models" resolves on disk - and thus whether ruff's isort classifies it as first-party -
# depends on which job runs. Pinning it here keeps import-sort order consistent across jobs.
known-first-party = ["borm"]

[tool.pylint."MESSAGES CONTROL"]
max-line-length = 120
[tool.ruff.lint.per-file-ignores]
# src/borm/models is autogenerated from the BO4E schemas at CI time (not present in this checkout);
# mirrors the old .pylintrc_autogen_code disables (unused-import, line-too-long).
"src/borm/models/**" = ["F401", "E501"]

[build-system]
requires = ["hatchling>=1.31.0", "hatch-vcs", "hatch-fancy-pypi-readme"]
Expand All @@ -56,18 +73,13 @@ tests = [
coverage = [
"coverage==7.15.2"
]
formatting = [
"black==26.5.1",
"isort==5.13.2"
]
init_bo4e = [
"bo4e-python-generator==0.0.13",
"bo4e-schema-tool==0.0.9",
"datamodel-code-generator==0.25.9"
]
linting = [
"pylint==4.0.6",
{include-group = "tests"}
"ruff==0.16.0",
]
spell_check = [
"codespell==2.4.3"
Expand All @@ -80,7 +92,6 @@ dev = [
"pre-commit",
{include-group = "tests"},
{include-group = "coverage"},
{include-group = "formatting"},
{include-group = "init_bo4e"},
{include-group = "linting"},
{include-group = "spell_check"},
Expand Down
1 change: 1 addition & 0 deletions src/borm/db/base_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ class MappingBase(DeclarativeBase):
"""
Base class which inherits from DeclarativeBase
"""

metadata = metadata
10 changes: 5 additions & 5 deletions src/borm/db/mysql_db/alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ version_path_separator = os.pathsep # Use os.pathsep. Default configuration use
# on newly generated revision scripts. See the documentation for further
# detail and examples

# format using "black" - use the console_scripts runner, against the "black" entrypoint
hooks = black
black.type = console_scripts
black.entrypoint = black
black.options = -l 120 REVISION_SCRIPT_FILENAME
# format using "ruff format" - use the exec runner, against the "ruff" executable on PATH
hooks = ruff_format
ruff_format.type = exec
ruff_format.executable = ruff
ruff_format.options = format REVISION_SCRIPT_FILENAME

# Logging configuration
[loggers]
Expand Down
2 changes: 1 addition & 1 deletion src/borm/db/mysql_db/auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def get_url() -> str:
port = os.getenv("MYSQL_PORT")
db = os.getenv("MYSQL_DB")
if user is None and password is None and server is None and db is None and port is None:
raise IOError("Could not load .env file.")
raise OSError("Could not load .env file.")
if user is None or password is None or server is None or db is None or port is None:
raise KeyError(
f"Couldn't find all environment variables:\n"
Expand Down
11 changes: 4 additions & 7 deletions src/borm/db/mysql_db/migrations/versions/d73a00baaa17_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@

"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op
from collections.abc import Sequence

# revision identifiers, used by Alembic.
revision: str = "d73a00baaa17"
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
down_revision: str | None = None
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
Expand Down
10 changes: 5 additions & 5 deletions src/borm/db/postgresql_db/alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ version_path_separator = os.pathsep # Use os.pathsep. Default configuration use
# on newly generated revision scripts. See the documentation for further
# detail and examples

# format using "black" - use the console_scripts runner, against the "black" entrypoint
hooks = black
black.type = console_scripts
black.entrypoint = black
black.options = -l 120 REVISION_SCRIPT_FILENAME
# format using "ruff format" - use the exec runner, against the "ruff" executable on PATH
hooks = ruff_format
ruff_format.type = exec
ruff_format.executable = ruff
ruff_format.options = format REVISION_SCRIPT_FILENAME

# Logging configuration
[loggers]
Expand Down
2 changes: 1 addition & 1 deletion src/borm/db/postgresql_db/auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def get_url() -> str:
port = os.getenv("POSTGRES_PORT")
database = os.getenv("POSTGRES_DB")
if user is None and password is None and server is None and database is None and port is None:
raise IOError("Could not load .env file.")
raise OSError("Could not load .env file.")
if user is None or password is None or server is None or database is None or port is None:
raise KeyError(
f"Couldn't find all environment variables:\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@

"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op
from collections.abc import Sequence

# revision identifiers, used by Alembic.
revision: str = "9f7a0a61d21e"
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
down_revision: str | None = None
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
Expand Down
11 changes: 0 additions & 11 deletions tests/.pylintrc

This file was deleted.

2 changes: 1 addition & 1 deletion tests/integrationtests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Generator
from collections.abc import Generator

import pytest
from sqlmodel import Session, SQLModel
Expand Down
Loading
Loading