Skip to content

Commit 7e63912

Browse files
refactor: Modernize further (#323)
Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
1 parent 4701cc9 commit 7e63912

7 files changed

Lines changed: 91 additions & 58 deletions

File tree

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ on:
1111
- uv.lock
1212
- .github/workflows/test.yml
1313
pull_request:
14-
types: [opened, synchronize, reopened]
1514
paths:
1615
- tap_socketdev/**
1716
- tests/**

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,8 @@ repos:
4949
hooks:
5050
- id: uv-lock
5151
- id: uv-sync
52+
53+
- repo: https://github.com/hukkin/mdformat
54+
rev: 1.0.0
55+
hooks:
56+
- id: mdformat

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,41 +28,41 @@ Built with the [Meltano Tap SDK](https://sdk.meltano.com) for Singer Taps.
2828

2929
## Capabilities
3030

31-
* `catalog`
32-
* `state`
33-
* `discover`
34-
* `about`
35-
* `stream-maps`
31+
- `catalog`
32+
- `state`
33+
- `discover`
34+
- `about`
35+
- `stream-maps`
3636

3737
## Settings
3838

39-
| Setting | Required | Default | Description |
39+
| Setting | Required | Default | Description |
4040
| :--------- | :------- | :------ | :--------------------------------- |
41-
| api_key | True | None | API Key for Socket |
42-
| start_date | False | None | Earliest datetime to get data from |
41+
| api_key | True | None | API Key for Socket |
42+
| start_date | False | None | Earliest datetime to get data from |
4343

4444
A full list of supported settings and capabilities is available by running: `tap-socketdev --about`
4545

4646
### Builtin Settings
4747

4848
The following settings are available to all taps.
4949

50-
| Setting | Required | Default | Description |
50+
| Setting | Required | Default | Description |
5151
| :-------------------------------- | :------- | :------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
52-
| stream_maps | False | None | Config object for stream maps capability. For more information check out [Stream Maps](https://sdk.meltano.com/en/latest/stream_maps.html). |
53-
| stream_map_config | False | None | User-defined config values to be used within map expressions. |
54-
| faker_config | False | None | Config for the [`Faker`](https://faker.readthedocs.io/en/master/) instance variable `fake` used within map expressions. Only applicable if the plugin specifies `faker` as an additional dependency (through the `singer-sdk` `faker` extra or directly). |
55-
| faker_config.seed | False | None | Value to seed the Faker generator for deterministic output: https://faker.readthedocs.io/en/master/#seeding-the-generator |
56-
| faker_config.locale | False | None | One or more LCID locale strings to produce localized output for: https://faker.readthedocs.io/en/master/#localization |
57-
| flattening_enabled | False | None | 'True' to enable schema flattening and automatically expand nested properties. |
58-
| flattening_max_depth | False | None | The max depth to flatten schemas. |
59-
| batch_config | False | None | Configuration for BATCH message capabilities. |
60-
| batch_config.encoding | False | None | Specifies the format and compression of the batch files. |
61-
| batch_config.encoding.format | False | None | Format to use for batch files. |
62-
| batch_config.encoding.compression | False | None | Compression format to use for batch files. |
63-
| batch_config.storage | False | None | Defines the storage layer to use when writing batch files |
64-
| batch_config.storage.root | False | None | Root path to use when writing batch files. |
65-
| batch_config.storage.prefix | False | None | Prefix to use when writing batch files. |
52+
| stream_maps | False | None | Config object for stream maps capability. For more information check out [Stream Maps](https://sdk.meltano.com/en/latest/stream_maps.html). |
53+
| stream_map_config | False | None | User-defined config values to be used within map expressions. |
54+
| faker_config | False | None | Config for the [`Faker`](https://faker.readthedocs.io/en/master/) instance variable `fake` used within map expressions. Only applicable if the plugin specifies `faker` as an additional dependency (through the `singer-sdk` `faker` extra or directly). |
55+
| faker_config.seed | False | None | Value to seed the Faker generator for deterministic output: https://faker.readthedocs.io/en/master/#seeding-the-generator |
56+
| faker_config.locale | False | None | One or more LCID locale strings to produce localized output for: https://faker.readthedocs.io/en/master/#localization |
57+
| flattening_enabled | False | None | 'True' to enable schema flattening and automatically expand nested properties. |
58+
| flattening_max_depth | False | None | The max depth to flatten schemas. |
59+
| batch_config | False | None | Configuration for BATCH message capabilities. |
60+
| batch_config.encoding | False | None | Specifies the format and compression of the batch files. |
61+
| batch_config.encoding.format | False | None | Format to use for batch files. |
62+
| batch_config.encoding.compression | False | None | Compression format to use for batch files. |
63+
| batch_config.storage | False | None | Defines the storage layer to use when writing batch files |
64+
| batch_config.storage.root | False | None | Root path to use when writing batch files. |
65+
| batch_config.storage.prefix | False | None | Prefix to use when writing batch files. |
6666

6767
### Source Authentication and Authorization
6868

noxfile.py

100644100755
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#!/usr/bin/env -S uv run --script
2+
3+
# /// script
4+
# dependencies = ["nox"]
5+
# ///
6+
17
"""Nox configuration."""
28

39
from __future__ import annotations
@@ -72,3 +78,7 @@ def ty(session: nox.Session) -> None:
7278
)
7379
args = session.posargs or ("tap_socketdev", "tests")
7480
session.run("ty", "check", *args)
81+
82+
83+
if __name__ == "__main__":
84+
nox.main()

pyproject.toml

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ keywords = [
1515
"Socket",
1616
]
1717
license = "Apache-2.0"
18-
authors = [ { name = "Edgar Ramírez-Mondragón", email = "edgarrm358@gmail.com" } ]
1918
requires-python = ">=3.12"
2019
classifiers = [
2120
"License :: OSI Approved :: Apache Software License",
@@ -29,10 +28,15 @@ dependencies = [
2928
"requests~=2.32.0",
3029
"singer-sdk~=0.54.0a4",
3130
]
32-
urls.Documentation = "https://github.com/reservoir-data/tap-socketdev#readme"
33-
urls.Homepage = "https://github.com/reservoir-data/tap-socketdev"
34-
urls.Repository = "https://github.com/reservoir-data/tap-socketdev"
35-
scripts.tap-socketdev = "tap_socketdev.tap:TapSocketDev.cli"
31+
[[project.authors]]
32+
name = "Edgar Ramírez-Mondragón"
33+
email = "edgarrm358@gmail.com"
34+
[project.scripts]
35+
tap-socketdev = "tap_socketdev.tap:TapSocketDev.cli"
36+
[project.urls]
37+
Documentation = "https://github.com/reservoir-data/tap-socketdev#readme"
38+
Homepage = "https://github.com/reservoir-data/tap-socketdev"
39+
Repository = "https://github.com/reservoir-data/tap-socketdev"
3640

3741
[dependency-groups]
3842
dev = [
@@ -47,50 +51,61 @@ testing = [
4751
"singer-sdk[testing]",
4852
]
4953
typing = [
50-
"mypy>=1.8",
51-
"ty>=0.0.1a18",
54+
"mypy>=1.9",
55+
"ty>=0.0.21",
5256
"types-requests~=2.32.0",
5357
]
5458

5559
[tool.hatch]
56-
version.source = "vcs"
60+
[tool.hatch.version]
61+
source = "vcs"
5762

5863
[tool.ruff]
5964
line-length = 88
60-
lint.select = [
65+
[tool.ruff.lint]
66+
select = [
6167
"ALL",
6268
]
63-
lint.ignore = [
69+
ignore = [
6470
"COM812", # missing-trailing-comma
6571
"DJ", # flake8-django
6672
"FIX002", # line-contains-todo
6773
"ISC001", # single-line-implicit-string-concatenation
6874
]
69-
lint.per-file-ignores."noxfile.py" = [
75+
per-file-ignores."noxfile.py" = [
7076
"ANN",
7177
]
72-
lint.per-file-ignores."tests/*" = [
78+
per-file-ignores."tests/*" = [
7379
"ANN201", # missing-return-type-public-function
7480
"INP001", # implicit-namespace-package
7581
"S101", # assert
7682
"SLF001", # private-member-access
7783
]
78-
lint.unfixable = [
84+
unfixable = [
7985
"ERA001", # commented-out-code
8086
]
81-
lint.flake8-annotations.allow-star-arg-any = true
82-
lint.isort.required-imports = [
87+
flake8-annotations.allow-star-arg-any = true
88+
isort.required-imports = [
8389
"from __future__ import annotations",
8490
]
85-
lint.pydocstyle.convention = "google"
91+
pydocstyle.convention = "google"
8692

8793
[tool.pyproject-fmt]
88-
max_supported_python = "3.14"
94+
table_format = "long"
8995

9096
[tool.pytest]
91-
ini_options.addopts = "-vvv"
97+
addopts = [ "-vvv", "-ra", "--strict-config", "--strict-markers" ]
98+
filterwarnings = [ "error" ]
99+
log_level = "INFO"
100+
minversion = "9"
101+
strict = true
102+
testpaths = [ "tests" ]
103+
xfail_strict = true
92104

93105
[tool.mypy]
106+
enable_error_code = [ "ignore-without-code", "redundant-expr", "truthy-bool" ]
107+
strict = true
94108
warn_redundant_casts = true
109+
warn_unreachable = true
95110
warn_unused_configs = true
96111
warn_unused_ignores = true

tap_socketdev/streams.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
from __future__ import annotations
44

5-
import typing as t
6-
from typing import override
5+
from typing import TYPE_CHECKING, Any, override
76

87
from singer_sdk import typing as th
9-
from singer_sdk.pagination import BasePageNumberPaginator
8+
from singer_sdk.pagination import PageNumberPaginator
109

1110
from tap_socketdev.client import SocketDevStream
1211

13-
if t.TYPE_CHECKING:
12+
if TYPE_CHECKING:
13+
from collections.abc import Generator, Iterable
14+
1415
from requests import Response
1516
from singer_sdk.helpers.types import Context
1617

@@ -70,15 +71,18 @@ class Organizations(SocketDevStream):
7071
).to_dict()
7172

7273
@override
73-
def parse_response(self, response: Response) -> t.Generator[dict, None, None]:
74+
def parse_response(
75+
self,
76+
response: Response,
77+
) -> Generator[dict[str, Any], None, None]:
7478
yield from response.json()["organizations"].values()
7579

7680
@override
7781
def generate_child_contexts(
7882
self,
79-
record: dict[str, t.Any],
83+
record: dict[str, Any],
8084
context: Context | None,
81-
) -> t.Iterable[Context | None]:
85+
) -> Iterable[Context | None]:
8286
yield {
8387
"org_slug": record["slug"],
8488
}
@@ -165,7 +169,7 @@ def get_url_params(
165169
self,
166170
context: Context | None,
167171
next_page_token: int | None,
168-
) -> dict[str, t.Any] | str:
172+
) -> dict[str, Any] | str:
169173
return {
170174
"page": next_page_token,
171175
"per_page": 100,
@@ -198,7 +202,7 @@ class RepoLabels(SocketDevStream):
198202
),
199203
th.Property(
200204
"repository_ids",
201-
th.ArrayType(th.StringType), # ty: ignore[invalid-argument-type]
205+
th.ArrayType(th.StringType),
202206
description="The IDs of repositories this label is associated with",
203207
),
204208
th.Property(
@@ -225,12 +229,12 @@ def get_url_params(
225229
self,
226230
context: Context | None,
227231
next_page_token: int | None,
228-
) -> dict[str, t.Any] | str:
232+
) -> dict[str, Any] | str:
229233
return {
230234
"page": next_page_token,
231235
"per_page": 100,
232236
}
233237

234238
@override
235-
def get_new_paginator(self) -> BasePageNumberPaginator | None:
236-
return BasePageNumberPaginator(start_value=1)
239+
def get_new_paginator(self) -> PageNumberPaginator | None:
240+
return PageNumberPaginator(start_value=1)

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)