Skip to content

Add Ruff and mypy configuration files #283

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2024
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
14 changes: 2 additions & 12 deletions check.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,9 @@ def run():
)
args = parser.parse_args()

# Lints:
# Sort imports
# Unused import
# Unused variable
check_args = ["--select", "I,F401,F841"]
check_args = []
format_args = []
mypy_args = [
"pythonbuild",
"check.py",
"build-linux.py",
"build-macos.py",
"build-windows.py",
]
mypy_args = []

if args.fix:
check_args.append("--fix")
Expand Down
9 changes: 9 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[mypy]
warn_no_return = True
warn_redundant_casts = True
warn_return_any = True
warn_unused_configs = True
warn_unused_ignores = True
warn_unreachable = True

files = pythonbuild,check.py,build-linux.py,build-macos.py,build-windows.py
12 changes: 5 additions & 7 deletions pythonbuild/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ def supported_targets(yaml_path: pathlib.Path):
targets = set()

for target, settings in get_targets(yaml_path).items():
for platform in settings["host_platforms"]:
if sys.platform == "linux" and platform == "linux64":
for host_platform in settings["host_platforms"]:
if sys.platform == "linux" and host_platform == "linux64":
targets.add(target)
elif sys.platform == "darwin" and platform == "macos":
elif sys.platform == "darwin" and host_platform == "macos":
targets.add(target)

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

local_name = local_name or url[url.rindex("/") + 1 :]

local_path = dest_path / local_name
local_path = dest_path / (local_name or url[url.rindex("/") + 1 :])
download_to_path(url, local_path, size, sha256)

return local_path
Expand Down Expand Up @@ -466,7 +464,7 @@ def add_licenses_to_extension_entry(entry):
if "path_static" in link or "path_dynamic" in link:
have_local_link = True

for key, value in DOWNLOADS.items():
for value in DOWNLOADS.values():
if name not in value.get("library_names", []):
continue

Expand Down
2 changes: 2 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[lint]
select = ["F", "I", "B"]
Loading