From 471c4fc02aaa5d8516485ea0151a2c13493f9105 Mon Sep 17 00:00:00 2001 From: Claude Code Date: Wed, 2 Sep 2026 19:22:03 +0000 Subject: [PATCH] Don't reuse the f-string's quote inside its expression Two sites, and one of them is package code. **'pyEDAA/OutputFilter/CLI/Configuration.py'** could not be imported on Python 3.11: ConfigurationWarning(f"tools.vivado.policies.hasLatches: Unknown value '{policies["hasLatches"]}'.")) Reusing the f-string's own quote character inside a replacement field is PEP 701, which is Python **3.12**. It is a 'SyntaxError' raised at import, so the whole module goes with it - and this repository's pipeline lists 3.11 in 'unittest_python_version_list'. CI stayed green because nothing in 'tests/unit' imports 'pyEDAA.OutputFilter.CLI'; 'tests/app' reaches it as a subprocess module, so a 3.11 user running the CLI hits it, not the testsuite. **'doc/conf.py'** built the LaTeX title the same way, and worse - it also puts a backslash in the replacement field, which is the other thing 3.12 started accepting: f"The {pythonProject.replace("_", r"\_")} Documentation", Both are marked '# WORKAROUND: Python <3.12' with the 3.12+ form kept in the comment, so dropping 3.11 is a search for the marker. Neither changes what is produced - the warning text and the rendered title are identical. Found with '/work/_tools/CheckFStrings.py' after the same construct broke all 31 Python 3.11 jobs of 'pyTooling/pyTooling'. tests/unit: 75 passed, 2 xpassed. Co-Authored-By: Patrick Lehmann --- doc/conf.py | 9 ++++++++- pyEDAA/OutputFilter/CLI/Configuration.py | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index a131d01..0c229ae 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -139,13 +139,20 @@ "printindex": r"\def\twocolumn[#1]{#1}\printindex", } +# WORKAROUND: Python <3.12 +# Reusing the f-string's own quote character inside its expression - and a backslash in it - both need PEP 701. +# The escaped project name is built first, so this file still parses on Python 3.11. +# Replace by inlining it again: +# f"The {pythonProject.replace("_", r"\_")} Documentation", +latexProject = pythonProject.replace("_", r"\_") + # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ ( master_doc, f"{pythonProject}.tex", - f"The {pythonProject.replace("_", r"\_")} Documentation", + f"The {latexProject} Documentation", "Patrick Lehmann", "manual" ), diff --git a/pyEDAA/OutputFilter/CLI/Configuration.py b/pyEDAA/OutputFilter/CLI/Configuration.py index beea625..f6d77dc 100644 --- a/pyEDAA/OutputFilter/CLI/Configuration.py +++ b/pyEDAA/OutputFilter/CLI/Configuration.py @@ -703,8 +703,14 @@ def _ParsePolicies(self, policies: CommentedMap) -> None: if policies["hasLatches"] == "error": self._hasLatches = Action.Error else: + # WORKAROUND: Python <3.12 + # Reusing the f-string's own quote character inside its expression needs PEP 701. On Python 3.11 + # this is a 'SyntaxError' raised at import, which takes the whole module with it. + # Replace by: + # ConfigurationWarning(f"tools.vivado.policies.hasLatches: Unknown value '{policies["hasLatches"]}'.")) + hasLatches = policies["hasLatches"] WarningCollector.Raise( - ConfigurationWarning(f"tools.vivado.policies.hasLatches: Unknown value '{policies["hasLatches"]}'.")) + ConfigurationWarning(f"tools.vivado.policies.hasLatches: Unknown value '{hasLatches}'.")) def _ParseRuleSetAction(self, actionConfig: Any) -> LineAction: if not isinstance(actionConfig, str):