diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 07b7824bd..000000000 --- a/.flake8 +++ /dev/null @@ -1,10 +0,0 @@ -[flake8] -max-line-length = 88 -exclude = cookiecutter -ignore = E, F, W -per-file-ignores = - # Don't require docstrings conventions in private modules - singer_sdk/helpers/_*.py:DAR - # Disabled some checks in samples code - samples/*:DAR -docstring-convention = google diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 729f7eee3..e3bfd2a9f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,7 +50,7 @@ repos: - id: check-readthedocs - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.6 + rev: v0.5.7 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix, --show-fixes] @@ -64,18 +64,6 @@ repos: cookiecutter/.* )$ -- repo: https://github.com/pycqa/flake8 - rev: 7.1.1 - hooks: - - id: flake8 - additional_dependencies: - - darglint==1.8.1 - files: | - (?x)^( - singer_sdk/.*| - samples/.* - )$ - - repo: https://github.com/python-poetry/poetry rev: 1.8.0 hooks: diff --git a/pyproject.toml b/pyproject.toml index 2b272313a..030f94b96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -314,6 +314,7 @@ select = [ "E", # pycodestyle (error) "W", # pycodestyle (warning) "C90", # mccabe + "DOC", # pydocstyle "I", # isort "N", # pep8-naming "D", # pydocstyle/flake8-docstrings @@ -373,6 +374,7 @@ unfixable = [ "ANN", "D1", "D2", + "DOC", "FBT001", "FBT003", "PLR2004", @@ -381,8 +383,10 @@ unfixable = [ "PLC2701", # Allow usage of private members in tests "PLR6301", # Don't suggest making test methods static, etc. ] +# Disabled some checks in helper modules +"singer_sdk/helpers/_*.py" = ["DOC"] # Disabled some checks in samples code -"samples/*" = ["ANN", "D"] +"samples/*" = ["ANN", "D", "DOC"] # Templates support a generic resource of type Any. "singer_sdk/testing/*.py" = ["S101"] "singer_sdk/testing/templates.py" = ["ANN401"] diff --git a/singer_sdk/_singerlib/catalog.py b/singer_sdk/_singerlib/catalog.py index 183224e2d..c39d46a1b 100644 --- a/singer_sdk/_singerlib/catalog.py +++ b/singer_sdk/_singerlib/catalog.py @@ -199,7 +199,7 @@ def get_standard_metadata( else: entry = Metadata(inclusion=Metadata.InclusionType.AVAILABLE) - mapping[("properties", field_name)] = entry + mapping["properties", field_name] = entry mapping[()] = root diff --git a/singer_sdk/streams/core.py b/singer_sdk/streams/core.py index ed9052ae0..3f8ca6a72 100644 --- a/singer_sdk/streams/core.py +++ b/singer_sdk/streams/core.py @@ -277,6 +277,11 @@ def get_starting_timestamp( and datetime replication keys. For non-datetime replication keys, use :meth:`~singer_sdk.Stream.get_starting_replication_key_value()` + .. note:: + + This method requires :attr:`~singer_sdk.Stream.replication_key` to be set + to a non-null value, indicating the stream should be synced incrementally. + Args: context: Stream partition or context dictionary. @@ -285,11 +290,6 @@ def get_starting_timestamp( Raises: ValueError: If the replication value is not a valid timestamp. - - .. note:: - - This method requires :attr:`~singer_sdk.Stream.replication_key` to be set - to a non-null value, indicating the stream should be synced incrementally. """ value = self.get_starting_replication_key_value(context) @@ -358,9 +358,6 @@ def _write_replication_key_signpost( Args: context: Stream partition or context dictionary. value: TODO - - Returns: - TODO """ if not value: return @@ -1175,9 +1172,6 @@ def sync(self, context: types.Context | None = None) -> None: Args: context: Stream partition or context dictionary. - - Raises: - Exception: Any exception raised by the sync process. """ msg = f"Beginning {self.replication_method.lower()} sync of '{self.name}'" if context: diff --git a/singer_sdk/target_base.py b/singer_sdk/target_base.py index e600b6b51..81c991a09 100644 --- a/singer_sdk/target_base.py +++ b/singer_sdk/target_base.py @@ -242,9 +242,6 @@ def add_sink( Returns: A new sink for the stream. - - Raises: - Exception: If sink setup fails. """ self.logger.info("Initializing '%s' target sink...", self.name) sink_class = self.get_sink_class(stream_name=stream_name) diff --git a/tests/_singerlib/test_catalog.py b/tests/_singerlib/test_catalog.py index 69f377137..41efd8063 100644 --- a/tests/_singerlib/test_catalog.py +++ b/tests/_singerlib/test_catalog.py @@ -86,19 +86,19 @@ def test_selection_mask(): assert mask[()] is True # Explicitly deselected - assert mask[("properties", "id")] is False + assert mask["properties", "id"] is False # Missing defaults to parent selection - assert mask[("properties", "name")] is True + assert mask["properties", "name"] is True # Explicitly selected - assert mask[("properties", "an_object")] is False + assert mask["properties", "an_object"] is False # Missing defaults to parent selection - assert mask[("properties", "an_object", "properties", "id")] is False + assert mask["properties", "an_object", "properties", "id"] is False # Explicitly selected nested property - assert mask[("properties", "an_object", "properties", "a_string")] is True + assert mask["properties", "an_object", "properties", "a_string"] is True def test_metadata_mapping(): @@ -112,27 +112,27 @@ def test_metadata_mapping(): forced_replication_method="FULL_TABLE", ) ) - assert mapping[("properties", "id")] == Metadata( + assert mapping["properties", "id"] == Metadata( inclusion=Metadata.InclusionType.AUTOMATIC, selected=True, ) - assert mapping[("properties", "name")] == Metadata( + assert mapping["properties", "name"] == Metadata( inclusion=Metadata.InclusionType.AVAILABLE, selected=True, ) - assert mapping[("properties", "missing")] == Metadata() + assert mapping["properties", "missing"] == Metadata() selection_mask = mapping.resolve_selection() assert selection_mask[()] is True - assert selection_mask[("properties", "id")] is True - assert selection_mask[("properties", "updated_at")] is True - assert selection_mask[("properties", "name")] is True - assert selection_mask[("properties", "missing")] is True - assert selection_mask[("properties", "an_object")] is False - assert selection_mask[("properties", "an_object", "properties", "nested")] is False - assert selection_mask[("properties", "not_supported_selected")] is False - assert selection_mask[("properties", "not_supported_not_selected")] is False - assert selection_mask[("properties", "selected_by_default")] is True + assert selection_mask["properties", "id"] is True + assert selection_mask["properties", "updated_at"] is True + assert selection_mask["properties", "name"] is True + assert selection_mask["properties", "missing"] is True + assert selection_mask["properties", "an_object"] is False + assert selection_mask["properties", "an_object", "properties", "nested"] is False + assert selection_mask["properties", "not_supported_selected"] is False + assert selection_mask["properties", "not_supported_not_selected"] is False + assert selection_mask["properties", "selected_by_default"] is True def test_empty_metadata_mapping(): @@ -264,11 +264,11 @@ def test_standard_metadata( assert stream_metadata.schema_name == schema_name for pk in key_properties: - pk_metadata = metadata[("properties", pk)] + pk_metadata = metadata["properties", pk] assert pk_metadata.inclusion == Metadata.InclusionType.AUTOMATIC assert pk_metadata.selected is None for rk in valid_replication_keys or []: - rk_metadata = metadata[("properties", rk)] + rk_metadata = metadata["properties", rk] assert rk_metadata.inclusion == Metadata.InclusionType.AUTOMATIC assert rk_metadata.selected is None diff --git a/tests/samples/test_tap_countries.py b/tests/samples/test_tap_countries.py index 0479acff1..5730eed96 100644 --- a/tests/samples/test_tap_countries.py +++ b/tests/samples/test_tap_countries.py @@ -140,7 +140,7 @@ def tally_messages(messages: list) -> t.Counter: assert counter["SCHEMA", "countries"] == 1 assert counter["BATCH", "countries"] == 1 - assert counter[("STATE",)] == 3 + assert counter["STATE",] == 3 @pytest.mark.snapshot