Skip to content
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
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ dev = [
"pytest-timeout ~= 2.3.0",
"pytest-xdist ~= 3.6.0",
"redbaron ~= 0.9.0",
"ruff ~= 0.4.0",
"setuptools ~= 70.0.0", # setuptools are used by pytest, but not explicitly required
"ruff ~= 0.5.0",
"setuptools ~= 70.3.0", # setuptools are used by pytest, but not explicitly required
"twine ~= 5.1.0",
]

Expand All @@ -57,7 +57,7 @@ dev = [
"Apify Homepage" = "https://apify.com"

[build-system]
requires = ["setuptools ~= 70.0.0", "wheel"]
requires = ["setuptools ~= 70.3.0", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools.packages.find]
Expand All @@ -69,6 +69,8 @@ apify_client = ["py.typed"]

[tool.ruff]
line-length = 150

[tool.ruff.lint]
select = ["ALL"]
ignore = [
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in {filename}
Expand Down
12 changes: 6 additions & 6 deletions scripts/fix_async_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
continue

# Work around a bug in Red Baron, which indents docstrings too much when you insert them, so we have to un-indent it one level first
correct_async_docstring = re.sub('^ ', '', correct_async_docstring, flags=re.M)
correct_async_docstring = re.sub('^ ', '', correct_async_docstring, flags=re.MULTILINE)

if not isinstance(async_docstring, str):
print(f'Fixing missing docstring for "{async_class.name}.{async_method.name}"...')
Expand All @@ -54,14 +54,14 @@

# Work around a bug in Red Baron, which adds indents to docstrings when you insert them (including empty lines),
# so we have to remove the extra whitespace
updated_source_code = re.sub('^ $', '', updated_source_code, flags=re.M)
updated_source_code = re.sub('^ $', '', updated_source_code, flags=re.MULTILINE)

# Work around a bug in Red Baron, which indents `except` and `finally` statements wrong
# so we have to add some extra whitespace
updated_source_code = re.sub('^except', ' except', updated_source_code, flags=re.M)
updated_source_code = re.sub('^ except', ' except', updated_source_code, flags=re.M)
updated_source_code = re.sub('^finally', ' finally', updated_source_code, flags=re.M)
updated_source_code = re.sub('^ finally', ' finally', updated_source_code, flags=re.M)
updated_source_code = re.sub('^except', ' except', updated_source_code, flags=re.MULTILINE)
updated_source_code = re.sub('^ except', ' except', updated_source_code, flags=re.MULTILINE)
updated_source_code = re.sub('^finally', ' finally', updated_source_code, flags=re.MULTILINE)
updated_source_code = re.sub('^ finally', ' finally', updated_source_code, flags=re.MULTILINE)

# Work around a bug in Red Baron, which sometimes adds an extra new line to the end of a file
updated_source_code = updated_source_code.rstrip() + '\n'
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def sync_to_async_docstring(docstring: str) -> str:
substitutions = [(r'Client', r'ClientAsync')]
res = docstring
for pattern, replacement in substitutions:
res = re.sub(pattern, replacement, res, flags=re.M)
res = re.sub(pattern, replacement, res, flags=re.MULTILINE)
return res


Expand Down
15 changes: 10 additions & 5 deletions src/apify_client/_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,14 @@ def __init__(self: InvalidResponseBodyError, response: httpx.Response) -> None:
self.response = response


def is_retryable_error(e: Exception) -> bool:
def is_retryable_error(exc: Exception) -> bool:
"""Check if the given error is retryable."""
if isinstance(e, (InvalidResponseBodyError, httpx.NetworkError, httpx.TimeoutException, httpx.RemoteProtocolError)):
return True

return False
return isinstance(
exc,
(
InvalidResponseBodyError,
httpx.NetworkError,
httpx.TimeoutException,
httpx.RemoteProtocolError,
),
)
2 changes: 1 addition & 1 deletion src/apify_client/_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def _get_extra_fields(self: _DebugLogFormatter, record: logging.LogRecord) -> di
extra_fields: dict = {}
for key, value in record.__dict__.items():
if key not in self.empty_record.__dict__:
extra_fields[key] = value
extra_fields[key] = value # noqa: PERF403

return extra_fields

Expand Down