From 10e3b6aa5fbea5bd07061ff5031ccd1a0c970d41 Mon Sep 17 00:00:00 2001 From: Trinh Quoc Anh Date: Thu, 31 Oct 2024 08:50:59 +0100 Subject: [PATCH] Disallow type error without code --- pyproj/crs/coordinate_operation.py | 2 +- pyproj/crs/crs.py | 2 +- pyproj/geod.py | 4 ++-- pyproject.toml | 16 +++++++++------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/pyproj/crs/coordinate_operation.py b/pyproj/crs/coordinate_operation.py index e3408c77c..e986e875f 100644 --- a/pyproj/crs/coordinate_operation.py +++ b/pyproj/crs/coordinate_operation.py @@ -604,7 +604,7 @@ def __new__( f"+k_0={scale_factor_natural_origin}" ) return cls.from_json( - CRS(proj_string).coordinate_operation.to_json() # type: ignore + CRS(proj_string).coordinate_operation.to_json() # type: ignore[union-attr] ) diff --git a/pyproj/crs/crs.py b/pyproj/crs/crs.py index 6ebded896..a8073a68d 100644 --- a/pyproj/crs/crs.py +++ b/pyproj/crs/crs.py @@ -334,7 +334,7 @@ def __init__(self, projparams: Any | None = None, **kwargs) -> None: elif isinstance(projparams, (list, tuple)) and len(projparams) == 2: projstring = _prepare_from_authority(*projparams) elif hasattr(projparams, "to_wkt"): - projstring = projparams.to_wkt() # type: ignore + projstring = projparams.to_wkt() else: raise CRSError(f"Invalid CRS input: {projparams!r}") diff --git a/pyproj/geod.py b/pyproj/geod.py index 39f7fb93e..6dcef7bc9 100644 --- a/pyproj/geod.py +++ b/pyproj/geod.py @@ -1003,7 +1003,7 @@ def geometry_length(self, geometry, radians: bool = False) -> float: The total geodesic length of the geometry (meters). """ try: - return self.line_length(*geometry.xy, radians=radians) # type: ignore + return self.line_length(*geometry.xy, radians=radians) # type: ignore[misc] except (AttributeError, NotImplementedError): pass if hasattr(geometry, "exterior"): @@ -1074,7 +1074,7 @@ def geometry_area_perimeter( The geodesic area (meters^2) and perimeter (meters) of the polygon. """ try: - return self.polygon_area_perimeter( # type: ignore + return self.polygon_area_perimeter( # type: ignore[misc] *geometry.xy, radians=radians ) except (AttributeError, NotImplementedError): diff --git a/pyproject.toml b/pyproject.toml index 195d2c32c..5ffd5c17d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -110,8 +110,8 @@ select = [ "RUF", # flake8-bandit: exec-builtin "S102", - # numpy-legacy-random - "NPY002", + # NumPy-specific rules + "NPY", # Perflint "PERF", # flynt @@ -123,7 +123,7 @@ select = [ # flake8-slots "SLOT", # flake8-raise - "RSE" + "RSE", ] ignore = [ @@ -146,10 +146,6 @@ ignore = [ ### TODO: Enable gradually # Rename unused "B007", - # Use specific rule codes when ignoring type issues - "PGH003", - # unconventional-import-alias - "ICN001", # Move standard library import into a type-checking block "TCH003", # Consider f-string instead of string join @@ -158,3 +154,9 @@ ignore = [ "PERF401" ] + +[tool.mypy] +files = ["pyproj"] +python_version = "3.10" +ignore_errors = false +enable_error_code = "ignore-without-code"