Skip to content

Commit dfc282c

Browse files
Add Ruff and mypy configuration files (#283)
## Summary I think it's useful that running `ruff check` or `mypy` enforces the configuration we enforce in CI.
1 parent aec9cbf commit dfc282c

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

check.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,9 @@ def run():
5454
)
5555
args = parser.parse_args()
5656

57-
# Lints:
58-
# Sort imports
59-
# Unused import
60-
# Unused variable
61-
check_args = ["--select", "I,F401,F841"]
57+
check_args = []
6258
format_args = []
63-
mypy_args = [
64-
"pythonbuild",
65-
"check.py",
66-
"build-linux.py",
67-
"build-macos.py",
68-
"build-windows.py",
69-
]
59+
mypy_args = []
7060

7161
if args.fix:
7262
check_args.append("--fix")

mypy.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[mypy]
2+
warn_no_return = True
3+
warn_redundant_casts = True
4+
warn_return_any = True
5+
warn_unused_configs = True
6+
warn_unused_ignores = True
7+
warn_unreachable = True
8+
9+
files = pythonbuild,check.py,build-linux.py,build-macos.py,build-windows.py

pythonbuild/utils.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ def supported_targets(yaml_path: pathlib.Path):
4444
targets = set()
4545

4646
for target, settings in get_targets(yaml_path).items():
47-
for platform in settings["host_platforms"]:
48-
if sys.platform == "linux" and platform == "linux64":
47+
for host_platform in settings["host_platforms"]:
48+
if sys.platform == "linux" and host_platform == "linux64":
4949
targets.add(target)
50-
elif sys.platform == "darwin" and platform == "macos":
50+
elif sys.platform == "darwin" and host_platform == "macos":
5151
targets.add(target)
5252

5353
return targets
@@ -305,9 +305,7 @@ def download_entry(key: str, dest_path: pathlib.Path, local_name=None) -> pathli
305305
assert isinstance(size, int)
306306
assert isinstance(sha256, str)
307307

308-
local_name = local_name or url[url.rindex("/") + 1 :]
309-
310-
local_path = dest_path / local_name
308+
local_path = dest_path / (local_name or url[url.rindex("/") + 1 :])
311309
download_to_path(url, local_path, size, sha256)
312310

313311
return local_path
@@ -466,7 +464,7 @@ def add_licenses_to_extension_entry(entry):
466464
if "path_static" in link or "path_dynamic" in link:
467465
have_local_link = True
468466

469-
for key, value in DOWNLOADS.items():
467+
for value in DOWNLOADS.values():
470468
if name not in value.get("library_names", []):
471469
continue
472470

ruff.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[lint]
2+
select = ["F", "I", "B"]

0 commit comments

Comments
 (0)