diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bc5ec284..17d831f3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,6 +11,9 @@ repos: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.0.286 + rev: v0.6.4 hooks: + # Run the linter. - id: ruff + # Run the formatter. + - id: ruff-format diff --git a/pydda/io/read_grid.py b/pydda/io/read_grid.py index ed2b37ae..d6b4956a 100644 --- a/pydda/io/read_grid.py +++ b/pydda/io/read_grid.py @@ -42,19 +42,19 @@ def read_grid(file_name, level_name="parent", **kwargs): raise IOError("NetCDF file does not contain any valid radar grid fields!") root["point_x"] = xr.DataArray(_point_data_factory(root, "x"), dims=("z", "y", "x")) - root.attrs["units"] = root["x"].units - root.attrs["long_name"] = "Point x location" + root["point_x"].attrs["units"] = root["x"].attrs["units"] + root["point_x"].attrs["long_name"] = "Point x location" root["point_y"] = xr.DataArray(_point_data_factory(root, "y"), dims=("z", "y", "x")) - root.attrs["units"] = root["y"].units - root.attrs["long_name"] = "Point y location" + root["point_y"].attrs["units"] = root["y"].attrs["units"] + root["point_y"].attrs["long_name"] = "Point y location" root["point_z"] = xr.DataArray(_point_data_factory(root, "z"), dims=("z", "y", "x")) - root.attrs["units"] = root["z"].units - root.attrs["long_name"] = "Point z location" + root["point_z"].attrs["units"] = root["z"].attrs["units"] + root["point_z"].attrs["long_name"] = "Point z location" root["point_altitude"] = xr.DataArray( _point_altitude_data_factory(root), dims=("z", "y", "x") ) - root.attrs["units"] = root["z"].units - root.attrs["long_name"] = "Point altitude" + root["point_z"].attrs["units"] = root["z"].attrs["units"] + root["point_z"].attrs["long_name"] = "Point altitude" lon = _point_lon_lat_data_factory(root, 0) lat = _point_lon_lat_data_factory(root, 1) root["point_longitude"] = xr.DataArray(lon, dims=("z", "y", "x")) @@ -139,23 +139,23 @@ def read_from_pyart_grid(Grid): new_grid["point_x"] = xr.DataArray( _point_data_factory(new_grid, "x"), dims=("z", "y", "x") ) - new_grid.attrs["units"] = new_grid["x"].units - new_grid.attrs["long_name"] = "Point x location" + new_grid["point_x"].attrs["units"] = Grid.x["units"] + new_grid["point_x"].attrs["long_name"] = "Point x location" new_grid["point_y"] = xr.DataArray( _point_data_factory(new_grid, "y"), dims=("z", "y", "x") ) - new_grid.attrs["units"] = new_grid["y"].units - new_grid.attrs["long_name"] = "Point y location" + new_grid["point_y"].attrs["units"] = Grid.y["units"] + new_grid["point_y"].attrs["long_name"] = "Point y location" new_grid["point_z"] = xr.DataArray( _point_data_factory(new_grid, "z"), dims=("z", "y", "x") ) - new_grid.attrs["units"] = new_grid["z"].units - new_grid.attrs["long_name"] = "Point z location" + new_grid["point_z"].attrs["units"] = Grid.z["units"] + new_grid["point_z"].attrs["long_name"] = "Point z location" new_grid["point_altitude"] = xr.DataArray( _point_altitude_data_factory(new_grid), dims=("z", "y", "x") ) - new_grid.attrs["units"] = new_grid["z"].units - new_grid.attrs["long_name"] = "Point altitude" + new_grid["point_altitude"].attrs["units"] = Grid.z["units"] + new_grid["point_altitude"].attrs["long_name"] = "Point altitude" lon = _point_lon_lat_data_factory(new_grid, 0) lat = _point_lon_lat_data_factory(new_grid, 1) new_grid["point_longitude"] = xr.DataArray( diff --git a/pyproject.toml b/pyproject.toml index e97ec826..fc294737 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,14 +1,3 @@ -[tool.ruff] -# Enable the pycodestyle (`E`) and Pyflakes (`F`) rules by default. -# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or -# McCabe complexity (`C901`) by default. -select = ["E", "F"] -ignore = ["E402", "F401", "E731", "E501"] - -# Allow autofix for all enabled rules (when `--fix`) is provided. -fixable = ["ALL"] -unfixable = [] - # Exclude a variety of commonly ignored directories. exclude = [ ".bzr", @@ -35,11 +24,23 @@ exclude = [ ] per-file-ignores = {} + # Same as Black. line-length = 88 # Allow unused variables when underscore-prefixed. dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" -# Assume Python 3.8 -target-version = "py38" +# Assume Python 3.10 +target-version = "py310" + +[tool.ruff.lint] +# Enable the pycodestyle (`E`) and Pyflakes (`F`) rules by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +select = ["E", "F"] +ignore = ["E402", "F401", "E731", "E501"] + +# Allow autofix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] diff --git a/setup.py b/setup.py index fb25dc22..c1740f11 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,6 @@ """ - DOCLINES = __doc__.split("\n") import glob @@ -43,7 +42,7 @@ PLATFORMS = "Linux, Windows, OSX" MAJOR = 2 MINOR = 0 -MICRO = 0 +MICRO = 1 # SCRIPTS = glob.glob('scripts/*') # TEST_SUITE = 'nose.collector'