Skip to content
Draft
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
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Pre-commit Checks

on:
pull_request:
branches:
- production
- develop
push:
branches:
- production
- develop

jobs:
pre-commit:
runs-on: ubuntu-latest
name: Run pre-commit hooks

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pre-commit

- name: Run pre-commit
run: pre-commit run --all-files --show-diff-on-failure
45 changes: 41 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,43 @@
# Global excludes - apply to all hooks
exclude: ^(build/|dist/|.*\.egg-info/|\.tox/|\.pytest_cache/|\.mypy_cache/|__pycache__/|postprocessing/|open_mastr/soap_api/|scripts/)

repos:
- repo: https://github.com/psf/black
rev: 22.6.0
# Base pre-commit hooks for common issues
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: black
language_version: python3.11
- id: trailing-whitespace
exclude: \.ipynb$
- id: end-of-file-fixer
exclude: \.ipynb$
- id: check-yaml
- id: check-added-large-files
args: ['--maxkb=1000']
- id: check-json
- id: check-toml
- id: check-merge-conflict
- id: debug-statements
- id: check-case-conflict
- id: check-docstring-first
- id: mixed-line-ending
args: ['--fix=lf']

# Ruff - fast, comprehensive linter and formatter (replaces flake8, isort, pylint, pyupgrade, black, pydocstyle)
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.9
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

# mypy - static type checking
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.19.1
hooks:
- id: mypy
additional_dependencies:
- types-requests
- types-PyYAML
- types-tqdm
args: [--ignore-missing-imports, --show-error-codes]
exclude: ^(tests/|scripts/|docs/|postprocessing/)
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ and the versioning aims to respect [Semantic Versioning](http://semver.org/spec/
### Added
- Add partial bulk download
[#652](https://github.com/OpenEnergyPlatform/open-MaStR/pull/652)
- Modernize linting setup and add pre-commit checks in CI
[#671](https://github.com/OpenEnergyPlatform/open-MaStR/pull/671)
### Changed
- Updates the system_catalog dict with missing Einheittyp values
[#653](https://github.com/OpenEnergyPlatform/open-MaStR/pull/653)
Expand Down
27 changes: 24 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ classifiers = [

[project.optional-dependencies]
dev = [
"flake8",
"pylint",
"pytest",
"pytest-dependency",
"xmltodict",
Expand All @@ -59,7 +57,8 @@ dev = [
"mkdocstrings[python]",
"mkdocs-material",
"mkdocs-include-markdown-plugin",
"black",
"ruff",
"mypy",
]

[project.urls]
Expand All @@ -80,3 +79,25 @@ include = ["open_mastr", "open_mastr.soap_api", "open_mastr.soap_api.metadata",

# from setup.py - not yet included in here
# download_url="https://github.com/OpenEnergyPlatform/open-MaStR/archive""/refs/tags/v0.16.0.tar.gz",

[tool.ruff]
line-length = 88
target-version = "py39"

[tool.ruff.lint]
# Enable:
# E - pycodestyle errors
# F - pyflakes
# I - isort (import sorting)
# N - pep8-naming
# W - pycodestyle warnings
# UP - pyupgrade (modernize Python code)
# D - pydocstyle (docstring conventions)
select = ["E", "F", "I", "N", "W", "UP", "D"]
ignore = []

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.ruff.lint.isort]
known-first-party = ["open_mastr"]
Loading