Skip to content
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
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Projection information.
project = "PyGMT"
author = "The PyGMT Developers"
copyright = f"2017-{datetime.date.today().year}, {author}" # ruff: ignore[A001]
copyright = f"2017-{datetime.date.today().year}, {author}" # ruff: ignore[builtin-variable-shadowing]
version = "dev" if isdev else __version__
release = __version__

Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/images/cross_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
region_map = [122, 149, 30, 49]

# Chose a survey line with start point A and end point B
lonA, latA, lonB, latB = 126, 42, 146, 40 # ruff: ignore[N816]
lonA, latA, lonB, latB = 126, 42, 146, 40 # ruff: ignore[mixed-case-variable-in-global-scope]


fig = pygmt.Figure()
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/images/rgb_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Data is sourced from a Cloud-Optimized GeoTIFF (COG) file hosted on
`OpenAerialMap <https://map.openaerialmap.org>`_ under a
`CC BY-NC 4.0 <https://creativecommons.org/licenses/by-nc/4.0/>`_ license.
""" # ruff: ignore[RUF002]
""" # ruff: ignore[ambiguous-unicode-character-docstring]

# %%
import pygmt
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/advanced/non_ascii_text.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ruff: file-ignore[RUF001, RUF003]
# ruff: file-ignore[ambiguous-unicode-character-string, ambiguous-unicode-character-comment]
"""
Typesetting non-ASCII text
--------------------------
Expand Down
2 changes: 1 addition & 1 deletion pygmt/alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def __init__(self, **kwargs):
kwdict[option] = aliases._value
super().__init__(kwdict)

def add_common(self, **kwargs): # ruff: ignore[PLR0912]
def add_common(self, **kwargs): # ruff: ignore[too-many-branches]
"""
Add common parameters to the alias dictionary.
"""
Expand Down
12 changes: 6 additions & 6 deletions pygmt/clib/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def create(self, name: str) -> None:
self._error_log: list[str] = []

@ctp.CFUNCTYPE(ctp.c_int, ctp.c_void_p, ctp.c_char_p)
def print_func(file_pointer, message): # ruff: ignore[ARG001]
def print_func(file_pointer, message): # ruff: ignore[unused-function-argument]
"""
Callback function that the GMT C API will use to print log and error
messages.
Expand All @@ -399,7 +399,7 @@ def print_func(file_pointer, message): # ruff: ignore[ARG001]
return 0
self._error_log.append(message)
# Flush to make sure the messages are printed even if we have a crash.
print(message, file=sys.stderr, flush=True) # ruff: ignore[T201]
print(message, file=sys.stderr, flush=True) # ruff: ignore[print]
return 0

# Need to store a copy of the function because ctypes doesn't and it will be
Expand Down Expand Up @@ -1171,7 +1171,7 @@ def read_data(
------
GMTCLibError
If the GMT API function fails to read the data.
""" # ruff: ignore[W505]
""" # ruff: ignore[doc-line-too-long]
c_read_data = self.get_libgmt_func(
"GMT_Read_Data",
argtypes=[
Expand Down Expand Up @@ -1762,7 +1762,7 @@ def virtualfile_from_stringio(
@deprecate_parameter(
"required_data", "required", "v0.16.0", remove_version="v0.20.0"
)
def virtualfile_in( # ruff: ignore[PLR0912]
def virtualfile_in( # ruff: ignore[too-many-branches]
self,
check_kind=None,
data=None,
Expand Down Expand Up @@ -1920,7 +1920,7 @@ def virtualfile_in( # ruff: ignore[PLR0912]
if hasattr(data, "items") and not hasattr(data, "to_frame"):
# Dictionary, pandas.DataFrame or xarray.Dataset types.
# pandas.Series will be handled below like a 1-D numpy.ndarray.
_data = [array for _, array in data.items()] # ruff: ignore[PERF102]
_data = [array for _, array in data.items()] # ruff: ignore[incorrect-dict-iterator]
else:
# Python list, tuple, numpy.ndarray, and pandas.Series types
_data = np.atleast_2d(np.asanyarray(data).T)
Expand Down Expand Up @@ -2354,7 +2354,7 @@ def extract_region(self) -> np.ndarray:
... region = lib.extract_region()
>>> print(", ".join([f"{x:.2f}" for x in region]))
-165.00, -150.00, 15.00, 25.00
""" # ruff: ignore[RUF002]
""" # ruff: ignore[ambiguous-unicode-character-docstring]
c_extract_region = self.get_libgmt_func(
"GMT_Extract_Region",
argtypes=[ctp.c_void_p, ctp.c_char_p, ctp.POINTER(ctp.c_double)],
Expand Down
2 changes: 1 addition & 1 deletion pygmt/datasets/load_remote_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

with contextlib.suppress(ImportError):
# rioxarray is needed to register the rio accessor
import rioxarray # ruff: ignore[F401]
import rioxarray # ruff: ignore[unused-import]


class Resolution(NamedTuple):
Expand Down
2 changes: 1 addition & 1 deletion pygmt/datasets/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def load_sample_data(
'usgs_quakes': 'Table of earthquakes from the USGS'}
>>> # Load the sample bathymetry dataset
>>> data = load_sample_data("bathymetry")
""" # ruff: ignore[W505]
""" # ruff: ignore[doc-line-too-long]
if name not in datasets:
raise GMTValueError(name, choices=datasets.keys(), description="dataset name")
return datasets[name].func()
2 changes: 1 addition & 1 deletion pygmt/datasets/tile_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
_HAS_CONTEXTILY = False

try:
import rioxarray # ruff: ignore[F401]
import rioxarray # ruff: ignore[unused-import]

_HAS_RIOXARRAY = True
except ImportError:
Expand Down
6 changes: 3 additions & 3 deletions pygmt/datatypes/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pandas as pd


class _GMT_DATASEGMENT(ctp.Structure): # ruff: ignore[N801]
class _GMT_DATASEGMENT(ctp.Structure): # ruff: ignore[invalid-class-name]
"""
GMT datasegment structure for holding a segment with multiple columns.
"""
Expand All @@ -38,7 +38,7 @@ class _GMT_DATASEGMENT(ctp.Structure): # ruff: ignore[N801]
]


class _GMT_DATATABLE(ctp.Structure): # ruff: ignore[N801]
class _GMT_DATATABLE(ctp.Structure): # ruff: ignore[invalid-class-name]
"""
GMT datatable structure for holding a table with multiple segments.
"""
Expand All @@ -65,7 +65,7 @@ class _GMT_DATATABLE(ctp.Structure): # ruff: ignore[N801]
]


class _GMT_DATASET(ctp.Structure): # ruff: ignore[N801]
class _GMT_DATASET(ctp.Structure): # ruff: ignore[invalid-class-name]
"""
GMT dataset structure for holding multiple tables (files).

Expand Down
2 changes: 1 addition & 1 deletion pygmt/datatypes/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pygmt.datatypes.header import _GMT_GRID_HEADER, gmt_grdfloat


class _GMT_GRID(ctp.Structure): # ruff: ignore[N801]
class _GMT_GRID(ctp.Structure): # ruff: ignore[invalid-class-name]
"""
GMT grid structure for holding a grid and its header.

Expand Down
2 changes: 1 addition & 1 deletion pygmt/datatypes/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _parse_nameunits(nameunits: str) -> tuple[str, str | None]:
return long_name, units


class _GMT_GRID_HEADER(ctp.Structure): # ruff: ignore[N801]
class _GMT_GRID_HEADER(ctp.Structure): # ruff: ignore[invalid-class-name]
"""
GMT grid header structure for metadata about the grid.

Expand Down
2 changes: 1 addition & 1 deletion pygmt/datatypes/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
)


class _GMT_IMAGE(ctp.Structure): # ruff: ignore[N801]
class _GMT_IMAGE(ctp.Structure): # ruff: ignore[invalid-class-name]
"""
GMT image data structure.

Expand Down
6 changes: 3 additions & 3 deletions pygmt/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class GMTCLibNoSessionError(GMTCLibError):
"""


class GMTInvalidInput(GMTError): # ruff: ignore[N818]
class GMTInvalidInput(GMTError): # ruff: ignore[error-suffix-on-exception-name]
"""
Raised when the input of a function/method is invalid.
"""
Expand All @@ -50,7 +50,7 @@ class GMTVersionError(GMTError):
"""


class GMTImageComparisonFailure(AssertionError): # ruff: ignore[N818]
class GMTImageComparisonFailure(AssertionError): # ruff: ignore[error-suffix-on-exception-name]
"""
Raised when a comparison between two images fails.
"""
Expand Down Expand Up @@ -99,7 +99,7 @@ class GMTValueError(GMTError, ValueError):
Traceback (most recent call last):
...
pygmt.exceptions.GMTValueError: Invalid value: 'invalid'. Explain why it's invalid.
""" # ruff: ignore[W505]
""" # ruff: ignore[doc-line-too-long]

def __init__(
self,
Expand Down
2 changes: 1 addition & 1 deletion pygmt/helpers/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def fmt_docstring(module_func):
- J = projection
- R = region
<BLANKLINE>
""" # ruff: ignore[D410, D411]
""" # ruff: ignore[no-blank-line-after-section, no-blank-line-before-section]
filler_text = {}

if hasattr(module_func, "aliases"):
Expand Down
4 changes: 2 additions & 2 deletions pygmt/helpers/tempfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def tempfile_from_geojson(geojson):
E.g. '1a2b3c4d5e6.gmt'.
"""
with GMTTempFile(suffix=".gmt") as tmpfile:
import geopandas # ruff: ignore[PLC0415]
import geopandas # ruff: ignore[import-outside-top-level]

Path(tmpfile.name).unlink() # Ensure file is deleted first
ogrgmt_kwargs = {
Expand Down Expand Up @@ -162,7 +162,7 @@ def tempfile_from_geojson(geojson):
geojson.to_file(**ogrgmt_kwargs)
except AttributeError:
# Other 'geo' formats which implement __geo_interface__
import json # ruff: ignore[PLC0415]
import json # ruff: ignore[import-outside-top-level]

jsontext = json.dumps(geojson.__geo_interface__)
geopandas.read_file(filename=io.StringIO(jsontext)).to_file(**ogrgmt_kwargs)
Expand Down
8 changes: 5 additions & 3 deletions pygmt/helpers/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ def check_figures_equal(*, extensions=("png",), tol=0.0, result_dir="result_imag
keyword_only = inspect.Parameter.KEYWORD_ONLY

def decorator(func):
import pytest # ruff: ignore[PLC0415]
from matplotlib.testing.compare import compare_images # ruff: ignore[PLC0415]
# ruff: disable[import-outside-top-level]
import pytest
from matplotlib.testing.compare import compare_images
# ruff: enable[import-outside-top-level]

Path(result_dir).mkdir(parents=True, exist_ok=True)
old_sig = inspect.signature(func)
Expand Down Expand Up @@ -191,7 +193,7 @@ def skip_if_no(package):
A pytest.mark.skipif to use as either a test decorator or a
parametrization mark.
"""
import pytest # ruff: ignore[PLC0415]
import pytest # ruff: ignore[import-outside-top-level]

try:
_ = importlib.import_module(name=package)
Expand Down
10 changes: 5 additions & 5 deletions pygmt/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
]


def _validate_data_input( # ruff: ignore[PLR0912]
def _validate_data_input( # ruff: ignore[too-many-branches]
data=None, x=None, y=None, z=None, required=True, mincols=2, kind=None
) -> None:
"""
Expand Down Expand Up @@ -217,7 +217,7 @@ def _contains_apostrophe_or_backtick(argstr: str) -> bool:
True
>>> _contains_apostrophe_or_backtick("12AB'`")
True
""" # ruff: ignore[RUF002]
""" # ruff: ignore[ambiguous-unicode-character-docstring]
return "'" in argstr or "`" in argstr


Expand Down Expand Up @@ -452,7 +452,7 @@ def non_ascii_to_octal(argstr: str, encoding: Encoding = "ISOLatin1+") -> str:
'12AB\\340\\341\\342\\343\\344\\345@~\\142@~@%34%\\254@%%@%34%\\255@%%'
>>> non_ascii_to_octal("'‘’\"“”")
'\\234\\140\\047"\\216\\217'
""" # ruff: ignore[RUF002]
""" # ruff: ignore[ambiguous-unicode-character-docstring]
# Return the input string if it only contains printable ASCII characters, excluding
# apostrophe (') and backtick (`).
if encoding == "ascii" or (
Expand Down Expand Up @@ -481,7 +481,7 @@ def non_ascii_to_octal(argstr: str, encoding: Encoding = "ISOLatin1+") -> str:
return argstr.translate(str.maketrans(mapping))


def build_arg_list( # ruff: ignore[PLR0912]
def build_arg_list( # ruff: ignore[too-many-branches]
kwdict: Mapping[str, Any],
confdict: Mapping[str, Any] | None = None,
infile: PathLike | Sequence[PathLike] | None = None,
Expand Down Expand Up @@ -712,7 +712,7 @@ def launch_external_viewer(fname: PathLike, waiting: float = 0) -> None:
case "darwin": # macOS
subprocess.run([shutil.which("open"), fname], check=False, **run_args) # type:ignore[call-overload]
case "win32": # Windows
os.startfile(fname) # type:ignore[attr-defined] # ruff: ignore[S606]
os.startfile(fname) # type:ignore[attr-defined] # ruff: ignore[start-process-with-no-shell]
case _: # Fall back to the browser if can't recognize the operating system.
webbrowser.open_new_tab(f"file://{Path(fname).resolve()}")
if waiting > 0:
Expand Down
2 changes: 1 addition & 1 deletion pygmt/params/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __post_init__(self):
"""
self._validate()

def _validate(self): # ruff: ignore[B027]
def _validate(self): # ruff: ignore[empty-method-without-abstract-decorator]
"""
Validate the parameters of the object.

Expand Down
2 changes: 1 addition & 1 deletion pygmt/sphinx_gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PyGMTScraper:
``conf.py`` as the ``"image_scrapers"`` argument.
"""

def __call__(self, block, block_vars, gallery_conf): # ruff: ignore[ARG002]
def __call__(self, block, block_vars, gallery_conf): # ruff: ignore[unused-method-argument]
"""
Called by sphinx-gallery to save the figures generated after running code.
"""
Expand Down
4 changes: 2 additions & 2 deletions pygmt/src/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def _build_frame(
return Frame(xaxis=xaxis, yaxis=yaxis)


def _alias_option_D( # ruff: ignore[N802]
def _alias_option_D( # ruff: ignore[invalid-function-name]
position=None,
length=None,
width=None,
Expand Down Expand Up @@ -220,7 +220,7 @@ def _alias_option_D( # ruff: ignore[N802]
]


def _alias_option_N(dpi=None): # ruff: ignore[N802]
def _alias_option_N(dpi=None): # ruff: ignore[invalid-function-name]
"""
Return an Alias object for the colorbar encoding setting.

Expand Down
2 changes: 1 addition & 1 deletion pygmt/src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pygmt.clib import Session


class config: # ruff: ignore[N801]
class config: # ruff: ignore[invalid-class-name]
"""
Change GMT default settings globally or locally.

Expand Down
6 changes: 3 additions & 3 deletions pygmt/src/grdfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
__doctest_skip__ = ["grdfilter"]


def _alias_option_F( # ruff: ignore[N802]
filter=None, # ruff: ignore[A002]
def _alias_option_F( # ruff: ignore[invalid-function-name]
filter=None, # ruff: ignore[builtin-argument-shadowing]
width=None,
highpass=False,
):
Expand Down Expand Up @@ -70,7 +70,7 @@ def _alias_option_F( # ruff: ignore[N802]
def grdfilter(
grid: PathLike | xr.DataArray,
outgrid: PathLike | None = None,
filter: Literal[ # ruff: ignore[A002]
filter: Literal[ # ruff: ignore[builtin-argument-shadowing]
"boxcar", "cosarch", "gaussian", "minall", "minpos", "maxall", "maxneg"
]
| str
Expand Down
2 changes: 1 addition & 1 deletion pygmt/src/grdgradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
__doctest_skip__ = ["grdgradient"]


def _alias_option_N( # ruff: ignore[N802]
def _alias_option_N( # ruff: ignore[invalid-function-name]
normalize=False,
norm_amp=None,
norm_ambient=None,
Expand Down
2 changes: 1 addition & 1 deletion pygmt/src/grdhisteq.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
__doctest_skip__ = ["grdhisteq.*"]


class grdhisteq: # ruff: ignore[N801]
class grdhisteq: # ruff: ignore[invalid-class-name]
r"""
Perform histogram equalization for a grid.

Expand Down
2 changes: 1 addition & 1 deletion pygmt/src/grdmask.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
__doctest_skip__ = ["grdmask"]


def _alias_option_N( # ruff: ignore[N802]
def _alias_option_N( # ruff: ignore[invalid-function-name]
outside: float | None = None,
edge: float | Literal["z", "id"] | None = None,
inside: float | Literal["z", "id"] | None = None,
Expand Down
2 changes: 1 addition & 1 deletion pygmt/src/grdview.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
__doctest_skip__ = ["grdview"]


def _alias_option_Q( # ruff: ignore[N802]
def _alias_option_Q( # ruff: ignore[invalid-function-name]
surftype=None, dpi=None, mesh_fill=None, monochrome=False, nan_transparent=False
):
"""
Expand Down
Loading