Skip to content

Commit 5939971

Browse files
committed
Use Ruff instead of other lint/formatting tools
1 parent b0ef8b6 commit 5939971

11 files changed

Lines changed: 46 additions & 77 deletions

File tree

.pre-commit-config.yaml

Lines changed: 12 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,14 @@
1+
ci:
2+
autoupdate_schedule: quarterly
13
repos:
2-
- repo: https://github.com/psf/black
3-
rev: 23.12.1
4-
hooks:
5-
- id: black
6-
name: black
7-
description: "Black: The uncompromising Python code formatter"
8-
entry: black
9-
language: python
10-
language_version: python3
11-
minimum_pre_commit_version: 2.9.2
12-
require_serial: true
13-
types_or: [python, pyi]
14-
- id: black-jupyter
15-
name: black-jupyter
16-
description:
17-
"Black: The uncompromising Python code formatter (with Jupyter Notebook support)"
18-
entry: black
19-
language: python
20-
minimum_pre_commit_version: 2.9.2
21-
require_serial: true
22-
types_or: [python, pyi, jupyter]
23-
additional_dependencies: [".[jupyter]"]
24-
25-
- repo: https://github.com/pycqa/flake8
26-
rev: 7.0.0
27-
hooks:
28-
- id: flake8
29-
additional_dependencies:
30-
- flake8-bugbear
31-
- flake8-comprehensions
32-
- flake8-simplify
33-
34-
- repo: https://gitlab.com/kennon.mckeever/nbhooks
35-
rev: 1.0.1
36-
hooks:
37-
- id: nb-ensure-clean
38-
name: nb-ensure-clean
39-
description: Ensure that committed Jupyter notebooks contain no outputs.
40-
entry: nb-ensure-clean
41-
files: \.ipynb$
42-
language: python
43-
44-
- repo: https://github.com/asottile/pyupgrade
45-
rev: v3.15.0
46-
hooks:
47-
- id: pyupgrade
48-
args: [--py310-plus]
49-
50-
- repo: https://github.com/asottile/reorder-python-imports
51-
rev: v3.12.0
52-
hooks:
53-
- id: reorder-python-imports
54-
args: [--py310-plus, --add-import, "from __future__ import annotations"]
4+
- repo: https://github.com/astral-sh/ruff-pre-commit
5+
rev: v0.8.1
6+
hooks:
7+
# Run the linter
8+
- id: ruff
9+
args: [ --fix ]
10+
# Run the formatter
11+
- id: ruff-format
5512

5613
- repo: https://github.com/pre-commit/pre-commit-hooks
5714
rev: v4.5.0
@@ -75,20 +32,10 @@ repos:
7532
.gitignore
7633
)
7734
78-
- repo: https://github.com/PyCQA/pydocstyle
79-
rev: 6.3.0
80-
hooks:
81-
- id: pydocstyle
82-
files: bmipy/.*\.py$
83-
args:
84-
- --convention=numpy
85-
- --add-select=D417
86-
additional_dependencies: [".[toml]"]
87-
8835
- repo: https://github.com/pre-commit/mirrors-mypy
8936
rev: v1.8.0
9037
hooks:
9138
- id: mypy
92-
language_version: python3.12
93-
additional_dependencies: [types-all]
39+
#language_version: python3.12
40+
#additional_dependencies: [types-all]
9441
files: src/.*\.py$

noxfile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Nox configuration."""
2+
13
from __future__ import annotations
24

35
import os

pyproject.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,29 @@ where = [
6565
[tool.coverage.run]
6666
relative_files = true
6767

68+
[tool.ruff.lint]
69+
select = [
70+
"B", # flake8-bugbear
71+
"C4", # flake8-comprehensions
72+
"C90", # mccabe
73+
"D", # pydocstyle
74+
"E", "W", # pycodestyle
75+
"F", # Pyflakes
76+
"FA", # flake8-future-annotations
77+
"I", # isort
78+
# "SIM", # flake8-simplify
79+
"UP", # pyupgrade
80+
]
81+
82+
[tool.ruff.lint.per-file-ignores]
83+
"tests/**.py" = ["D"]
84+
85+
[tool.ruff.lint.mccabe]
86+
max-complexity = 18
87+
88+
[tool.ruff.lint.pydocstyle]
89+
convention = "numpy"
90+
6891
[tool.mypy]
6992
check_untyped_defs = true
7093
disallow_any_generics = true

setup.cfg

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/bmipy/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""The Basic Model Interface (BMI) for Python."""
2+
23
from __future__ import annotations
34

45
from bmipy._version import __version__

src/bmipy/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""The bmipy-render command."""
2+
23
from __future__ import annotations
34

45
from bmipy._cmd import main

src/bmipy/_cmd.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Command line interface that create template BMI implementations."""
2+
23
from __future__ import annotations
34

45
import argparse

src/bmipy/_template.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
import os
55
import re
66
import textwrap
7-
from collections import defaultdict
8-
from collections import OrderedDict
7+
from collections import OrderedDict, defaultdict
98

109
from bmipy.bmi import Bmi
1110

src/bmipy/bmi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
This language specification is derived from the Scientific Interface
44
Definition Language (SIDL) file `bmi.sidl <https://github.com/csdms/bmi>`_.
55
"""
6+
67
from __future__ import annotations
78

8-
from abc import ABC
9-
from abc import abstractmethod
9+
from abc import ABC, abstractmethod
1010
from typing import Any
1111

1212
import numpy as np

tests/cli_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import pytest
4+
45
from bmipy._cmd import main
56

67

0 commit comments

Comments
 (0)