From 761a5984630e05b86d069193e72c2332f8132fe9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 20:31:43 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v3.15.0 → v3.15.2](https://github.com/asottile/pyupgrade/compare/v3.15.0...v3.15.2) - [github.com/astral-sh/ruff-pre-commit: v0.1.9 → v0.3.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.9...v0.3.5) - [github.com/psf/black-pre-commit-mirror: 23.12.1 → 24.3.0](https://github.com/psf/black-pre-commit-mirror/compare/23.12.1...24.3.0) - [github.com/nbQA-dev/nbQA: 1.7.1 → 1.8.5](https://github.com/nbQA-dev/nbQA/compare/1.7.1...1.8.5) - [github.com/abravalheri/validate-pyproject: v0.15 → v0.16](https://github.com/abravalheri/validate-pyproject/compare/v0.15...v0.16) --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 47ba8a26..44b73189 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,20 +3,20 @@ ci: repos: - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 + rev: v3.15.2 hooks: - id: pyupgrade args: ["--py39-plus"] - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.1.9' + rev: 'v0.3.5' hooks: - id: ruff args: ["--show-fixes", "--fix"] - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.12.1 + rev: 24.3.0 hooks: - id: black @@ -36,7 +36,7 @@ repos: - mdformat-myst - repo: https://github.com/nbQA-dev/nbQA - rev: 1.7.1 + rev: 1.8.5 hooks: - id: nbqa-black - id: nbqa-ruff @@ -67,7 +67,7 @@ repos: - id: validate-cff - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.15 + rev: v0.16 hooks: - id: validate-pyproject From 41d850a663e6f6b9bdacd461c1c6ea38dd0c1fa8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 20:32:29 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- cf_xarray/accessor.py | 6 ++---- cf_xarray/coding.py | 1 + cf_xarray/formatting.py | 8 +++++--- cf_xarray/tests/test_accessor.py | 6 +++--- cf_xarray/units.py | 1 + 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/cf_xarray/accessor.py b/cf_xarray/accessor.py index a10c4886..5dd71a52 100644 --- a/cf_xarray/accessor.py +++ b/cf_xarray/accessor.py @@ -721,8 +721,7 @@ def _getitem( accessor: CFAccessor, key: Hashable, skip: list[Literal["coords", "measures"]] | None = None, -) -> DataArray: - ... +) -> DataArray: ... @overload @@ -730,8 +729,7 @@ def _getitem( accessor: CFAccessor, key: Iterable[Hashable], skip: list[Literal["coords", "measures"]] | None = None, -) -> Dataset: - ... +) -> Dataset: ... def _getitem( diff --git a/cf_xarray/coding.py b/cf_xarray/coding.py index 529db1f2..282eaf8f 100644 --- a/cf_xarray/coding.py +++ b/cf_xarray/coding.py @@ -1,6 +1,7 @@ """ Encoders and decoders for CF conventions not implemented by Xarray. """ + import numpy as np import pandas as pd import xarray as xr diff --git a/cf_xarray/formatting.py b/cf_xarray/formatting.py index bd5430e4..f99e95bc 100644 --- a/cf_xarray/formatting.py +++ b/cf_xarray/formatting.py @@ -110,9 +110,11 @@ def _print_rows(subtitle: str, rows: list[str], rich: bool): # Add subtitle to the first row, align other rows rows = [ - _format_subtitle(subtitle, rich=rich) + row - if i == 0 - else len(subtitle) * " " + row + ( + _format_subtitle(subtitle, rich=rich) + row + if i == 0 + else len(subtitle) * " " + row + ) for i, row in enumerate(rows) ] diff --git a/cf_xarray/tests/test_accessor.py b/cf_xarray/tests/test_accessor.py index 60a68114..147e9686 100644 --- a/cf_xarray/tests/test_accessor.py +++ b/cf_xarray/tests/test_accessor.py @@ -1454,9 +1454,9 @@ def test_rename(obj): "air_temperature" if isinstance(obj, Dataset) else "longitude": "renamed" } xr_dict = { - "air" - if isinstance(obj, Dataset) and "air" in obj.data_vars - else "lon": "renamed" + ( + "air" if isinstance(obj, Dataset) and "air" in obj.data_vars else "lon" + ): "renamed" } assert_identical(obj.rename(xr_dict), obj.cf.rename(cf_dict)) assert_identical(obj.rename(**xr_dict), obj.cf.rename(**cf_dict)) diff --git a/cf_xarray/units.py b/cf_xarray/units.py index dea7d6b5..1ec75cbb 100644 --- a/cf_xarray/units.py +++ b/cf_xarray/units.py @@ -1,4 +1,5 @@ """Module to provide unit support via pint approximating UDUNITS/CF.""" + import functools import re