chore: some cleanup from ruff --preview checks
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
committed by
Henry Schreiner
parent
2f62696400
commit
183a7c3f1d
@@ -160,7 +160,7 @@ def main_inner(global_options: GlobalOptions) -> None:
|
||||
parser.add_argument(
|
||||
"package_dir",
|
||||
metavar="PACKAGE",
|
||||
default=Path("."),
|
||||
default=Path(),
|
||||
type=Path,
|
||||
nargs="?",
|
||||
help="""
|
||||
|
||||
@@ -710,7 +710,7 @@ def build(options: Options, tmp_path: Path) -> None:
|
||||
# and not the repo code)
|
||||
test_command_prepared = prepare_command(
|
||||
build_options.test_command,
|
||||
project=Path(".").resolve(),
|
||||
project=Path.cwd(),
|
||||
package=build_options.package_dir.resolve(),
|
||||
wheel=repaired_wheel,
|
||||
)
|
||||
@@ -728,7 +728,7 @@ def build(options: Options, tmp_path: Path) -> None:
|
||||
)
|
||||
else:
|
||||
# There are no test sources. Run the tests in the project directory.
|
||||
test_cwd = Path(".").resolve()
|
||||
test_cwd = Path.cwd()
|
||||
|
||||
shell_with_arch(test_command_prepared, cwd=test_cwd, env=virtualenv_env)
|
||||
|
||||
@@ -738,7 +738,7 @@ def build(options: Options, tmp_path: Path) -> None:
|
||||
moved_wheel = move_file(repaired_wheel, output_wheel)
|
||||
if moved_wheel != output_wheel.resolve():
|
||||
log.warning(
|
||||
"{repaired_wheel} was moved to {moved_wheel} instead of {output_wheel}"
|
||||
f"{repaired_wheel} was moved to {moved_wheel} instead of {output_wheel}"
|
||||
)
|
||||
built_wheels.append(output_wheel)
|
||||
|
||||
|
||||
+14
-11
@@ -73,7 +73,7 @@ class CommandLineArguments:
|
||||
only=None,
|
||||
config_file="",
|
||||
output_dir=Path("wheelhouse"),
|
||||
package_dir=Path("."),
|
||||
package_dir=Path(),
|
||||
print_build_identifiers=False,
|
||||
debug_traceback=False,
|
||||
enable=[],
|
||||
@@ -184,7 +184,7 @@ class ListFormat(OptionFormat):
|
||||
|
||||
def __init__(self, sep: str, quote: Callable[[str], str] | None = None) -> None:
|
||||
self.sep = sep
|
||||
self.quote = quote if quote else lambda s: s
|
||||
self.quote = quote or (lambda s: s)
|
||||
|
||||
def format_list(self, value: SettingList) -> str:
|
||||
return self.sep.join(self.quote(str(v)) for v in value)
|
||||
@@ -265,10 +265,12 @@ class EnvironmentFormat(OptionFormat):
|
||||
values may contain variables or command substitutions.
|
||||
"""
|
||||
|
||||
def format_table(self, table: SettingTable) -> str:
|
||||
@staticmethod
|
||||
def format_table(table: SettingTable) -> str:
|
||||
return " ".join(f'{k}="{v}"' for k, v in table.items())
|
||||
|
||||
def merge_values(self, before: str, after: str) -> str:
|
||||
@staticmethod
|
||||
def merge_values(before: str, after: str) -> str:
|
||||
return f"{before} {after}"
|
||||
|
||||
|
||||
@@ -630,8 +632,7 @@ class Options:
|
||||
)
|
||||
try:
|
||||
enable = {EnableGroup(group) for group in enable_groups.split()}
|
||||
for command_line_group in args.enable:
|
||||
enable.add(EnableGroup(command_line_group))
|
||||
enable.update(EnableGroup(command_line_group) for command_line_group in args.enable)
|
||||
except ValueError as e:
|
||||
msg = f"Failed to parse enable group. {e}. Valid group names are: {', '.join(g.value for g in EnableGroup)}"
|
||||
raise errors.ConfigurationError(msg) from e
|
||||
@@ -737,9 +738,9 @@ class Options:
|
||||
environment.add(env_var_name, self.env[env_var_name], prepend=True)
|
||||
|
||||
if dependency_versions == "pinned":
|
||||
dependency_constraints: None | (
|
||||
DependencyConstraints
|
||||
) = DependencyConstraints.with_defaults()
|
||||
dependency_constraints: DependencyConstraints | None = (
|
||||
DependencyConstraints.with_defaults()
|
||||
)
|
||||
elif dependency_versions == "latest":
|
||||
dependency_constraints = None
|
||||
else:
|
||||
@@ -932,13 +933,15 @@ class Options:
|
||||
|
||||
return result
|
||||
|
||||
def indent_if_multiline(self, value: str, indent: str) -> str:
|
||||
@staticmethod
|
||||
def indent_if_multiline(value: str, indent: str) -> str:
|
||||
if "\n" in value:
|
||||
return "\n" + textwrap.indent(value.strip(), indent)
|
||||
else:
|
||||
return value
|
||||
|
||||
def option_summary_value(self, option_value: Any) -> str:
|
||||
@staticmethod
|
||||
def option_summary_value(option_value: Any) -> str:
|
||||
if hasattr(option_value, "options_summary"):
|
||||
option_value = option_value.options_summary()
|
||||
|
||||
|
||||
@@ -292,8 +292,8 @@ def build(options: Options, tmp_path: Path) -> None:
|
||||
# directory.
|
||||
oldmounts = ""
|
||||
extra_mounts = [str(identifier_tmp_dir)]
|
||||
if str(Path(".").resolve()).startswith("/tmp"):
|
||||
extra_mounts.append(str(Path(".").resolve()))
|
||||
if str(Path.cwd()).startswith("/tmp"):
|
||||
extra_mounts.append(str(Path.cwd()))
|
||||
|
||||
if "_PYODIDE_EXTRA_MOUNTS" in env:
|
||||
oldmounts = env["_PYODIDE_EXTRA_MOUNTS"] + ":"
|
||||
@@ -413,7 +413,7 @@ def build(options: Options, tmp_path: Path) -> None:
|
||||
# and not the repo code)
|
||||
test_command_prepared = prepare_command(
|
||||
build_options.test_command,
|
||||
project=Path(".").resolve(),
|
||||
project=Path.cwd(),
|
||||
package=build_options.package_dir.resolve(),
|
||||
)
|
||||
|
||||
@@ -427,7 +427,7 @@ def build(options: Options, tmp_path: Path) -> None:
|
||||
)
|
||||
else:
|
||||
# There are no test sources. Run the tests in the project directory.
|
||||
test_cwd = Path(".").resolve()
|
||||
test_cwd = Path.cwd()
|
||||
|
||||
shell(test_command_prepared, cwd=test_cwd, env=virtualenv_env)
|
||||
|
||||
@@ -437,7 +437,7 @@ def build(options: Options, tmp_path: Path) -> None:
|
||||
moved_wheel = move_file(repaired_wheel, output_wheel)
|
||||
if moved_wheel != output_wheel.resolve():
|
||||
log.warning(
|
||||
"{repaired_wheel} was moved to {moved_wheel} instead of {output_wheel}"
|
||||
f"{repaired_wheel} was moved to {moved_wheel} instead of {output_wheel}"
|
||||
)
|
||||
built_wheels.append(output_wheel)
|
||||
|
||||
|
||||
@@ -53,8 +53,7 @@ class BuildSelector:
|
||||
# Filter build selectors by python_requires if set
|
||||
if self.requires_python is not None:
|
||||
py_ver_str = build_id.split("-")[0]
|
||||
if py_ver_str.endswith("t"):
|
||||
py_ver_str = py_ver_str[:-1]
|
||||
py_ver_str = py_ver_str.removesuffix("t")
|
||||
major = int(py_ver_str[2])
|
||||
minor = int(py_ver_str[3:])
|
||||
version = Version(f"{major}.{minor}.99")
|
||||
|
||||
@@ -151,7 +151,8 @@ class FlexibleVersion:
|
||||
# Normalize by removing trailing zeros
|
||||
self.version_parts = self._remove_trailing_zeros(self.version_parts)
|
||||
|
||||
def _remove_trailing_zeros(self, parts: tuple[int, ...]) -> tuple[int, ...]:
|
||||
@staticmethod
|
||||
def _remove_trailing_zeros(parts: tuple[int, ...]) -> tuple[int, ...]:
|
||||
# Remove trailing zeros for accurate comparisons
|
||||
# without this, "3.0" would be considered greater than "3"
|
||||
while parts and parts[-1] == 0:
|
||||
|
||||
@@ -546,7 +546,7 @@ def build(options: Options, tmp_path: Path) -> None:
|
||||
# and not the repo code)
|
||||
test_command_prepared = prepare_command(
|
||||
build_options.test_command,
|
||||
project=Path(".").resolve(),
|
||||
project=Path.cwd(),
|
||||
package=options.globals.package_dir.resolve(),
|
||||
wheel=repaired_wheel,
|
||||
)
|
||||
@@ -560,7 +560,7 @@ def build(options: Options, tmp_path: Path) -> None:
|
||||
)
|
||||
else:
|
||||
# There are no test sources. Run the tests in the project directory.
|
||||
test_cwd = Path(".").resolve()
|
||||
test_cwd = Path.cwd()
|
||||
|
||||
shell(test_command_prepared, cwd=test_cwd, env=virtualenv_env)
|
||||
|
||||
@@ -570,7 +570,7 @@ def build(options: Options, tmp_path: Path) -> None:
|
||||
moved_wheel = move_file(repaired_wheel, output_wheel)
|
||||
if moved_wheel != output_wheel.resolve():
|
||||
log.warning(
|
||||
"{repaired_wheel} was moved to {moved_wheel} instead of {output_wheel}"
|
||||
f"{repaired_wheel} was moved to {moved_wheel} instead of {output_wheel}"
|
||||
)
|
||||
built_wheels.append(output_wheel)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user