Skip to content

Commit

Permalink
Update and fix linters (rstcheck,mypy,pre-commit) (xarray-contrib#387)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/PyCQA/isort: 5.10.1 → 5.11.4](PyCQA/isort@5.10.1...5.11.4)
- [github.com/psf/black: 22.8.0 → 22.12.0](psf/black@22.8.0...22.12.0)
- [github.com/PyCQA/flake8: 5.0.4 → 6.0.0](PyCQA/flake8@5.0.4...6.0.0)
- [github.com/pre-commit/mirrors-mypy: v0.981 → v0.991](pre-commit/mirrors-mypy@v0.981...v0.991)
- [github.com/rstcheck/rstcheck: v5.0.0 → v6.1.1](rstcheck/rstcheck@v5.0.0...v6.1.1)
- [github.com/nbQA-dev/nbQA: 1.5.2 → 1.6.0](nbQA-dev/nbQA@1.5.2...1.6.0)
- [github.com/asottile/pyupgrade: v2.38.2 → v3.3.1](asottile/pyupgrade@v2.38.2...v3.3.1)
- [github.com/pre-commit/pre-commit-hooks: v4.3.0 → v4.4.0](pre-commit/pre-commit-hooks@v4.3.0...v4.4.0)
- [github.com/keewis/blackdoc: v0.3.7 → v0.3.8](keewis/blackdoc@v0.3.7...v0.3.8)

* Explicit None typing

* Fix rstcheck

* Update typnig

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Deepak Cherian <[email protected]>
Co-authored-by: dcherian <[email protected]>
  • Loading branch information
3 people authored Jan 15, 2023
1 parent 1b373a2 commit 3407d29
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@ ci:

repos:
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.11.4
hooks:
- id: isort
files: .+\.py$

- repo: https://github.com/psf/black
rev: 22.8.0
rev: 22.12.0
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
rev: 6.0.0
hooks:
- id: flake8

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.981
rev: v0.991
hooks:
- id: mypy
additional_dependencies: [types-all]

- repo: https://github.com/rstcheck/rstcheck
rev: v5.0.0
rev: v6.1.1
hooks:
- id: rstcheck
additional_dependencies: [sphinx]
Expand All @@ -39,7 +39,7 @@ repos:
- mdformat-myst

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.5.2
rev: 1.6.0
hooks:
- id: nbqa-black
- id: nbqa-pyupgrade
Expand All @@ -52,22 +52,22 @@ repos:
additional_dependencies: [mdformat==0.7.14]

- repo: https://github.com/asottile/pyupgrade
rev: v2.38.2
rev: v3.3.1
hooks:
- id: pyupgrade
args:
- "--py37-plus"

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-toml
- id: check-yaml

- repo: https://github.com/keewis/blackdoc
rev: v0.3.7
rev: v0.3.8
hooks:
- id: blackdoc
files: .+\.py$
14 changes: 7 additions & 7 deletions cf_xarray/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def _getattr(
accessor: CFAccessor,
key_mappers: Mapping[str, Mapper],
wrap_classes: bool = False,
extra_decorator: Callable = None,
extra_decorator: Callable | None = None,
):
"""
Common getattr functionality.
Expand Down Expand Up @@ -613,7 +613,7 @@ def wrapper(*args, **kwargs):


def _getitem(
accessor: CFAccessor, key: str | list[str], skip: list[str] = None
accessor: CFAccessor, key: str | list[str], skip: list[str] | None = None
) -> DataArray | Dataset:
"""
Index into obj using key. Attaches CF associated variables.
Expand Down Expand Up @@ -1081,12 +1081,12 @@ def curvefit(
self,
coords: str | DataArray | Iterable[str | DataArray],
func: Callable[..., Any],
reduce_dims: Hashable | Iterable[Hashable] = None,
reduce_dims: Hashable | Iterable[Hashable] | None = None,
skipna: bool = True,
p0: dict[str, Any] = None,
bounds: dict[str, Any] = None,
param_names: Sequence[str] = None,
kwargs: dict[str, Any] = None,
p0: dict[str, Any] | None = None,
bounds: dict[str, Any] | None = None,
param_names: Sequence[str] | None = None,
kwargs: dict[str, Any] | None = None,
):

if coords is not None:
Expand Down
8 changes: 5 additions & 3 deletions cf_xarray/geometry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import Sequence, Union
from __future__ import annotations

from typing import Sequence

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -69,7 +71,7 @@ def reshape_unique_geometries(
return out


def shapely_to_cf(geometries: Union[xr.DataArray, Sequence], grid_mapping: str = None):
def shapely_to_cf(geometries: xr.DataArray | Sequence, grid_mapping: str | None = None):
"""Convert a DataArray with shapely geometry objects into a CF-compliant dataset.
.. warning::
Expand Down Expand Up @@ -171,7 +173,7 @@ def cf_to_shapely(ds: xr.Dataset):
return geometries.rename("geometry")


def points_to_cf(pts: Union[xr.DataArray, Sequence]):
def points_to_cf(pts: xr.DataArray | Sequence):
"""Get a list of points (shapely.geometry.[Multi]Point) and return a CF-compliant geometry dataset.
Parameters
Expand Down
1 change: 0 additions & 1 deletion doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ v0.1.3
.. _`Julia Kent`: https://github.com/jukent
.. _`Kristen Thyng`: https://github.com/kthyng
.. _`Julius Busecke`: https://github.com/jbusecke
.. _`Filipe Fernandes`: https://github.com/ocefpaf
.. _`Tom Vo`: https://github.com/tomvothecoder
.. _`Romain Caneill`: https://github.com/rcaneill
.. _`Lars Buntemeyer`: https://github.com/larsbuntemeyer
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ test = pytest
nobeep = True

[rstcheck]
report=warning
report_level=warning
ignore_roles=pr,issue,py:meth,py:attr
ignore_directives=ipython,autodata,csv-table
ignore_directives=ipython,autodata,csv-table,autosummary
ignore_messages=(is not referenced\.$)

0 comments on commit 3407d29

Please sign in to comment.