Skip to content

Commit 954a634

Browse files
Merge branch 'main' into improves-diversity
2 parents d2eac91 + 37fc28f commit 954a634

26 files changed

Lines changed: 1025 additions & 868 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ jobs:
3535

3636
- name: Run static analysis
3737
run: |
38-
# hatch fmt --check
39-
echo linter errors will be fixed in a separate PR
38+
hatch fmt --linter --check
4039
4140
- name: Run tests
4241
run: hatch test --python ${{ matrix.python-version }} --cover --randomize --parallel --retries 2 --retry-delay 1

pyproject.toml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,92 @@ exclude_lines = [
145145
"if __name__ == .__main__.:",
146146
"if TYPE_CHECKING:",
147147
]
148+
149+
[tool.ruff]
150+
# Set target version to 3.10 to support match statements
151+
target-version = "py310"
152+
153+
[tool.ruff.lint]
154+
# Suppress all current linter errors to establish a baseline
155+
ignore = [
156+
"A001", # Variable shadows built-in
157+
"A002", # Argument shadows built-in
158+
"A004", # Import shadows built-in
159+
"ARG001", # Unused function argument
160+
"B006", # Mutable default argument
161+
"B007", # Unused loop control variable
162+
"B008", # Function call in argument defaults
163+
"B023", # Function uses loop variable
164+
"B904", # raise-without-from-inside-except
165+
"BLE001", # Blind except
166+
"C405", # Unnecessary literal set
167+
"C416", # Unnecessary comprehension
168+
"E721", # Type comparison using ==
169+
"E722", # Bare except
170+
"E741", # Ambiguous variable name
171+
"EM101", # Exception string literal
172+
"EM102", # Exception f-string
173+
"F401", # Unused import
174+
"F541", # f-string without placeholders
175+
"F811", # Redefinition of unused name
176+
"F821", # Undefined name
177+
"F841", # Unused variable
178+
"FA100", # Missing from __future__ import annotations
179+
"FA102", # Missing from __future__ import annotations in stub
180+
"FBT001", # Boolean positional arg in function definition
181+
"FBT002", # Boolean default value in function definition
182+
"FURB188", # Prefer removeprefix over conditional slice
183+
"G004", # Logging with f-string
184+
"I001", # Import block unsorted or unformatted
185+
"INP001", # Implicit namespace package
186+
"LOG015", # root logger usage
187+
"N801", # Class name should use CapWords convention
188+
"N802", # Function name should be lowercase
189+
"N806", # Variable in function should be lowercase
190+
"N818", # Exception name should end with Error
191+
"PERF102", # Use keys() or values() instead of items()
192+
"PERF401", # Use list comprehension
193+
"PIE790", # Unnecessary pass statement
194+
"PLC0415", # Import should be at top of file
195+
"PLC1802", # Use of len(x) == 0
196+
"PLR2004", # Magic value used in comparison
197+
"PLW0602", # Global variable not assigned
198+
"PLW0603", # Using global statement
199+
"PLW1508", # Invalid envvar default
200+
"PLW2901", # Outer loop variable overwritten
201+
"PT011", # pytest.raises too broad
202+
"PYI041", # Use float instead of int | float
203+
"RET503", # Missing explicit return
204+
"RET504", # Unnecessary assignment before return
205+
"RET505", # Unnecessary else after return
206+
"RET506", # Unnecessary else after raise
207+
"RUF005", # Unpack instead of concatenation
208+
"RUF010", # Use explicit conversion flag
209+
"RUF015", # Prefer next() over single element slice
210+
"RUF059", # Use of private function/attribute
211+
"RUF100", # Unused noqa directive
212+
"S108", # Hardcoded temp file/directory
213+
"S607", # Starting process with partial path
214+
"SIM102", # Use single if statement
215+
"SIM115", # Use context handler for file
216+
"SIM210", # Use ternary operator
217+
"SLF001", # Private member access
218+
"T201", # print found
219+
"TID252", # Relative imports from parent modules
220+
"TRY003", # Raise vanilla args
221+
"TRY004", # Prefer TypeError for wrong type
222+
"TRY300", # Consider moving statement to else
223+
"TRY301", # Abstract raise to inner function
224+
"TRY400", # Use logging.exception instead of logging.error
225+
"UP004", # Use X | Y for union types
226+
"UP006", # Use X | Y for union types in isinstance
227+
"UP009", # UTF-8 encoding declaration
228+
"UP015", # Unnecessary mode argument
229+
"UP020", # Use builtin open
230+
"UP024", # Replace aliased errors with OSError
231+
"UP032", # Use f-string
232+
"UP035", # Import from collections.abc
233+
"UP045", # Use X | None for type annotations
234+
"W291", # Trailing whitespace
235+
"W293", # Blank line contains whitespace
236+
]

