chore: add pathlib check
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
committed by
Henry Schreiner
parent
3e37148923
commit
783be9bc2f
+1
-2
@@ -7,7 +7,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import glob
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -86,7 +85,7 @@ def bump_version() -> None:
|
||||
actions = []
|
||||
|
||||
for path_pattern, version_pattern in config:
|
||||
paths = [Path(p) for p in glob.glob(path_pattern)]
|
||||
paths = list(Path().glob(path_pattern))
|
||||
|
||||
if not paths:
|
||||
print(f"error: Pattern {path_pattern} didn't match any files")
|
||||
|
||||
@@ -56,7 +56,7 @@ def main() -> None:
|
||||
f"""
|
||||
Update the versions of our dependencies.
|
||||
|
||||
PR generated by `{os.path.basename(__file__)}`.
|
||||
PR generated by `{Path(__file__).name}`.
|
||||
"""
|
||||
)
|
||||
subprocess.run(
|
||||
|
||||
@@ -9,12 +9,13 @@ import sys
|
||||
import textwrap
|
||||
import time
|
||||
import typing
|
||||
from glob import glob
|
||||
from pathlib import Path
|
||||
from urllib.parse import quote
|
||||
|
||||
import click
|
||||
|
||||
DIR = Path(__file__).parent.resolve()
|
||||
|
||||
|
||||
def shell(cmd: str, *, check: bool, **kwargs: object) -> subprocess.CompletedProcess[str]:
|
||||
return subprocess.run([cmd], shell=True, check=check, **kwargs) # type: ignore[call-overload, no-any-return]
|
||||
@@ -79,9 +80,8 @@ services = [
|
||||
]
|
||||
|
||||
|
||||
def ci_service_for_config_file(config_file: str) -> CIService:
|
||||
filename = Path(config_file).name
|
||||
|
||||
def ci_service_for_config_file(config_file: Path) -> CIService:
|
||||
filename = config_file.name
|
||||
try:
|
||||
return next(s for s in services if filename.startswith(s.name))
|
||||
except StopIteration:
|
||||
@@ -98,16 +98,16 @@ def run_example_ci_configs(config_files=None):
|
||||
"""
|
||||
|
||||
if len(config_files) == 0:
|
||||
config_files = glob("examples/*-minimal.yml")
|
||||
config_files = Path("examples").glob("*-minimal.yml")
|
||||
|
||||
# check each CI service has at most 1 config file
|
||||
configs_by_service = {}
|
||||
configs_by_service = set()
|
||||
for config_file in config_files:
|
||||
service = ci_service_for_config_file(config_file)
|
||||
if service.name in configs_by_service:
|
||||
msg = "You cannot specify more than one config per CI service"
|
||||
raise Exception(msg)
|
||||
configs_by_service[service.name] = config_file
|
||||
configs_by_service.add(service.name)
|
||||
|
||||
if git_repo_has_changes():
|
||||
print("Your git repo has uncommitted changes. Commit or stash before continuing.")
|
||||
@@ -128,18 +128,17 @@ def run_example_ci_configs(config_files=None):
|
||||
|
||||
for config_file in config_files:
|
||||
service = ci_service_for_config_file(config_file)
|
||||
src_config_file = Path(config_file)
|
||||
dst_config_file = example_project / service.dst_config_path
|
||||
|
||||
dst_config_file.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copyfile(src_config_file, dst_config_file)
|
||||
shutil.copyfile(config_file, dst_config_file)
|
||||
|
||||
subprocess.run(["git", "add", example_project], check=True)
|
||||
message = textwrap.dedent(
|
||||
f"""\
|
||||
Test example minimal configs
|
||||
|
||||
Testing files: {config_files}
|
||||
Testing files: {[str(f) for f in config_files]}
|
||||
Generated from branch: {previous_branch}
|
||||
Time: {timestamp}
|
||||
"""
|
||||
@@ -174,6 +173,5 @@ def run_example_ci_configs(config_files=None):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
os.chdir("..")
|
||||
os.chdir(DIR)
|
||||
run_example_ci_configs(standalone_mode=True)
|
||||
|
||||
@@ -292,7 +292,7 @@ def build(options: Options, tmp_path: Path) -> None:
|
||||
# directory.
|
||||
oldmounts = ""
|
||||
extra_mounts = [str(identifier_tmp_dir)]
|
||||
if str(Path.cwd()).startswith("/tmp"):
|
||||
if Path.cwd().is_relative_to("/tmp"):
|
||||
extra_mounts.append(str(Path.cwd()))
|
||||
|
||||
if "_PYODIDE_EXTRA_MOUNTS" in env:
|
||||
|
||||
+4
-1
@@ -190,6 +190,7 @@ extend-select = [
|
||||
"PIE", # flake8-pie
|
||||
"PL", # pylint
|
||||
"PT", # flake8-pytest-style
|
||||
"PTH", # flake8-use-pathlib
|
||||
"RET", # flake8-return
|
||||
"RUF", # Ruff-specific
|
||||
"SIM", # flake8-simplify
|
||||
@@ -206,6 +207,7 @@ ignore = [
|
||||
"PYI025", # Set as AbstractSet
|
||||
"ISC001", # Conflicts with formatter
|
||||
"EXE003", # Ruff doesn't like uv?
|
||||
"PTH123", # open -> Path.open
|
||||
]
|
||||
flake8-unused-arguments.ignore-variadic-names = true
|
||||
|
||||
@@ -219,9 +221,10 @@ flake8-unused-arguments.ignore-variadic-names = true
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"unit_test/*" = ["PLC1901"]
|
||||
"bin/*" = ["TID251"]
|
||||
"cibuildwheel/resources/install_certifi.py" = ["PTH"]
|
||||
|
||||
[tool.repo-review]
|
||||
ignore = ["PC170", "PP303"]
|
||||
|
||||
[tool.check-wheel-contents]
|
||||
ignore = ["W002"] # requirements-*.txt are allowed to be duplicates of one another
|
||||
ignore = ["W002"] # constraints-*.txt are allowed to be duplicates of one another
|
||||
|
||||
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
import os
|
||||
import subprocess
|
||||
import textwrap
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -16,8 +17,8 @@ def skip_if_no_msvc(arm64: bool = False) -> None:
|
||||
if not programfiles:
|
||||
pytest.skip("Requires %PROGRAMFILES(X86)% variable to be set")
|
||||
|
||||
vswhere = os.path.join(programfiles, "Microsoft Visual Studio", "Installer", "vswhere.exe")
|
||||
if not os.path.isfile(vswhere):
|
||||
vswhere = Path(programfiles, "Microsoft Visual Studio", "Installer", "vswhere.exe")
|
||||
if not vswhere.is_file():
|
||||
pytest.skip("Requires Visual Studio installation")
|
||||
|
||||
require = "Microsoft.VisualStudio.Component.VC.Tools.x86.x64"
|
||||
|
||||
Reference in New Issue
Block a user