diff --git a/pyproject.toml b/pyproject.toml index 553ddcda7..64d767b21 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -190,6 +190,7 @@ plugins = [ ] python_version = "3.8" warn_unused_configs = true +warn_unused_ignores = true warn_return_any = true [[tool.mypy.overrides]] @@ -249,6 +250,7 @@ select = [ "ARG", # flake8-unused-arguments "PTH", # flake8-use-pathlib "ERA", # eradicate + "PGH", # pygrep-hooks ] src = ["samples", "singer_sdk", "tests"] target-version = "py37" diff --git a/singer_sdk/_singerlib/catalog.py b/singer_sdk/_singerlib/catalog.py index 54caa99e9..22d3e122d 100644 --- a/singer_sdk/_singerlib/catalog.py +++ b/singer_sdk/_singerlib/catalog.py @@ -155,7 +155,7 @@ def root(self) -> StreamMetadata: Returns: Stream metadata. """ - return self[()] # type: ignore + return self[()] # type: ignore[return-value] @classmethod def get_standard_metadata( diff --git a/singer_sdk/authenticators.py b/singer_sdk/authenticators.py index 727c29110..51b2c4413 100644 --- a/singer_sdk/authenticators.py +++ b/singer_sdk/authenticators.py @@ -74,7 +74,7 @@ def __call__(cls, *args: Any, **kwargs: Any) -> Any: # noqa: ANN401 """ if cls.__single_instance: return cls.__single_instance - single_obj = cls.__new__(cls, None) # type: ignore + single_obj = cls.__new__(cls, None) # type: ignore[call-overload] single_obj.__init__(*args, **kwargs) cls.__single_instance = single_obj return single_obj diff --git a/singer_sdk/helpers/_compat.py b/singer_sdk/helpers/_compat.py index ff9346b7c..b89984691 100644 --- a/singer_sdk/helpers/_compat.py +++ b/singer_sdk/helpers/_compat.py @@ -2,16 +2,13 @@ from __future__ import annotations -try: - from typing import final -except ImportError: - # Final not available until Python3.8 - final = lambda f: f # noqa: E731 +import sys -try: +if sys.version_info < (3, 8): + import importlib_metadata as metadata + from typing_extensions import final +else: from importlib import metadata -except ImportError: - # Running on pre-3.8 Python; use importlib-metadata package - import importlib_metadata as metadata # type: ignore + from typing import final __all__ = ["metadata", "final"] diff --git a/singer_sdk/helpers/_simpleeval.py b/singer_sdk/helpers/_simpleeval.py index 2243cd3e5..c3fb41c3f 100644 --- a/singer_sdk/helpers/_simpleeval.py +++ b/singer_sdk/helpers/_simpleeval.py @@ -126,7 +126,7 @@ # builtins is a dict in python >3.6 but a module before DISALLOW_FUNCTIONS = {type, isinstance, eval, getattr, setattr, repr, compile, open} if hasattr(__builtins__, "help") or ( - hasattr(__builtins__, "__contains__") and "help" in __builtins__ # type: ignore + hasattr(__builtins__, "__contains__") and "help" in __builtins__ ): # PyInstaller environment doesn't include this module. DISALLOW_FUNCTIONS.add(help) diff --git a/singer_sdk/helpers/_state.py b/singer_sdk/helpers/_state.py index 69909290c..c01ff29bf 100644 --- a/singer_sdk/helpers/_state.py +++ b/singer_sdk/helpers/_state.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Callable, cast +from typing import TYPE_CHECKING, Any, Callable, TypeVar, cast from singer_sdk.exceptions import InvalidStreamSortException from singer_sdk.helpers._typing import to_json_compatible @@ -10,6 +10,8 @@ if TYPE_CHECKING: import datetime + _T = TypeVar("_T", datetime.datetime, str, int, float) + PROGRESS_MARKERS = "progress_markers" PROGRESS_MARKER_NOTE = "Note" SIGNPOST_MARKER = "replication_key_signpost" @@ -224,13 +226,12 @@ def increment_state( def _greater_than_signpost( - signpost: datetime.datetime | str | int | float, - new_value: datetime.datetime | str | int | float, + signpost: _T, + new_value: _T, ) -> bool: """Compare and return True if new_value is greater than signpost.""" - return ( # fails if signpost and bookmark are incompatible types - new_value > signpost # type: ignore - ) + # fails if signpost and bookmark are incompatible types + return new_value > signpost def finalize_state_progress_markers(stream_or_partition_state: dict) -> dict | None: diff --git a/singer_sdk/mapper_base.py b/singer_sdk/mapper_base.py index 09f3d8940..bc7880dce 100644 --- a/singer_sdk/mapper_base.py +++ b/singer_sdk/mapper_base.py @@ -164,7 +164,7 @@ def cli( cls._env_prefix, ) - mapper = cls( # type: ignore # Ignore 'type not callable' + mapper = cls( # type: ignore[operator] config=config_dict, validate_config=validate_config, ) diff --git a/singer_sdk/streams/graphql.py b/singer_sdk/streams/graphql.py index 00e19f44b..824ad04fa 100644 --- a/singer_sdk/streams/graphql.py +++ b/singer_sdk/streams/graphql.py @@ -22,7 +22,7 @@ class GraphQLStream(RESTStream, metaclass=abc.ABCMeta): rest_method = "POST" @classproperty - def records_jsonpath(cls) -> str: # type: ignore # OK: str vs @classproperty + def records_jsonpath(cls) -> str: # type: ignore[override] """Get the JSONPath expression to extract records from an API response. Returns: diff --git a/singer_sdk/streams/rest.py b/singer_sdk/streams/rest.py index edb760ffe..5bee7cd84 100644 --- a/singer_sdk/streams/rest.py +++ b/singer_sdk/streams/rest.py @@ -495,7 +495,7 @@ def get_new_paginator(self) -> BaseAPIPaginator: DeprecationWarning, stacklevel=2, ) - return LegacyStreamPaginator(self) # type: ignore + return LegacyStreamPaginator(self) if self.next_page_token_jsonpath: return JSONPathPaginator(self.next_page_token_jsonpath) @@ -588,7 +588,7 @@ def backoff_wait_generator(self) -> Generator[float, None, None]: Returns: The wait generator """ - return backoff.expo(factor=2) # type: ignore # ignore 'Returning Any' + return backoff.expo(factor=2) def backoff_max_tries(self) -> int: """The number of attempts before giving up when retrying requests. diff --git a/singer_sdk/tap_base.py b/singer_sdk/tap_base.py index 959a5a63a..cae8b7dc5 100644 --- a/singer_sdk/tap_base.py +++ b/singer_sdk/tap_base.py @@ -86,7 +86,7 @@ def __init__( if isinstance(catalog, Catalog): self._input_catalog = catalog elif isinstance(catalog, dict): - self._input_catalog = Catalog.from_dict(catalog) # type: ignore + self._input_catalog = Catalog.from_dict(catalog) # type: ignore[arg-type] elif catalog is not None: self._input_catalog = Catalog.from_dict(read_json_file(catalog)) @@ -490,7 +490,7 @@ def cli( config_files.append(Path(config_path)) - tap = cls( # type: ignore # Ignore 'type not callable' + tap = cls( # type: ignore[operator] config=config_files or None, state=state, catalog=catalog, diff --git a/singer_sdk/target_base.py b/singer_sdk/target_base.py index 850691c2b..406b1912d 100644 --- a/singer_sdk/target_base.py +++ b/singer_sdk/target_base.py @@ -569,7 +569,7 @@ def cli( config_files.append(Path(config_path)) - target = cls( # type: ignore # Ignore 'type not callable' + target = cls( # type: ignore[operator] config=config_files or None, parse_env_config=parse_env_config, validate_config=validate_config, diff --git a/singer_sdk/testing/factory.py b/singer_sdk/testing/factory.py index 1c90f2d68..152494127 100644 --- a/singer_sdk/testing/factory.py +++ b/singer_sdk/testing/factory.py @@ -58,7 +58,7 @@ def runner(self) -> TapTestRunner | TargetTestRunner: for suite in test_suites: # make sure given runner is of type TapTestRunner - expected_runner_class = ( # type: ignore[valid-type] + expected_runner_class = ( TapTestRunner if suite.kind in {"tap", "tap_stream", "tap_stream_attribute"} else TargetTestRunner diff --git a/singer_sdk/typing.py b/singer_sdk/typing.py index 4ae32e921..5ec5363c0 100644 --- a/singer_sdk/typing.py +++ b/singer_sdk/typing.py @@ -382,7 +382,7 @@ def __init__(self, wrapped_type: W | type[W]) -> None: self.wrapped_type = wrapped_type @property - def type_dict(self) -> dict: # type: ignore # OK: @classproperty vs @property + def type_dict(self) -> dict: # type: ignore[override] """Get type dictionary. Returns: @@ -435,7 +435,7 @@ def __init__( self.examples = examples or None @property - def type_dict(self) -> dict: # type: ignore # OK: @classproperty vs @property + def type_dict(self) -> dict: # type: ignore[override] """Get type dictionary. Returns: @@ -577,7 +577,7 @@ def __init__( self.pattern_properties = pattern_properties @property - def type_dict(self) -> dict: # type: ignore # OK: @classproperty vs @property + def type_dict(self) -> dict: # type: ignore[override] """Get type dictionary. Returns: @@ -620,7 +620,7 @@ def __init__(self, jsonschema_type_dict: dict) -> None: self._jsonschema_type_dict = jsonschema_type_dict @property - def type_dict(self) -> dict: # type: ignore # OK: @classproperty vs @property + def type_dict(self) -> dict: # type: ignore[override] """Get type dictionary. Returns: