Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

- [ ] Closes #xxx
- [ ] Tests added
- [ ] Passes `isort . && black . && flake8`
- [ ] Fully documented, including `CHANGELOG.md`
18 changes: 5 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,14 @@ repos:
- id: check-yaml
- id: debug-statements
- id: mixed-line-ending
# This wants to go before isort & flake8
- repo: https://github.com/PyCQA/autoflake
rev: "v2.3.1"
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.12.7'
hooks:
- id: autoflake # isort should run before black as black sometimes tweaks the isort output
args: ["--in-place", "--ignore-init-module-imports"]
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- id: ruff
args: ["--fix", "--show-fixes"]
# https://github.com/python/black#version-control-integration
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
8 changes: 4 additions & 4 deletions ci/min_deps_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import sys
from collections.abc import Iterator
from datetime import datetime
from typing import Optional

import conda.api # type: ignore[import]
import yaml
Expand All @@ -30,6 +29,7 @@
"pytest-cov",
"pytest-env",
"pytest-xdist",
"ruff",
}

POLICY_MONTHS = {"python": 24, "numpy": 18, "setuptools": 42}
Expand Down Expand Up @@ -57,7 +57,7 @@ def warning(msg: str) -> None:
print("WARNING:", msg)


def parse_requirements(fname) -> Iterator[tuple[str, int, int, Optional[int]]]:
def parse_requirements(fname) -> Iterator[tuple[str, int, int, int | None]]:
"""Load requirements/py*-min-all-deps.yml

Yield (package name, major version, minor version, [patch version])
Expand Down Expand Up @@ -128,7 +128,7 @@ def metadata(entry):


def process_pkg(
pkg: str, req_major: int, req_minor: int, req_patch: Optional[int]
pkg: str, req_major: int, req_minor: int, req_patch: int | None
) -> tuple[str, str, str, str, str, str]:
"""Compare package version from requirements file to available versions in conda.
Return row to build pandas dataframe:
Expand All @@ -140,7 +140,7 @@ def process_pkg(
- publication date of version suggested by policy (YYYY-MM-DD)
- status ("<", "=", "> (!)")
"""
print("Analyzing %s..." % pkg)
print(f"Analyzing {pkg}...")
versions = query_conda(pkg)

try:
Expand Down
3 changes: 1 addition & 2 deletions ci/requirements/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ dependencies:
- xarray
# formatting
- black
- isort
- flake8
- ruff
# for testing
- pytest
- pytest-cov
4 changes: 2 additions & 2 deletions mplotutils/_cartopy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def yticklabels(
if not y_label_points:
msg = (
"WARN: no points found for ylabel\n"
"y_lim is: {:0.2f} to {:0.2f}".format(y_lim[0], y_lim[1])
f"y_lim is: {y_lim[0]:0.2f} to {y_lim[1]:0.2f}"
)
warnings.warn(msg)

Expand Down Expand Up @@ -427,7 +427,7 @@ def xticklabels(
if not x_label_points:
msg = (
"WARN: no points found for xlabel\n"
"x_lim is: {:0.2f} to {:0.2f}".format(x_lim[0], x_lim[1])
f"x_lim is: {x_lim[0]:0.2f} to {x_lim[1]:0.2f}"
)
warnings.warn(msg)

Expand Down
2 changes: 1 addition & 1 deletion mplotutils/_colormaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _color_palette(cmap, n_colors):
from matplotlib.colors import ListedColormap

colors_i = np.linspace(0, 1.0, n_colors)
if isinstance(cmap, (list, tuple)):
if isinstance(cmap, list | tuple):
# expand or truncate the list of colors to n_colors
cmap = list(itertools.islice(itertools.cycle(cmap), n_colors))
cmap = ListedColormap(cmap)
Expand Down
26 changes: 26 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,32 @@ build-backend = "setuptools.build_meta"
fallback_version = "999"
version_scheme = "no-guess-dev"


[tool.ruff]
# also check notebooks
extend-include = ["*.ipynb"]
target-version = "py310"

[tool.ruff.lint]
# E402: module level import not at top of file
# E501: line too long - let the formatter worry about this
# E731: do not assign a lambda expression, use a def
ignore = [
"E402",
"E501",
"E731",
]
select = [
"F", # Pyflakes
"E", # Pycodestyle
"W", # warnings
"I", # isort
"UP", # Pyupgrade
]

[tool.ruff.lint.isort]
known-first-party = ["mplotutils"]

[tool.pytest.ini_options]

log_cli_level = "INFO"
Expand Down
17 changes: 0 additions & 17 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,6 @@ install_requires =
numpy >=1.26
xarray >=2024.7

[flake8]
ignore=
# E203: whitespace before ':' - doesn't work well with black
# E402: module level import not at top of file
# E501: line too long - let black worry about that
# E731: do not assign a lambda expression, use a def
# W503: line break before binary operator
E203, E402, E501, E731, W503
exclude =
build
docs
.git

[isort]
profile = black
known_first_party = mplotutils

[coverage:run]
omit =
*/tests/*,
Loading