Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mypy to CI and fix errors #158

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ warn_unused_configs = True

[mypy-backoff.*]
ignore_missing_imports = True

[mypy-facebook_business.*]
ignore_missing_imports = True
60 changes: 59 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ facebook-business = "^19.0.0"
[tool.poetry.dev-dependencies]
pytest = ">=7.4.1"
singer-sdk = {version = ">=0.27,<0.35", extras = ["testing"]}
mypy = "^1.8.0"

[tool.isort]
profile = "black"
Expand Down
11 changes: 7 additions & 4 deletions tap_facebook/streams/ad_insights.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,17 @@ def _get_datatype(field: str) -> th.Type | None:
@property
@lru_cache # noqa: B019
def schema(self) -> dict:
properties: th.List[th.Property] = []
properties: list[th.Property] = []
columns = list(AdsInsights.Field.__dict__)[1:]
for field in columns:
if field in EXCLUDED_FIELDS:
continue
properties.append(th.Property(field, self._get_datatype(field)))
for breakdown in self._report_definition["breakdowns"]:
properties.append(th.Property(breakdown, th.StringType()))
breakdown_list = [
th.Property(breakdown, th.StringType())
for breakdown in self._report_definition["breakdowns"]
]
properties.extend(breakdown_list)
return th.PropertiesList(*properties).to_dict()

def _initialize_client(self) -> None:
Expand All @@ -126,7 +129,7 @@ def _initialize_client(self) -> None:
msg = f"Couldn't find account with id {account_id}"
raise RuntimeError(msg)

def _run_job_to_completion(self, params: dict) -> th.Any:
def _run_job_to_completion(self, params: dict) -> t.Any: # noqa: ANN401
job = self.account.get_insights(
params=params,
is_async=True,
Expand Down
4 changes: 2 additions & 2 deletions tap_facebook/streams/campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ class CampaignStream(IncrementalFacebookStream):
def post_process(
self,
row: dict,
context: dict | None, # noqa: ARG002
) -> dict:
context: dict | None = None, # noqa: ARG002
) -> dict | None:
daily_budget = row.get("daily_budget")
row["daily_budget"] = int(daily_budget) if daily_budget is not None else None
return row
4 changes: 4 additions & 0 deletions tap_facebook/streams/custom_audiences.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class CustomAudiences(FacebookStream):
def path(self) -> str:
return f"/customaudiences?fields={self.columns}"

@path.setter
def path(self, new_value: str) -> None:
self._value = new_value

@property
def columns(self) -> list[str]:
return [
Expand Down