Skip to content

Commit

Permalink
Migrate to ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
tukiains committed Nov 9, 2023
1 parent fc95a3e commit 4a2da45
Show file tree
Hide file tree
Showing 11 changed files with 227 additions and 110 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: RpgPy CI

on: [push]
on: [push, pull_request]

jobs:
build:
Expand Down Expand Up @@ -28,12 +28,10 @@ jobs:
run: |
python3 -m pip install .[test]
python3 setup.py build_ext --inplace
- name: Lint with pylint
- name: Run pre-commit checks
if: startsWith(matrix.os, 'ubuntu-')
run: |
pylint rpgpy/ tests/
- name: Typecheck with mypy
run: |
mypy rpgpy/ tests/
pre-commit run --all-files --show-diff-on-failure
- name: Test with pytest
run: |
pytest --flake-finder tests/unit/ --flake-runs=2
Expand Down
22 changes: 7 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-case-conflict
- id: check-executables-have-shebangs
Expand All @@ -11,23 +11,15 @@ repos:
- id: mixed-line-ending
args: ["--fix", "lf"]
- id: trailing-whitespace
- repo: https://github.com/pycqa/isort
rev: 5.12.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.5
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
- id: ruff
args: ["--fix"]
- id: ruff-format

- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
require_serial: true
args: ["--jobs=4"]
- id: mypy
name: mypy
entry: mypy
Expand Down
39 changes: 11 additions & 28 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,23 @@ Homepage = "https://github.com/actris-cloudnet/rpgpy"
Repository = "https://github.com/actris-cloudnet/rpgpy"
Changelog = "https://github.com/actris-cloudnet/rpgpy/blob/main/CHANGELOG.md"

[tool.setuptools.dynamic]
version = {attr = "rpgpy.version.__version__"}
[tool.mypy]
check_untyped_defs = true

[[tool.mypy.overrides]]
module = ["Cython.Build", "setuptools", "netCDF4", "numba", "rpgpy.data"]
ignore_missing_imports = true

[tool.black]
line-length = 100

[tool.isort]
profile = "black"
line_length = 100

[tool.pylint]
max-line-length = 100
ignored-modules = ["netCDF4"]
disable = [
"missing-module-docstring",
"missing-class-docstring",
"missing-function-docstring",
"too-many-statements",
"invalid-name",
"too-many-branches",
"import-error",
"too-many-nested-blocks",
"logging-fstring-interpolation",
"too-many-locals",
"cyclic-import",
"duplicate-code",
"too-few-public-methods",
]

[tool.release-version]
filename = "rpgpy/version.py"
pattern = ["MAJOR = (?P<major>\\d+)", "MINOR = (?P<minor>\\d+)", "PATCH = (?P<patch>\\d+)"]
changelog = "CHANGELOG.md"

[tool.ruff]
extend-select = ["I"]

[tool.ruff.lint.extend-per-file-ignores]
"__init__.py" = ["F401"]

[tool.setuptools.dynamic]
version = {attr = "rpgpy.version.__version__"}
14 changes: 12 additions & 2 deletions rpgpy/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ def read(*fields):
header["CustName"] = _read_string(file)

if version > 1.0:
read(("Freq", "f"), ("AntSep", "f"), ("AntDia", "f"), ("AntG", "f"), ("HPBW", "f"))
read(
("Freq", "f"),
("AntSep", "f"),
("AntDia", "f"),
("AntG", "f"),
("HPBW", "f"),
)

if level == 0:
read(("Cr", "f"))
Expand All @@ -72,7 +78,11 @@ def read(*fields):

n_levels, n_temp, n_humidity, n_chirp = _get_number_of_levels(header)

read(("RAlts", _dim(n_levels)), ("TAlts", _dim(n_temp)), ("HAlts", _dim(n_humidity)))
read(
("RAlts", _dim(n_levels)),
("TAlts", _dim(n_temp)),
("HAlts", _dim(n_humidity)),
)

if level == 0:
read(("Fr", _dim(n_levels)))
Expand Down
Loading

0 comments on commit 4a2da45

Please sign in to comment.