Skip to content

Commit

Permalink
remove black/isort formatter for code base, enable a few checks in pr…
Browse files Browse the repository at this point in the history
…e-commit-hooks, remove nbqa hook
  • Loading branch information
Zeitsperre committed Feb 18, 2025
1 parent cc69858 commit 3803fba
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 33 deletions.
20 changes: 7 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
exclude: '.ipynb|.github/publish-mastodon-template.md'
- id: fix-byte-order-marker
- id: name-tests-test
args: [ '--pytest-test-first' ]
- id: no-commit-to-branch
args: [ '--branch', 'main' ]
- id: check-merge-conflict
- id: check-json
- id: check-toml
- id: check-yaml
Expand All @@ -32,10 +38,6 @@ repos:
hooks:
- id: yamllint
args: [ '--config-file=.yamllint.yaml' ]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.1.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.6
hooks:
Expand All @@ -56,14 +58,6 @@ repos:
rev: 'v2.14'
hooks:
- id: vulture
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.9.1
hooks:
- id: nbqa-pyupgrade
args: [ '--py310-plus' ]
additional_dependencies: [ 'pyupgrade==3.19.1' ]
- id: nbqa-black
additional_dependencies: [ 'black==25.1.0' ]
- repo: https://github.com/kynan/nbstripout
rev: 0.8.1
hooks:
Expand Down Expand Up @@ -92,7 +86,7 @@ repos:
- id: blackdoc
additional_dependencies: [ 'black==25.1.0' ]
exclude: '(src/xclim/indices/__init__.py|docs/installation.rst)'
- id: blackdoc-autoupdate-black
# - id: blackdoc-autoupdate-black
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ clean-test: ## remove test and coverage artifacts
rm -fr .pytest_cache

lint: ## check style with flake8 and black
python -m black --check src/xclim tests
python -m ruff check src/xclim tests
python -m flake8 --config=.flake8 src/xclim tests
python -m vulture src/xclim tests
python -m nbqa black --check docs
python -m blackdoc --check --exclude=src/xclim/indices/__init__.py src/xclim
python -m blackdoc --check docs
codespell src/xclim tests docs
Expand Down
10 changes: 3 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ xclim: Climate services library |logo| |logo-dark| |logo-light|
+----------------------------+-----------------------------------------------------+
| Open Source | |license| |ossf-score| |zenodo| |pyOpenSci| |joss| |
+----------------------------+-----------------------------------------------------+
| Coding Standards | |black| |ruff| |pre-commit| |ossf-bp| |fossa| |
| Coding Standards | |ruff| |pre-commit| |ossf-bp| |fossa| |
+----------------------------+-----------------------------------------------------+
| Development Status | |status| |build| |coveralls| |
+----------------------------+-----------------------------------------------------+
Expand Down Expand Up @@ -68,13 +68,13 @@ Conventions
-----------
In order to provide a coherent interface, `xclim` tries to follow different sets of conventions. In particular, input data should follow the `CF conventions`_ whenever possible for variable attributes. Variable names are usually the ones used in `CMIP6`_, when they exist.

However, xclim will *always* assume the temporal coordinate is named "time". If your data uses another name (for example: "T"), you can rename the variable with:
However, `xclim` will *always* assume the temporal coordinate is named "time". If your data uses another name (for example: "T"), you can rename the variable with:

.. code-block:: python
ds = ds.rename(T="time")
`xclim` code uses the `black`_ formatter, a modified `ruff`_ linting configuration, and (mostly) adheres to the `NumPy docstring`_ style. For more information on coding and development conventions, see the `Contributing Guidelines`_.
`xclim` employs `black`_-like code formatting style, a modified `ruff`_ linting configuration, and (mostly) adheres to the `NumPy docstring`_ style. For more information on coding and development conventions, see the `Contributing Guidelines`_.

.. _black: https://black.readthedocs.io/en/stable/
.. _ruff: https://docs.astral.sh/ruff/
Expand Down Expand Up @@ -191,10 +191,6 @@ This package was created with Cookiecutter_ and the `audreyfeldroy/cookiecutter-
:target: https://app.fossa.com/projects/git%2Bgithub.com%2FOuranosinc%2Fxclim?ref=badge_shield
:alt: FOSSA

.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
:alt: Python Black

.. |logo| image:: https://raw.githubusercontent.com/Ouranosinc/xclim/main/docs/logos/xclim-logo-small-light.png
:target: https://github.com/Ouranosinc/xclim
:alt: Xclim
Expand Down
3 changes: 1 addition & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ dependencies:
- lmoments3 >=1.0.7 # Required for some Jupyter notebooks
- pot >=0.9.4
# Testing and development dependencies
- black =25.1.0
- blackdoc =0.3.9
- bump-my-version >=0.28.1
- bump-my-version >=0.32.1
- cairosvg >=2.6.0
- codespell >=2.4.1
- coverage >=7.5.0
Expand Down
8 changes: 3 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ dependencies = [
[project.optional-dependencies]
dev = [
# Dev tools and testing
"black[jupyter] ==25.1.0",
"blackdoc ==0.3.9",
"bump-my-version ==0.32.1",
"codespell ==2.4.1",
Expand All @@ -82,7 +81,7 @@ dev = [
"pytest-cov >=5.0.0",
"pytest-socket >=0.6.0",
"pytest-xdist[psutil] >=3.2",
"ruff >=0.7.0",
"ruff >=0.9.6",
"tokenize-rt >=5.2.0",
"tox >=4.21.2",
"tox-gh >=1.4.4",
Expand Down Expand Up @@ -308,9 +307,9 @@ xfail_strict = true
src = ["xclim"]
line-length = 150
exclude = [
".eggs",
".git",
"build",
".eggs"
"build"
]
extend-include = [
"*.ipynb" # Include notebooks
Expand Down Expand Up @@ -364,7 +363,6 @@ case-sensitive = true
detect-same-package = false
known-first-party = ["xclim"]
no-lines-before = ["future"]
required-imports = ["from __future__ import annotations"]

[tool.ruff.lint.mccabe]
max-complexity = 20
Expand Down
6 changes: 3 additions & 3 deletions tests/test_cffwis.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ def test_fire_weather_ufunc_errors(

snd = xr.full_like(tas, 0)
lat = xr.full_like(tas.isel(time=0), 45)
DC0 = xr.full_like(tas.isel(time=0), np.nan) # noqa
DMC0 = xr.full_like(tas.isel(time=0), np.nan) # noqa
FFMC0 = xr.full_like(tas.isel(time=0), np.nan) # noqa
DC0 = xr.full_like(tas.isel(time=0), np.nan)
DMC0 = xr.full_like(tas.isel(time=0), np.nan)
FFMC0 = xr.full_like(tas.isel(time=0), np.nan)

# Test invalid combination
with pytest.raises(TypeError):
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ description = Run code quality compliance tests under {basepython}
skip_install = True
extras =
deps =
black[jupyter] ==25.1.0
blackdoc ==0.3.9
codespell >=2.4.1
deptry >=0.23.0
Expand Down

0 comments on commit 3803fba

Please sign in to comment.