Skip to content

Commit 659bf80

Browse files
committed
Align scripts and Ruff configuration with the SDK
1 parent a549404 commit 659bf80

File tree

6 files changed

+32
-8
lines changed

6 files changed

+32
-8
lines changed

pyproject.toml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ classifiers = [
2121
]
2222

2323
requires-python = ">=3.8"
24+
25+
# We use inclusive ordered comparison clause for non-Apify packages intentionally in order to enhance the Apify
26+
# packages's compatibility with a wide range of external packages. This decision was discussed in detail in
27+
# the following PR: https://github.com/apify/apify-sdk-python/pull/154
2428
dependencies = []
2529

2630
[project.optional-dependencies]
2731
dev = [
2832
"build ~= 1.0.3",
2933
"filelock ~= 3.12.4",
30-
"mypy ~= 1.5.1",
34+
"mypy ~= 1.7.1",
3135
"pre-commit ~= 3.4.0",
3236
"pydoc-markdown ~= 4.8.2",
3337
"pytest ~= 7.4.2",
@@ -36,7 +40,7 @@ dev = [
3640
"pytest-timeout ~= 2.2.0",
3741
"pytest-xdist ~= 3.3.1",
3842
"respx ~= 0.20.1",
39-
"ruff ~= 0.1.5",
43+
"ruff ~= 0.1.6",
4044
"twine ~= 4.0.2",
4145
]
4246

@@ -63,17 +67,27 @@ select = ["ALL"]
6367
ignore = [
6468
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in {filename}
6569
"BLE001", # Do not catch blind exception
70+
"C901", # `{name}` is too complex
6671
"COM812", # This rule may cause conflicts when used with the formatter
6772
"D100", # Missing docstring in public module
6873
"D104", # Missing docstring in public package
6974
"EM", # flake8-errmsg
75+
"G004", # Logging statement uses f-string
7076
"ISC001", # This rule may cause conflicts when used with the formatter
7177
"FIX", # flake8-fixme
7278
"PGH003", # Use specific rule codes when ignoring type issues
79+
"PLR0911", # Too many return statements
7380
"PLR0913", # Too many arguments in function definition
81+
"PLR0915", # Too many statements
7482
"PTH", # flake8-use-pathlib
83+
"PYI034", # `__aenter__` methods in classes like `{name}` usually return `self` at runtime
84+
"PYI036", # The second argument in `__aexit__` should be annotated with `object` or `BaseException | None`
7585
"S102", # Use of `exec` detected
7686
"S105", # Possible hardcoded password assigned to
87+
"S106", # Possible hardcoded password assigned to argument: "{name}"
88+
"S301", # `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue
89+
"S303", # Use of insecure MD2, MD4, MD5, or SHA1 hash function
90+
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
7791
"TD002", # Missing author in TODO; try: `# TODO(<author_name>): ...` or `# TODO @<author_name>: ...
7892
"TID252", # Relative imports from parent modules are bannedRuff
7993
"TRY003", # Avoid specifying long messages outside the exception class
@@ -97,8 +111,9 @@ indent-style = "space"
97111
"D", # Everything from the pydocstyle
98112
"INP001", # File {filename} is part of an implicit namespace package, add an __init__.py
99113
"PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
100-
"T20", # flake8-print
101114
"S101", # Use of assert detected
115+
"T20", # flake8-print
116+
"TRY301", # Abstract `raise` to an inner function
102117
]
103118

104119
[tool.ruff.lint.flake8-quotes]

scripts/check_version_availability.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env python3
22

3+
from __future__ import annotations
4+
35
from utils import get_current_package_version, get_published_package_versions
46

57
# Checks whether the current package version number was not already used in a published release.

scripts/check_version_in_changelog.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env python3
22

3+
from __future__ import annotations
4+
35
import re
46

57
from utils import REPO_ROOT, get_current_package_version

scripts/print_current_package_version.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env python3
22

3+
from __future__ import annotations
4+
35
from utils import get_current_package_version
46

57
# Print the current package version from the pyproject.toml file to stdout

scripts/update_version_for_prerelease.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env python3
22

3+
from __future__ import annotations
4+
35
import re
46
import sys
57

scripts/utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import json
24
import pathlib
35
from urllib.error import HTTPError
@@ -27,11 +29,10 @@ def set_current_package_version(version: str) -> None:
2729
updated_pyproject_toml_file_lines = []
2830
version_string_found = False
2931
for line in pyproject_toml_file:
30-
processed_line = line
3132
if line.startswith('version = '):
3233
version_string_found = True
33-
processed_line = f'version = "{version}"\n'
34-
updated_pyproject_toml_file_lines.append(processed_line)
34+
line = f'version = "{version}"\n' # noqa: PLW2901
35+
updated_pyproject_toml_file_lines.append(line)
3536

3637
if not version_string_found:
3738
raise RuntimeError('Unable to find version string.')
@@ -48,8 +49,8 @@ def get_published_package_versions() -> list:
4849
package_data = json.load(urlopen(package_info_url)) # noqa: S310
4950
published_versions = list(package_data['releases'].keys())
5051
# If the URL returns 404, it means the package has no releases yet (which is okay in our case)
51-
except HTTPError as e:
52-
if e.code != 404:
52+
except HTTPError as exc:
53+
if exc.code != 404:
5354
raise
5455
published_versions = []
5556
return published_versions

0 commit comments

Comments
 (0)