Skip to content

Commit 335ea5d

Browse files
authored
move to uv, update deps, fix tests (#49)
1 parent e628f28 commit 335ea5d

File tree

8 files changed

+1920
-1272
lines changed

8 files changed

+1920
-1272
lines changed

meltano.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ plugins:
1414
- catalog
1515
- discover
1616
config:
17-
start_date: 1741706134
17+
start_date: 1751953786
1818
access_token: $TAP_INTERCOM_ACCESS_TOKEN
1919
select:
2020
- "*.*"

poetry.lock

Lines changed: 0 additions & 1228 deletions
This file was deleted.

pyproject.toml

Lines changed: 77 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,104 @@
1-
[tool.poetry]
1+
[project]
22
name = "ticketswap-tap-intercom"
33
version = "0.0.1"
44
description = "`tap-intercom` is a Singer tap for Intercom, built with the Meltano Singer SDK."
55
readme = "README.md"
6-
authors = ["Tobias Cadee <tobias.cadee@ticketswap.com>"]
6+
authors = [{ name = "Tobias Cadee", email = "tobias.cadee@ticketswap.com" }]
77
keywords = [
88
"ELT",
99
"Intercom",
1010
]
11+
classifiers = [
12+
"Intended Audience :: Developers",
13+
"License :: OSI Approved :: Apache Software License",
14+
"Operating System :: OS Independent",
15+
"Programming Language :: Python :: 3.9",
16+
"Programming Language :: Python :: 3.10",
17+
"Programming Language :: Python :: 3.11",
18+
"Programming Language :: Python :: 3.12",
19+
"Programming Language :: Python :: 3.13",
20+
]
1121
license = "Apache-2.0"
12-
packages = [
13-
{ include = "tap_intercom" },
22+
license-files = [ "LICENSE" ]
23+
requires-python = ">=3.9"
24+
25+
dependencies = [
26+
"singer-sdk>=0.42.1",
27+
"fs-s3fs",
28+
"requests",
29+
"cached-property", # Remove after Python 3.7 support is dropped
1430
]
1531

16-
[tool.poetry.dependencies]
17-
python = ">=3.8,<4"
18-
singer-sdk = { version="~=0.42.1" }
19-
fs-s3fs = { version = "~=1.1.1", optional = true }
20-
requests = "~=2.32.3"
21-
cached-property = "~=2" # Remove after Python 3.7 support is dropped
32+
[project.optional-dependencies]
33+
s3 = [
34+
"s3fs",
35+
]
2236

23-
[tool.poetry.group.dev.dependencies]
24-
pytest = ">=7.4.0"
25-
singer-sdk = { version="~=0.42.1", extras = ["testing"] }
37+
[project.scripts]
38+
# CLI declaration
39+
tap-intercom = 'tap_intercom.tap:TapIntercom.cli'
2640

27-
[tool.poetry.extras]
28-
s3 = ["fs-s3fs"]
41+
[dependency-groups]
42+
dev = [
43+
{ include-group = "test" },
44+
]
45+
test = [
46+
"pytest>=8",
47+
"pytest-github-actions-annotate-failures>=0.3",
48+
"singer-sdk[testing]",
49+
]
50+
[tool.hatch.build.targets.wheel]
51+
packages = [
52+
"tap_intercom",
53+
]
54+
55+
[tool.pytest.ini_options]
56+
addopts = [
57+
"--durations=10",
58+
]
2959

3060
[tool.mypy]
31-
python_version = "3.9"
3261
warn_unused_configs = true
62+
plugins = "sqlmypy"
3363

34-
[tool.ruff]
64+
[tool.ruff.lint]
3565
ignore = [
36-
"ANN101", # missing-type-self
37-
"ANN102", # missing-type-cls
66+
"COM812", # missing-trailing-comma
3867
]
3968
select = ["ALL"]
40-
src = ["tap_intercom"]
41-
target-version = "py37"
42-
4369

44-
[tool.ruff.flake8-annotations]
70+
[tool.ruff.lint.flake8-annotations]
4571
allow-star-arg-any = true
4672

47-
[tool.ruff.isort]
48-
known-first-party = ["tap_intercom"]
49-
50-
[tool.ruff.pydocstyle]
73+
[tool.ruff.lint.pydocstyle]
5174
convention = "google"
5275

5376
[build-system]
54-
requires = ["poetry-core>=1.0.8"]
55-
build-backend = "poetry.core.masonry.api"
77+
requires = [
78+
"hatchling>=1,<2",
79+
]
80+
build-backend = "hatchling.build"
5681

57-
[tool.poetry.scripts]
58-
# CLI declaration
59-
tap-intercom = 'tap_intercom.tap:TapIntercom.cli'
82+
# This configuration can be used to customize tox tests as well as other test frameworks like flake8 and mypy
83+
[tool.tox]
84+
min_version = "4.22"
85+
requires = [
86+
"tox>=4.22",
87+
"tox-uv",
88+
]
89+
env_list = [
90+
"py313",
91+
"py312",
92+
"py311",
93+
"py310",
94+
"py39",
95+
]
96+
97+
[tool.tox.env_run_base]
98+
runner = "uv-venv-lock-runner"
99+
pass_env = [
100+
"GITHUB_*",
101+
"TAP_INTERCOM_*",
102+
]
103+
dependency_groups = [ "test" ]
104+
commands = [ [ "pytest", { replace = "posargs", default = [ "tests" ], extend = true } ] ]

tap_intercom/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def http_headers(self) -> dict:
5353

5454
def get_url_params(self, context, next_page_token):
5555
params = {}
56-
if self.rest_method == "GET":
56+
if self.http_method == "GET":
5757
params = {"per_page": 150}
5858
return params
5959

@@ -75,7 +75,7 @@ def prepare_request_payload(
7575
next_page_token: Token, page number or any request argument to request the
7676
next page of data.
7777
"""
78-
if self.rest_method == "POST":
78+
if self.http_method == "POST":
7979
body = {"sort": {"field": self.replication_key, "order": "ascending"}}
8080
start_date = self.get_starting_replication_key_value(context)
8181
if start_date or self.config.get("filters", {}).get(self.name):

tap_intercom/streams.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ class ConversationsStream(IntercomStream):
2121
primary_keys: t.ClassVar[list[str]] = ["id"]
2222
replication_key = "updated_at"
2323
records_jsonpath = "$.conversations[*]"
24-
rest_method = "POST"
24+
http_method = "POST"
2525
schema = conversations_schema
2626

2727
def get_child_context(self, record: dict, context: t.Optional[dict]) -> dict:
2828
"""Return a context dictionary for child streams."""
2929
return {"conversation_id": record["id"]}
3030

31+
3132
class ConversationPartsStream(IntercomStream):
3233
name = "conversation_parts"
3334
parent_stream_type = ConversationsStream
@@ -42,32 +43,36 @@ def post_process(self, row: dict, context: dict | None = None) -> dict | None:
4243
row["conversation_id"] = context["conversation_id"]
4344
return row
4445

46+
4547
class AdminsStream(IntercomStream):
4648
name = "admins"
4749
path = "/admins"
4850
primary_keys: t.ClassVar[list[str]] = ["id"]
4951
records_jsonpath = "$.admins[*]"
5052
schema = admins_schema
5153

54+
5255
class TagsStream(IntercomStream):
5356
name = "tags"
5457
path = "/tags"
5558
primary_keys: t.ClassVar[list[str]] = ["id"]
5659
records_jsonpath = "$.data[*]"
5760
schema = tags_schema
5861

62+
5963
class TeamsStream(IntercomStream):
6064
name = "teams"
6165
path = "/teams"
6266
primary_keys: t.ClassVar[list[str]] = ["id"]
6367
records_jsonpath = "$.teams[*]"
6468
schema = teams_schema
6569

70+
6671
class ContactsStream(IntercomStream):
6772
name = "contacts"
6873
path = "/contacts/search"
6974
primary_keys: t.ClassVar[list[str]] = ["id"]
7075
records_jsonpath = "$.data[*]"
7176
replication_key = "updated_at"
72-
rest_method = "POST"
77+
http_method = "POST"
7378
schema = contacts_schema

tests/conftest.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/test_core.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
import datetime
44
import os
55

6-
from singer_sdk.testing import get_tap_test_class
6+
from singer_sdk.testing import SuiteConfig, get_tap_test_class
77

88
from tap_intercom.tap import TapIntercom
99

1010
SAMPLE_CONFIG = {
11-
"start_date": (datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(hours=1)).strftime(
12-
"%Y-%m-%dT%H:%M:%SZ"
13-
),
11+
"start_date": int((datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(hours=1)).timestamp()),
1412
"access_token": os.getenv("TAP_INTERCOM_ACCESS_TOKEN"),
1513
}
1614

15+
TEST_SUITE_CONFIG = SuiteConfig(max_records_limit=10, ignore_no_records=True)
16+
1717

1818
# Run standard built-in tap tests from the SDK:
1919
TestTapIntercom = get_tap_test_class(
2020
tap_class=TapIntercom,
2121
config=SAMPLE_CONFIG,
22+
suite_config=TEST_SUITE_CONFIG,
2223
)

0 commit comments

Comments
 (0)