Skip to content

Commit 8228a70

Browse files
committed
Merge branch 'main' into avoid_private_hatch_color
2 parents 6243798 + c3fd9ef commit 8228a70

13 files changed

Lines changed: 112 additions & 87 deletions

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22

33
- [ ] Closes #xxx
44
- [ ] Tests added
5-
- [ ] Passes `isort . && black . && flake8`
65
- [ ] Fully documented, including `CHANGELOG.md`

.github/workflows/upstream-dev-ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
failure()
8585
&& steps.status.outcome == 'failure'
8686
&& github.event_name == 'schedule'
87-
&& github.repository_owner == 'regionmask'
87+
&& github.repository_owner == 'mpytools'
8888
uses: xarray-contrib/issue-from-pytest-log@v1
8989
with:
9090
log-path: output-${{ matrix.python-version }}-log.jsonl

.pre-commit-config.yaml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,14 @@ repos:
88
- id: check-yaml
99
- id: debug-statements
1010
- id: mixed-line-ending
11-
# This wants to go before isort & flake8
12-
- repo: https://github.com/PyCQA/autoflake
13-
rev: "v2.3.1"
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
# Ruff version.
13+
rev: 'v0.12.7'
1414
hooks:
15-
- id: autoflake # isort should run before black as black sometimes tweaks the isort output
16-
args: ["--in-place", "--ignore-init-module-imports"]
17-
- repo: https://github.com/PyCQA/isort
18-
rev: 5.13.2
19-
hooks:
20-
- id: isort
15+
- id: ruff
16+
args: ["--fix", "--show-fixes"]
2117
# https://github.com/python/black#version-control-integration
2218
- repo: https://github.com/psf/black
2319
rev: 24.10.0
2420
hooks:
2521
- id: black
26-
- repo: https://github.com/PyCQA/flake8
27-
rev: 7.1.1
28-
hooks:
29-
- id: flake8

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
- Avoid using the private `_hatch_color` property and use `set_hatchcolor` and `get_hatchcolor` instead in matplotlib
2626
versions where they are available ([#161](https://github.com/mpytools/mplotutils/pull/161)).
27+
- Consolidate package metadata and configuration in *pyproject.toml* ([#165](https://github.com/mpytools/mplotutils/pull/165)).
2728
- Replace deprecated `matplotlib.rcsetup.all_backends` with `matplotlib.backends.backend_registry.list_builtin()`
2829
([#160](https://github.com/mpytools/mplotutils/pull/160)).
2930
- Also upload coverage report in upstream dev CI ([#162](https://github.com/mpytools/mplotutils/pull/162)).

ci/min_deps_check.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import sys
1212
from collections.abc import Iterator
1313
from datetime import datetime
14-
from typing import Optional
1514

1615
import conda.api # type: ignore[import]
1716
import yaml
@@ -30,6 +29,7 @@
3029
"pytest-cov",
3130
"pytest-env",
3231
"pytest-xdist",
32+
"ruff",
3333
}
3434

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

5959

60-
def parse_requirements(fname) -> Iterator[tuple[str, int, int, Optional[int]]]:
60+
def parse_requirements(fname) -> Iterator[tuple[str, int, int, int | None]]:
6161
"""Load requirements/py*-min-all-deps.yml
6262
6363
Yield (package name, major version, minor version, [patch version])
@@ -128,7 +128,7 @@ def metadata(entry):
128128

129129

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

146146
try:

ci/requirements/environment.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ dependencies:
1010
- xarray
1111
# formatting
1212
- black
13-
- isort
14-
- flake8
13+
- ruff
1514
# for testing
1615
- pytest
1716
- pytest-cov

docs/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
- [cartopy](http://scitools.org.uk/cartopy/) (0.23 or later)
77
- [matplotlib](http://matplotlib.org/) (3.9 or later)
88
- [numpy](http://www.numpy.org/) (1.26 or later)
9+
- [xarray](http://xarray.pydata.org/) (2024.7 or later)
910

1011
## Optional dependencies
1112

1213
- [seaborn](https://seaborn.pydata.org/) (0.13 or later)
13-
- [xarray](http://xarray.pydata.org/) (2024.7 or later)
1414

1515
## Instructions
1616

mplotutils/_cartopy_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def yticklabels(
327327
if not y_label_points:
328328
msg = (
329329
"WARN: no points found for ylabel\n"
330-
"y_lim is: {:0.2f} to {:0.2f}".format(y_lim[0], y_lim[1])
330+
f"y_lim is: {y_lim[0]:0.2f} to {y_lim[1]:0.2f}"
331331
)
332332
warnings.warn(msg)
333333

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

mplotutils/_colormaps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _color_palette(cmap, n_colors):
5555
from matplotlib.colors import ListedColormap
5656

5757
colors_i = np.linspace(0, 1.0, n_colors)
58-
if isinstance(cmap, (list, tuple)):
58+
if isinstance(cmap, list | tuple):
5959
# expand or truncate the list of colors to n_colors
6060
cmap = list(itertools.islice(itertools.cycle(cmap), n_colors))
6161
cmap = ListedColormap(cmap)

pyproject.toml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,68 @@
1+
[project]
2+
name = "mplotutils"
3+
authors = [{name = "mplotutils developers", email = "mathias.hauser@env.ethz.com"}]
4+
license = "GPL-3.0-only"
5+
keywords = ['matplotlib cartopy plotting']
6+
description = "utilities for matplotlib and cartopy"
7+
classifiers = [
8+
"Development Status :: 5 - Production/Stable",
9+
"Operating System :: OS Independent",
10+
"Intended Audience :: Science/Research",
11+
"Programming Language :: Python",
12+
"Programming Language :: Python :: 3",
13+
"Programming Language :: Python :: 3.11",
14+
"Programming Language :: Python :: 3.12",
15+
"Programming Language :: Python :: 3.13",
16+
"Topic :: Scientific/Engineering",
17+
"Topic :: Scientific/Engineering :: Atmospheric Science",
18+
"Topic :: Scientific/Engineering :: GIS",
19+
]
20+
requires-python = ">=3.11"
21+
dependencies = [
22+
"cartopy >=0.23",
23+
"matplotlib >=3.9",
24+
"packaging >= 23.1",
25+
"numpy >=1.26",
26+
"xarray >=2024.7",
27+
]
28+
dynamic = ["version"]
29+
30+
[project.readme]
31+
file = "README.md"
32+
content-type = "text/markdown"
33+
34+
[project.urls]
35+
Homepage = "https://github.com/mpytools/mplotutils"
36+
Documentation = "https://github.com/mpytools/mplotutils"
37+
Source = "https://github.com/mpytools/mplotutils"
38+
BugReports = "https://github.com/mpytools/mplotutils/issues"
39+
40+
[project.optional-dependencies]
41+
full = [
42+
"seaborn",
43+
]
44+
45+
[dependency-groups]
46+
# docs = [
47+
# "mplotutils[full]",
48+
# dependencies to build the docs
49+
# "numpydoc",
50+
# "sphinx",
51+
# ]
52+
tests = [
53+
"pytest-cov",
54+
"pytest-xdist",
55+
"pytest",
56+
]
57+
dev = [
58+
"regionmask[full, tests]", # docs
59+
"black !=23",
60+
"ruff",
61+
]
62+
63+
[tool.setuptools.packages]
64+
find = {namespaces = false} # Disable implicit namespaces
65+
166
[build-system]
267
requires = [
368
"setuptools>=42",
@@ -9,10 +74,41 @@ build-backend = "setuptools.build_meta"
974
fallback_version = "999"
1075
version_scheme = "no-guess-dev"
1176

77+
78+
[tool.ruff]
79+
# also check notebooks
80+
extend-include = ["*.ipynb"]
81+
target-version = "py310"
82+
83+
[tool.ruff.lint]
84+
# E402: module level import not at top of file
85+
# E501: line too long - let the formatter worry about this
86+
# E731: do not assign a lambda expression, use a def
87+
ignore = [
88+
"E402",
89+
"E501",
90+
"E731",
91+
]
92+
select = [
93+
"F", # Pyflakes
94+
"E", # Pycodestyle
95+
"W", # warnings
96+
"I", # isort
97+
"UP", # Pyupgrade
98+
]
99+
100+
[tool.ruff.lint.isort]
101+
known-first-party = ["mplotutils"]
102+
12103
[tool.pytest.ini_options]
13104

14105
log_cli_level = "INFO"
15106

16107
filterwarnings = [
17108
"ignore:numpy.ufunc size changed, may indicate binary incompatibility.:RuntimeWarning"
18109
]
110+
111+
[tool.coverage.run]
112+
omit = [
113+
"*/mplotutils/tests/*",
114+
]

0 commit comments

Comments
 (0)