Skip to content

Commit c45df8f

Browse files
Revert "chore: do not use f-strings in logging statements (#32)"
This reverts commit b1dde9a.
1 parent b1dde9a commit c45df8f

14 files changed

+38
-50
lines changed

.git-blame-ignore-revs

-2
This file was deleted.

pyodide_build/_py_compile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def _compile(
114114
output_name = output_path.name
115115

116116
with set_log_level(logger, verbose):
117-
logger.debug("Running py-compile on %s to %s", input_path, output_path)
117+
logger.debug(f"Running py-compile on {input_path} to {output_path}")
118118

119119
if compression_level > 0:
120120
compression = zipfile.ZIP_DEFLATED

pyodide_build/bash_runner.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ def run(
7676
if cwd is None:
7777
cwd = Path.cwd()
7878
cwd = Path(cwd).absolute()
79-
logger.info("Running %s in %s", script_name, str(cwd))
79+
logger.info(f"Running {script_name} in {str(cwd)}")
8080
opts["cwd"] = cwd
8181
result = self.run_unchecked(cmd, **opts)
8282
if result.returncode != 0:
83-
logger.error("ERROR: %s failed", script_name)
83+
logger.error(f"ERROR: {script_name} failed")
8484
logger.error(textwrap.indent(cmd, " "))
8585
exit_with_stdio(result)
8686
return result

pyodide_build/buildall.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ def generate_dependency_graph(
434434

435435
if disabled_packages:
436436
logger.warning(
437-
"The following packages are disabled: %s", ", ".join(disabled_packages)
437+
f"The following packages are disabled: {', '.join(disabled_packages)}"
438438
)
439439

440440
return pkg_map
@@ -688,17 +688,17 @@ def build_from_graph(
688688

689689
if already_built:
690690
logger.info(
691-
"The following packages are already built: [bold]%s[/bold]",
692-
format_name_list(sorted(already_built)),
691+
"The following packages are already built: "
692+
f"[bold]{format_name_list(sorted(already_built))}[/bold]"
693693
)
694694
if not needs_build:
695695
logger.success("All packages already built. Quitting.")
696696
return
697697

698698
sorted_needs_build = sorted(needs_build)
699699
logger.info(
700-
"Building the following packages: [bold]%s[/bold]",
701-
format_name_list(sorted_needs_build),
700+
"Building the following packages: "
701+
f"[bold]{format_name_list(sorted_needs_build)}[/bold]"
702702
)
703703
build_state = _GraphBuilder(pkg_map, build_args, build_dir, set(needs_build))
704704
try:
@@ -850,14 +850,14 @@ def copy_logs(pkg_map: dict[str, BasePackage], log_dir: Path) -> None:
850850
"""
851851

852852
log_dir.mkdir(exist_ok=True, parents=True)
853-
logger.info("Copying build logs to %s", log_dir)
853+
logger.info(f"Copying build logs to {log_dir}")
854854

855855
for pkg in pkg_map.values():
856856
log_file = pkg.pkgdir / "build.log"
857857
if log_file.exists():
858858
shutil.copy(log_file, log_dir / f"{pkg.name}.log")
859859
else:
860-
logger.warning("Warning: %s has no build log", pkg.name)
860+
logger.warning(f"Warning: {pkg.name} has no build log")
861861

862862

863863
def install_packages(
@@ -881,7 +881,7 @@ def install_packages(
881881

882882
output_dir.mkdir(exist_ok=True, parents=True)
883883

884-
logger.info("Copying built packages to %s", output_dir)
884+
logger.info(f"Copying built packages to {output_dir}")
885885
copy_packages_to_dist_dir(
886886
pkg_map.values(),
887887
output_dir,
@@ -890,7 +890,7 @@ def install_packages(
890890
)
891891

892892
lockfile_path = output_dir / "pyodide-lock.json"
893-
logger.info("Writing pyodide-lock.json to %s", lockfile_path)
893+
logger.info(f"Writing pyodide-lock.json to {lockfile_path}")
894894

895895
package_data = generate_lockfile(output_dir, pkg_map)
896896
package_data.to_json(lockfile_path)

pyodide_build/buildpkg.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def build(self) -> None:
130130

131131
t0 = datetime.now()
132132
timestamp = t0.strftime("%Y-%m-%d %H:%M:%S")
133-
logger.info("[%s] Building package %s...", timestamp, self.name)
133+
logger.info(f"[{timestamp}] Building package {self.name}...")
134134
success = True
135135
try:
136136
self._build()
@@ -439,7 +439,7 @@ def _package_wheel(
439439
# Retag platformed wheels to pyodide
440440
wheel = retag_wheel(wheel, wheel_platform())
441441

442-
logger.info("Unpacking wheel to %s", str(wheel))
442+
logger.info(f"Unpacking wheel to {str(wheel)}")
443443

444444
name, ver, _ = wheel.name.split("-", 2)
445445

@@ -509,7 +509,7 @@ def _patch(self) -> None:
509509
cwd=self.src_extract_dir,
510510
)
511511
if result.returncode != 0:
512-
logger.error("ERROR: Patch %s failed", patch_abspath)
512+
logger.error(f"ERROR: Patch {patch_abspath} failed")
513513
exit_with_stdio(result)
514514

515515
# Add any extra files
@@ -612,7 +612,7 @@ def copy_sharedlibs(
612612
logger.info("Copied shared libraries:")
613613
for lib, path in dep_map_new.items():
614614
original_path = dep_map[lib]
615-
logger.info(" %s -> %s", original_path, path)
615+
logger.info(f" {original_path} -> {path}")
616616

617617
return dep_map_new
618618

@@ -695,7 +695,7 @@ def needs_rebuild(
695695
packaged_token = buildpath / ".packaged"
696696
if not packaged_token.is_file():
697697
logger.debug(
698-
"%s needs rebuild because %s does not exist", pkg_root, packaged_token
698+
f"{pkg_root} needs rebuild because {packaged_token} does not exist"
699699
)
700700
return True
701701

pyodide_build/cli/skeleton.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ def new_recipe_pypi(
8080
update_patched=update_patched,
8181
)
8282
except mkpkg.MkpkgFailedException as e:
83-
logger.error("%s update failed: %s", name, e)
83+
logger.error(f"{name} update failed: {e}")
8484
sys.exit(1)
8585
except mkpkg.MkpkgSkipped as e:
86-
logger.warning("%s update skipped: %s", name, e)
86+
logger.warning(f"{name} update skipped: {e}")
8787
except Exception:
8888
print(name)
8989
raise

pyodide_build/common.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def _has_python_file(subdir: zipfile.Path) -> bool:
101101

102102
if not top_level_imports:
103103
logger.warning(
104-
"WARNING: failed to parse top level import name from %s.", whlfile
104+
f"WARNING: failed to parse top level import name from {whlfile}."
105105
)
106106
return None
107107

@@ -293,7 +293,7 @@ def unpack_wheel(wheel_path: Path, target_dir: Path | None = None) -> None:
293293
encoding="utf-8",
294294
)
295295
if result.returncode != 0:
296-
logger.error("ERROR: Unpacking wheel %s failed", wheel_path.name)
296+
logger.error(f"ERROR: Unpacking wheel {wheel_path.name} failed")
297297
exit_with_stdio(result)
298298

299299

@@ -306,7 +306,7 @@ def pack_wheel(wheel_dir: Path, target_dir: Path | None = None) -> None:
306306
encoding="utf-8",
307307
)
308308
if result.returncode != 0:
309-
logger.error("ERROR: Packing wheel %s failed", wheel_dir)
309+
logger.error(f"ERROR: Packing wheel {wheel_dir} failed")
310310
exit_with_stdio(result)
311311

312312

@@ -348,7 +348,7 @@ def retag_wheel(wheel_path: Path, platform: str) -> Path:
348348
capture_output=True,
349349
)
350350
if result.returncode != 0:
351-
logger.error("ERROR: Retagging wheel %s to %s failed", wheel_path, platform)
351+
logger.error(f"ERROR: Retagging wheel {wheel_path} to {platform} failed")
352352
exit_with_stdio(result)
353353
return wheel_path.parent / result.stdout.splitlines()[-1].strip()
354354

pyodide_build/config.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ def _load_config_file(
110110
for key, v in configs["tool"]["pyodide"]["build"].items():
111111
if key not in OVERRIDABLE_BUILD_KEYS:
112112
logger.warning(
113-
"WARNING: The provided build key %s is either invalid or not overridable, hence ignored.",
114-
key,
113+
f"WARNING: The provided build key {key} is either invalid or not overridable, hence ignored."
115114
)
116115
continue
117116
build_config[key] = _environment_substitute_str(v, env)

pyodide_build/mkpkg.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def make_package(
151151
Creates a template that will work for most pure Python packages,
152152
but will have to be edited for more complex things.
153153
"""
154-
logger.info("Creating meta.yaml package for %s", package)
154+
logger.info(f"Creating meta.yaml package for {package}")
155155

156156
yaml = YAML()
157157

@@ -226,7 +226,7 @@ def update_package(
226226

227227
meta_path = root / package / "meta.yaml"
228228
if not meta_path.exists():
229-
logger.error("%s does not exist", meta_path)
229+
logger.error(f"{meta_path} does not exist")
230230
raise MkpkgFailedException(f"{package} recipe not found at {meta_path}")
231231

232232
yaml_content = yaml.load(meta_path.read_bytes())
@@ -281,19 +281,16 @@ def update_package(
281281
return
282282

283283
logger.info(
284-
"%s is out of date: either %s < %s or checksums might have mismatched: received %s against local %s 🚨",
285-
package,
286-
local_ver,
287-
pypi_ver,
288-
sha256,
289-
sha256_local,
284+
f"{package} is out of date:"
285+
f" either {local_ver} < {pypi_ver}"
286+
f" or checksums might have mismatched: received {sha256} against local {sha256_local} 🚨"
290287
)
291288

292289
if yaml_content["source"].get("patches"):
293290
if update_patched:
294291
logger.warning(
295-
"Pyodide applies patches to %s. Update the patches (if needed) to avoid build failing.",
296-
package,
292+
f"Pyodide applies patches to {package}. Update the "
293+
"patches (if needed) to avoid build failing."
297294
)
298295
else:
299296
raise MkpkgFailedException(

pyodide_build/out_of_tree/pypi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def _get_built_wheel_internal(url):
9595
source_path = build_path / files[0]
9696
else:
9797
source_path = build_path
98-
logger.info("Building wheel for %s...", gz_name)
98+
logger.info(f"Building wheel for {gz_name}...")
9999
with (
100100
tempfile.NamedTemporaryFile(mode="w+") as logfile,
101101
stream_redirected(to=logfile, stream=sys.stdout),

pyodide_build/out_of_tree/venv.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,11 @@ def install_stdlib(venv_bin: Path) -> None:
254254

255255
def create_pyodide_venv(dest: Path) -> None:
256256
"""Create a Pyodide virtualenv and store it into dest"""
257-
logger.info("Creating Pyodide virtualenv at %s", dest)
257+
logger.info(f"Creating Pyodide virtualenv at {dest}")
258258
from virtualenv import session_via_cli
259259

260260
if dest.exists():
261-
logger.error("ERROR: dest directory '%s' already exists", dest)
261+
logger.error(f"ERROR: dest directory '{dest}' already exists")
262262
sys.exit(1)
263263

264264
interp_path = pyodide_dist_dir() / "python"

pyodide_build/recipe.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,8 @@ def load_recipes(
8787

8888
elif name_or_tag in ("core", "min-scipy-stack"):
8989
logger.warning(
90-
"Using meta package without the 'tag:' prefix is deprecated, "
91-
"use 'tag:%s' instead.",
92-
name_or_tag,
90+
f"Using meta package without the 'tag:' prefix is deprecated,"
91+
f" use 'tag:{name_or_tag}' instead."
9392
)
9493
for recipe in tagged_recipes[name_or_tag]:
9594
recipes[recipe.package.name] = recipe.model_copy(deep=True)

pyodide_build/xbuildenv.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def use_version(self, version: str) -> None:
106106
version
107107
The version of xbuildenv to use.
108108
"""
109-
logger.info("Using Pyodide cross-build environment version: %s", version)
109+
logger.info(f"Using Pyodide cross-build environment version: {version}")
110110

111111
version_path = self._path_for_version(version)
112112
if not version_path.exists():
@@ -358,8 +358,7 @@ def _create_package_index(self, xbuildenv_pyodide_root: Path, version: str) -> N
358358

359359
if not lockfile_path.exists():
360360
logger.warning(
361-
"Pyodide lockfile not found at %s. Skipping PyPI index creation",
362-
lockfile_path,
361+
f"Pyodide lockfile not found at {lockfile_path}. Skipping PyPI index creation"
363362
)
364363
return
365364

pyproject.toml

-4
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,7 @@ lint.select = [
125125
"PLC", # pylint conventions
126126
"PLE", # pylint errors
127127
"UP", # pyupgrade
128-
"G004", # f-string logging should be avoided
129128
]
130-
131-
lint.logger-objects = ["pyodide_build.logger.logger"]
132-
133129
lint.ignore = ["E402", "E501", "E731", "E741", "UP038"]
134130
# line-length = 219 # E501: Recommended goal is 88 to match black
135131
target-version = "py311"

0 commit comments

Comments
 (0)