Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to ruff 0.3.0 #3081

Merged
merged 2 commits into from
Mar 1, 2024
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: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Sphinx documentation configuration file.
"""

import datetime
from importlib.metadata import metadata

Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies:
- pip
# Dev dependencies (style checks)
- codespell
- ruff>=0.2.0
- ruff>=0.3.0
# Dev dependencies (unit testing)
- matplotlib
- pytest-cov
Expand Down
1 change: 1 addition & 0 deletions pygmt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
lines, vectors, polygons, and symbols (pre-defined and customized).
- Generating publication-quality illustrations and making animations.
"""

import atexit as _atexit
import sys
from importlib.metadata import version
Expand Down
1 change: 1 addition & 0 deletions pygmt/accessors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
GMT accessor for :class:`xarray.DataArray`.
"""

from pathlib import Path

import xarray as xr
Expand Down
1 change: 1 addition & 0 deletions pygmt/clib/conversion.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Functions to convert data types into ctypes friendly formats.
"""

import warnings

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions pygmt/clib/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
The path to the shared library can be found automatically by ctypes or set through the
GMT_LIBRARY_PATH environment variable.
"""

import ctypes
import os
import shutil
Expand Down
1 change: 1 addition & 0 deletions pygmt/clib/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

Uses ctypes to wrap most of the core functions from the C API.
"""

import contextlib
import ctypes as ctp
import pathlib
Expand Down
1 change: 1 addition & 0 deletions pygmt/datasets/earth_age.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

The grids are available in various resolutions.
"""

from typing import Literal

from pygmt.datasets.load_remote_dataset import _load_remote_dataset
Expand Down
1 change: 1 addition & 0 deletions pygmt/datasets/earth_free_air_anomaly.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

The grids are available in various resolutions.
"""

from typing import Literal

from pygmt.datasets.load_remote_dataset import _load_remote_dataset
Expand Down
1 change: 1 addition & 0 deletions pygmt/datasets/earth_geoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

The grids are available in various resolutions.
"""

from typing import Literal

from pygmt.datasets.load_remote_dataset import _load_remote_dataset
Expand Down
1 change: 1 addition & 0 deletions pygmt/datasets/earth_magnetic_anomaly.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

The grids are available in various resolutions.
"""

from typing import Literal

from pygmt.datasets.load_remote_dataset import _load_remote_dataset
Expand Down
1 change: 1 addition & 0 deletions pygmt/datasets/earth_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

The grids are available in various resolutions.
"""

from typing import Literal

from pygmt.datasets.load_remote_dataset import _load_remote_dataset
Expand Down
1 change: 1 addition & 0 deletions pygmt/datasets/earth_relief.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

The grids are available in various resolutions.
"""

from typing import Literal

from pygmt.datasets.load_remote_dataset import _load_remote_dataset
Expand Down
1 change: 1 addition & 0 deletions pygmt/datasets/earth_vertical_gravity_gradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

The grids are available in various resolutions.
"""

from typing import Literal

from pygmt.datasets.load_remote_dataset import _load_remote_dataset
Expand Down
1 change: 1 addition & 0 deletions pygmt/datasets/load_remote_dataset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Internal function to load GMT remote datasets.
"""

from __future__ import annotations

from typing import TYPE_CHECKING, ClassVar, NamedTuple
Expand Down
1 change: 1 addition & 0 deletions pygmt/datasets/mars_relief.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

The grids are available in various resolutions.
"""

from typing import Literal

from pygmt.datasets.load_remote_dataset import _load_remote_dataset
Expand Down
1 change: 1 addition & 0 deletions pygmt/datasets/mercury_relief.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

The grids are available in various resolutions.
"""

from typing import Literal

from pygmt.datasets.load_remote_dataset import _load_remote_dataset
Expand Down
1 change: 1 addition & 0 deletions pygmt/datasets/moon_relief.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

The grids are available in various resolutions.
"""

from typing import Literal

from pygmt.datasets.load_remote_dataset import _load_remote_dataset
Expand Down
1 change: 1 addition & 0 deletions pygmt/datasets/pluto_relief.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

The grids are available in various resolutions.
"""

from typing import Literal

from pygmt.datasets.load_remote_dataset import _load_remote_dataset
Expand Down
1 change: 1 addition & 0 deletions pygmt/datasets/samples.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Functions to load sample data.
"""

from collections.abc import Callable
from typing import Literal, NamedTuple

Expand Down
1 change: 1 addition & 0 deletions pygmt/datasets/tile_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Function to load raster tile maps from XYZ tile providers, and load as
:class:`xarray.DataArray`.
"""

from __future__ import annotations

from packaging.version import Version
Expand Down
1 change: 1 addition & 0 deletions pygmt/datasets/venus_relief.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

The grids are available in various resolutions.
"""

from typing import Literal

from pygmt.datasets.load_remote_dataset import _load_remote_dataset
Expand Down
1 change: 1 addition & 0 deletions pygmt/datatypes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Wrappers for GMT data types.
"""

from pygmt.datatypes.dataset import _GMT_DATASET
from pygmt.datatypes.grid import _GMT_GRID
1 change: 1 addition & 0 deletions pygmt/datatypes/dataset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Wrapper for the GMT_DATASET data type.
"""

import ctypes as ctp


Expand Down
1 change: 1 addition & 0 deletions pygmt/datatypes/grid.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Wrapper for the GMT_GRID data type.
"""

