diff --git a/pyproject.toml b/pyproject.toml index c07e4634b..75c07e3d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -214,9 +214,10 @@ fail_under = 82 exclude = "tests" files = "singer_sdk" python_version = "3.8" +warn_redundant_casts = true +warn_return_any = true warn_unused_configs = true warn_unused_ignores = true -warn_return_any = true [[tool.mypy.overrides]] ignore_missing_imports = true diff --git a/singer_sdk/about.py b/singer_sdk/about.py index 78478c417..e5bbf60de 100644 --- a/singer_sdk/about.py +++ b/singer_sdk/about.py @@ -138,10 +138,7 @@ def format_about(self, about_info: AboutInfo) -> str: Returns: A formatted string. """ - max_setting_len = t.cast( - int, - max(len(k) for k in about_info.settings["properties"]), - ) + max_setting_len = max(len(k) for k in about_info.settings["properties"]) # Set table base for markdown table_base = ( diff --git a/singer_sdk/connectors/sql.py b/singer_sdk/connectors/sql.py index 91846d46a..c4ddba880 100644 --- a/singer_sdk/connectors/sql.py +++ b/singer_sdk/connectors/sql.py @@ -13,7 +13,6 @@ import simplejson import sqlalchemy -from sqlalchemy.engine import Engine from singer_sdk import typing as th from singer_sdk._singerlib import CatalogEntry, MetadataMapping, Schema @@ -21,6 +20,7 @@ from singer_sdk.helpers.capabilities import TargetLoadMethods if t.TYPE_CHECKING: + from sqlalchemy.engine import Engine from sqlalchemy.engine.reflection import Inspector @@ -293,7 +293,7 @@ def _dialect(self) -> sqlalchemy.engine.Dialect: Returns: The dialect object. """ - return t.cast(sqlalchemy.engine.Dialect, self._engine.dialect) + return self._engine.dialect @property def _engine(self) -> Engine: @@ -307,7 +307,7 @@ def _engine(self) -> Engine: """ if not self._cached_engine: self._cached_engine = self.create_engine() - return t.cast(Engine, self._cached_engine) + return self._cached_engine def create_engine(self) -> Engine: """Creates and returns a new engine. Do not call outside of _engine. @@ -572,10 +572,7 @@ def table_exists(self, full_table_name: str) -> bool: """ _, schema_name, table_name = self.parse_full_table_name(full_table_name) - return t.cast( - bool, - sqlalchemy.inspect(self._engine).has_table(table_name, schema_name), - ) + return sqlalchemy.inspect(self._engine).has_table(table_name, schema_name) def schema_exists(self, schema_name: str) -> bool: """Determine if the target database schema already exists. diff --git a/singer_sdk/helpers/_state.py b/singer_sdk/helpers/_state.py index cc8cbb747..1c188852c 100644 --- a/singer_sdk/helpers/_state.py +++ b/singer_sdk/helpers/_state.py @@ -80,7 +80,7 @@ def _find_in_partitions_list( f"{{state_partition_context}}.\nMatching state values were: {found!s}" ) raise ValueError(msg) - return t.cast(dict, found[0]) if found else None + return found[0] if found else None def _create_in_partitions_list( diff --git a/singer_sdk/streams/sql.py b/singer_sdk/streams/sql.py index 18d2d8862..e605471dc 100644 --- a/singer_sdk/streams/sql.py +++ b/singer_sdk/streams/sql.py @@ -51,7 +51,7 @@ def _singer_catalog_entry(self) -> CatalogEntry: Returns: A CatalogEntry object. """ - return t.cast(CatalogEntry, CatalogEntry.from_dict(self.catalog_entry)) + return CatalogEntry.from_dict(self.catalog_entry) @property def connector(self) -> SQLConnector: