Skip to content
New issue

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

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

Already on GitHub? # to your account

chore(deps): pre-commit autoupdate #91

Merged
merged 4 commits into from
Sep 4, 2023
Merged
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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.23.2
rev: 0.26.3
hooks:
- id: check-dependabot
- id: check-github-workflows

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.272
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.287
hooks:
- id: ruff
args: ["--fix"]

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
rev: v1.5.1
hooks:
- id: mypy
pass_filenames: true
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ banned-from = ["typing"]
typing = "t"

[tool.ruff.per-file-ignores]
"tests/*" = ["ANN201"]
"tests/*" = ["ANN201", "D103", "S101", "PLR2004"]

[tool.ruff.pydocstyle]
convention = "google"
30 changes: 13 additions & 17 deletions tap_facebook/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def url_base(self) -> str:
records_jsonpath = "$.data[*]" # Or override `parse_response`.
next_page_token_jsonpath = "$.paging.cursors.after" # noqa: S105

tolerated_http_errors: list[int] = []
tolerated_http_errors: list[int] = [] # noqa: RUF012

@property
def authenticator(self) -> BearerTokenAuthenticator:
Expand All @@ -50,8 +50,8 @@ def authenticator(self) -> BearerTokenAuthenticator:
def get_next_page_token(
self,
response: requests.Response,
previous_token: t.Any | None, # noqa: ARG002
) -> t.Any | None:
previous_token: t.Any | None, # noqa: ARG002, ANN401
) -> t.Any | None: # noqa: ANN401
"""Return a token for identifying next page or None if no more pages.

Args:
Expand All @@ -61,22 +61,19 @@ def get_next_page_token(
Returns:
The next pagination token.
"""
if self.next_page_token_jsonpath:
all_matches = extract_jsonpath(
self.next_page_token_jsonpath,
response.json(),
)
first_match = next(iter(all_matches), None)
next_page_token = first_match
else:
next_page_token = response.headers.get("X-Next-Page", None)
if not self.next_page_token_jsonpath:
return response.headers.get("X-Next-Page", None)

return next_page_token
all_matches = extract_jsonpath(
self.next_page_token_jsonpath,
response.json(),
)
return next(iter(all_matches), None)

def get_url_params(
self,
context: dict | None, # noqa: ARG002
next_page_token: t.Any | None,
next_page_token: t.Any | None, # noqa: ANN401
) -> dict[str, t.Any]:
"""Return a dictionary of values to be used in URL parameterization.

Expand All @@ -87,8 +84,7 @@ def get_url_params(
Returns:
A dictionary of URL query parameters.
"""
params: dict = {}
params["limit"] = 25
params: dict = {"limit": 25}
if next_page_token is not None:
params["after"] = next_page_token
if self.replication_key:
Expand All @@ -100,7 +96,7 @@ def get_url_params(
def prepare_request_payload(
self,
context: dict | None, # noqa: ARG002
next_page_token: t.Any | None, # noqa: ARG002
next_page_token: t.Any | None, # noqa: ARG002, ANN401
) -> dict | None:
"""Prepare the data payload for the REST API request.

Expand Down
Loading