import ctypes as ctp


Expand Down
1 change: 1 addition & 0 deletions pygmt/figure.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Define the Figure class that handles all plotting.
"""

import base64
import os
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions pygmt/helpers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Functions, classes, decorators, and context managers to help wrap GMT modules.
"""

from pygmt.helpers.decorators import (
deprecate_parameter,
fmt_docstring,
Expand Down
1 change: 1 addition & 0 deletions pygmt/helpers/caching.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Functions for downloading remote data files to cache.
"""

from pygmt.src import which


Expand Down
7 changes: 4 additions & 3 deletions pygmt/helpers/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
arguments, insert common text into docstrings, transform arguments to strings,
etc.
"""

import functools
import textwrap
import warnings
Expand Down Expand Up @@ -455,9 +456,9 @@ def fmt_docstring(module_func):
aliases.append(f"- {arg} = {alias}")
filler_text["aliases"] = "\n".join(aliases)

filler_text[
"table-like"
] = "numpy.ndarray, pandas.DataFrame, xarray.Dataset, or geopandas.GeoDataFrame"
filler_text["table-like"] = (
"numpy.ndarray, pandas.DataFrame, xarray.Dataset, or geopandas.GeoDataFrame"
)
filler_text["table-classes"] = (
":class:`numpy.ndarray`, a :class:`pandas.DataFrame`, an\n"
" :class:`xarray.Dataset` made up of 1-D :class:`xarray.DataArray`\n"
Expand Down
1 change: 1 addition & 0 deletions pygmt/helpers/tempfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Utilities for dealing with temporary file management.
"""

import os
import uuid
from contextlib import contextmanager
Expand Down
1 change: 1 addition & 0 deletions pygmt/helpers/testing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Helper functions for testing.
"""

import importlib
import inspect
import os
Expand Down
1 change: 1 addition & 0 deletions pygmt/helpers/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Utilities and common tasks for wrapping the GMT modules.
"""

# ruff: noqa: RUF001
import os
import pathlib
Expand Down
1 change: 1 addition & 0 deletions pygmt/helpers/validators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Functions to check if given arguments are valid.
"""

import warnings

from pygmt.exceptions import GMTInvalidInput
Expand Down
1 change: 1 addition & 0 deletions pygmt/io.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
PyGMT input/output (I/O) utilities.
"""

import xarray as xr


Expand Down
1 change: 1 addition & 0 deletions pygmt/session_management.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Modern mode session management modules.
"""

import os
import sys

Expand Down
1 change: 1 addition & 0 deletions pygmt/src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Source code for PyGMT methods.
"""

from pygmt.src.basemap import basemap
from pygmt.src.binstats import binstats
from pygmt.src.blockm import blockmean, blockmedian, blockmode
Expand Down
1 change: 1 addition & 0 deletions pygmt/src/binstats.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
binstats - Bin spatial data and determine statistics per bin
"""

from pygmt.clib import Session
from pygmt.helpers import (
GMTTempFile,
Expand Down
1 change: 1 addition & 0 deletions pygmt/src/blockm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
blockm - Block average (x, y, z) data tables by mean, median, or mode
estimation.
"""

import pandas as pd
from pygmt.clib import Session
from pygmt.helpers import (
Expand Down
1 change: 1 addition & 0 deletions pygmt/src/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
config - set GMT defaults globally or locally.
"""

from inspect import Parameter, Signature
from typing import ClassVar

Expand Down
1 change: 1 addition & 0 deletions pygmt/src/grdcontour.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
grdcontour - Plot a contour figure.
"""

from pygmt.clib import Session
from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias

Expand Down
12 changes: 7 additions & 5 deletions pygmt/src/grdimage.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
grdimage - Plot grids or images.
"""

from pygmt.clib import Session
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers import (
Expand Down Expand Up @@ -163,11 +164,12 @@ def grdimage(self, grid, **kwargs):
)

with Session() as lib:
with lib.virtualfile_in(
check_kind="raster", data=grid
) as fname, lib.virtualfile_in(
check_kind="raster", data=kwargs.get("I"), required_data=False
) as shadegrid:
with (
lib.virtualfile_in(check_kind="raster", data=grid) as fname,
lib.virtualfile_in(
check_kind="raster", data=kwargs.get("I"), required_data=False
) as shadegrid,
):
kwargs["I"] = shadegrid
lib.call_module(
module="grdimage", args=build_arg_string(kwargs, infile=fname)
Expand Down
1 change: 1 addition & 0 deletions pygmt/src/grdinfo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
grdinfo - Retrieve info about grid file.
"""

from pygmt.clib import Session
from pygmt.helpers import (
GMTTempFile,
Expand Down
1 change: 1 addition & 0 deletions pygmt/src/grdlandmask.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
grdlandmask - Create a "wet-dry" mask grid from shoreline data base
"""

from pygmt.clib import Session
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers import (
Expand Down
1 change: 1 addition & 0 deletions pygmt/src/grdproject.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
grdproject - Forward and inverse map transformation of grids.
"""

from pygmt.clib import Session
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers import (
Expand Down
Loading
Loading