Skip to content

Commit

Permalink
Update Linters (#359)
Browse files Browse the repository at this point in the history
* Update Linters

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update conf.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update conf.py

* Update __init__.py

* Update whats-new.rst

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
jbusecke and pre-commit-ci[bot] committed Jun 25, 2024
1 parent aff6659 commit 2536bf9
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 60 deletions.
65 changes: 21 additions & 44 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,22 @@
repos:

# Ill leave this for later. This will take a while to get up to speed.
# - repo: https://github.com/econchick/interrogate
# rev: 1.3.2
# hooks:
# - id: interrogate
# exclude: ^(docs|setup.py|tests|xmip/_version.py|xmip/__init__.py)
# args: [--config=pyproject.toml]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude: tests/data
- id: check-ast
- id: debug-statements
- id: end-of-file-fixer
- id: check-docstring-first
- id: requirements-txt-fixer
- id: file-contents-sorter
files: requirements-dev.txt

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
ci:
autoupdate_schedule: quarterly
autofix_prs: true

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
additional_dependencies: [toml]
args: [--project=xmip, --multi-line=3, --lines-after-imports=2, --lines-between-types=1, --trailing-comma, --force-grid-wrap=0, --use-parentheses, --line-width=88]

- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config

- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
- id: black
language_version: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-toml
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
os.environ["PYTHONPATH"] = str(root)
sys.path.insert(0, str(root))

import xmip # isort:skip
from importlib.metadata import version # isort:skip
import xmip # noqa
from importlib.metadata import version # noqa

release = version("xmip")
# for example take major/minor/patch
Expand Down
9 changes: 9 additions & 0 deletions docs/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

What's New
===========
.. _whats-new.0.8.0:

v0.8.0 (unreleased)
-------------------

Internal Changes
~~~~~~~~~~~~~~~~
- Updated pre-commit linting to use ruff (:pull:`359`). By `Julius Busecke <https://github.com/jbusecke>`

.. _whats-new.0.7.2:

v0.7.2 (unreleased)
Expand Down
14 changes: 4 additions & 10 deletions xmip/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
try:
from importlib.metadata import ( # only works for python 3.8 and upwards
PackageNotFoundError,
version,
)
except:
from importlib_metadata import ( # works for python <3.8
PackageNotFoundError,
version,
)
from importlib.metadata import ( # only works for python 3.8 and upwards
PackageNotFoundError,
version,
)

try:
__version__ = version("xmip")
Expand Down
2 changes: 1 addition & 1 deletion xmip/drift_removal.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def calculate_drift(
# Check if the parent member id matches
match_attrs = ["source_id", "variant_label"]
for ma in match_attrs:
if not ds.attrs[f"parent_{ma}"] in reference.attrs[ma]:
if ds.attrs[f"parent_{ma}"] not in reference.attrs[ma]:
raise ValueError(
f'`ds_parent` {ma} ({reference.attrs[ma]}) not compatible with `ds` parent_{ma} ({ds.attrs[f"parent_{ma}"]})'
)
Expand Down
4 changes: 1 addition & 3 deletions xmip/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,7 @@ def _interpolate_combine_func(
print(gl)
source_grid = [
dss for dss in ds_list if dss.attrs["grid_label"] == gl
][
0
] # again just take the first one available
][0] # again just take the first one available
regridder_dict[gl] = _clean_regridder(
source_grid, target_grid, method, **xesmf_kwargs
)
Expand Down

0 comments on commit 2536bf9

Please sign in to comment.