release_tools/copy_files.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import sys
77
import subprocess
88

9+
910
def read_file_list(list_path):
1011
"""
1112
Reads a file containing file paths, ignoring empty lines and lines starting with '#'.
@@ -15,6 +16,7 @@ def read_file_list(list_path):
1516
lines = [line.strip() for line in f]
1617
return [line for line in lines if line and not line.startswith("#")]
1718

19+
1820
def copy_files(file_list, dest_dir):
1921
"""
2022
Copy files listed in file_list to dest_dir, preserving their relative paths.
@@ -29,6 +31,7 @@ def copy_files(file_list, dest_dir):
2931
shutil.copy2(abs_src, abs_dest)
3032
print(f"Copied {abs_src} -> {abs_dest}")
3133

34+
3235
def ensure_git_repo(dest_dir):
3336
"""
3437
Initializes a git repository in dest_dir if it's not already a git repo.
@@ -56,6 +59,7 @@ def ensure_git_repo(dest_dir):
5659
print(f"Failed to ensure 'main' branch in {dest_dir}: {e}")
5760
sys.exit(1)
5861

62+
5963
def git_add_files(file_list, dest_dir):
6064
"""
6165
Runs 'git add' on each file in file_list within dest_dir.
@@ -72,6 +76,7 @@ def git_add_files(file_list, dest_dir):
7276
finally:
7377
os.chdir(cwd)
7478

79+
7580
if __name__ == "__main__":
7681
if len(sys.argv) != 3:
7782
print("Usage: python copy_files.py <file_list.txt> <dest_dir>")

release_tools/publish_docker.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,34 @@
66
import subprocess
77
import sys
88

9+
910
def get_image_digest(image_name, tag):
1011
result = subprocess.run(
1112
["docker", "buildx", "imagetools", "inspect", f"{image_name}:{tag}"],
12-
stdout=subprocess.PIPE, check=True, text=True
13+
stdout=subprocess.PIPE,
14+
check=True,
15+
text=True,
1316
)
1417
for line in result.stdout.splitlines():
1518
if line.strip().startswith("Digest:"):
1619
return line.strip().split(":", 1)[1].strip()
1720
return None
1821

22+
1923
def build_and_push_image(dest_dir, image_name, tag):
2024
# Build
21-
subprocess.run([
22-
"docker", "buildx", "build", "--platform", "linux/amd64", "-t", f"{image_name}:{tag}", dest_dir
23-
], check=True)
25+
subprocess.run(
26+
["docker", "buildx", "build", "--platform", "linux/amd64", "-t", f"{image_name}:{tag}", dest_dir], check=True
27+
)
2428
# Push
25-
subprocess.run([
26-
"docker", "push", f"{image_name}:{tag}"
27-
], check=True)
29+
subprocess.run(["docker", "push", f"{image_name}:{tag}"], check=True)
2830
print(f"Pushed {image_name}:{tag}")
2931
digest = get_image_digest(image_name, tag)
3032
print(f"Image digest: {digest}")
3133
with open("/tmp/digest.txt", "w") as f:
3234
f.write(digest)
3335

36+
3437
if __name__ == "__main__":
3538
if len(sys.argv) != 3:
3639
print("Usage: python build_and_publish_docker.py <ghcr_username/repo> <tag>")

0 commit comments

Comments
 (0)