Skip to content

Commit

Permalink
chore: Replace darglint with Ruff's implementation of pydoclint (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon authored Aug 9, 2024
1 parent 9e7f71b commit 22d4eae
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 59 deletions.
10 changes: 0 additions & 10 deletions .flake8

This file was deleted.

14 changes: 1 addition & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ select = [
"E", # pycodestyle (error)
"W", # pycodestyle (warning)
"C90", # mccabe
"DOC", # pydocstyle
"I", # isort
"N", # pep8-naming
"D", # pydocstyle/flake8-docstrings
Expand Down Expand Up @@ -373,6 +374,7 @@ unfixable = [
"ANN",
"D1",
"D2",
"DOC",
"FBT001",
"FBT003",
"PLR2004",
Expand All @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion singer_sdk/_singerlib/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 5 additions & 11 deletions singer_sdk/streams/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)

Expand Down Expand Up @@ -358,9 +358,6 @@ def _write_replication_key_signpost(
Args:
context: Stream partition or context dictionary.
value: TODO
Returns:
TODO
"""
if not value:
return
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 0 additions & 3 deletions singer_sdk/target_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
38 changes: 19 additions & 19 deletions tests/_singerlib/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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():
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/samples/test_tap_countries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 22d4eae

Please sign in to comment.