Skip to content

Commit

Permalink
Add pre-commit configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeru committed Sep 19, 2023
1 parent 3a5479c commit 8fceaf9
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 36 deletions.
8 changes: 0 additions & 8 deletions .flake8

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/lint.yaml

This file was deleted.

10 changes: 10 additions & 0 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,13 @@ jobs:

- name: Upload test coverage to Codecov.io
uses: codecov/codecov-action@v3

pre-commit:
name: Code quality

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: pre-commit/[email protected]
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ rixmp/source/inst/docum/*.html
# pytest and related
.benchmarks
.coverage*
.pytest_cache
.mypy_cache
.pytest_cache
.ruff_cache
*.pid
coverage.xml
htmlcov
Expand Down
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
repos:
- repo: local
hooks:
- id: mypy
name: mypy
always_run: true
require_serial: true
pass_filenames: false

language: python
entry: bash -c ". ${PRE_COMMIT_MYPY_VENV:-/dev/null}/bin/activate 2>/dev/null; mypy $0 $@"
additional_dependencies:
- mypy
- genno
- GitPython
- nbclient
- pytest
- sphinx
- xarray
args: ["."]
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.287
hooks:
- id: ruff
22 changes: 14 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ requires = ["build", "setuptools-scm"]
dynamic = ["version"]
name = "ixmp"
description = "The ix modeling platform"
authors = [
{ name = "IIASA Energy, Climate, and Environment (ECE) program" },
]
authors = [{ name = "IIASA Energy, Climate, and Environment (ECE) program" }]
maintainers = [
{name = "Paul Natsuo Kishimoto", email = "[email protected]"},
{name = "Fridolin Glatter", email = "[email protected]"},
{ name = "Paul Natsuo Kishimoto", email = "[email protected]" },
{ name = "Fridolin Glatter", email = "[email protected]" },
]
readme = "README.md"
classifiers = [
Expand Down Expand Up @@ -75,9 +73,7 @@ tests = [
ixmp = "ixmp.cli:main"

[tool.coverage.report]
omit = [
"ixmp/utils/sphinx_linkcode_github.py",
]
omit = ["ixmp/utils/sphinx_linkcode_github.py"]

[tool.isort]
profile = "black"
Expand Down Expand Up @@ -112,6 +108,16 @@ markers = [
"performance: ixmp performance test.",
]

[tool.ruff]
select = ["C9", "E", "F", "I", "W"]

[tool.ruff.mccabe]
# FIXME the following exceed this limit
# .backend.io.s_read_excel: 26
# .backend.jdbc.JDBCBackend.item_get_elements: 19
# .core.scenario.Scenario.add_set: 17
max-complexity = 15

[tool.setuptools.packages]
find = {}

Expand Down

0 comments on commit 8fceaf9

Please sign in to comment.