From be9369fbcc2217fd2a5ba7d91b39b373aad9d53e Mon Sep 17 00:00:00 2001 From: Nicholas Junge Date: Mon, 6 Jan 2025 17:06:55 +0100 Subject: [PATCH] cli: Render both mismatches and violations in the same table Previously, when violations were found (i.e. non-ABI3 symbols in an ABI3-tagged extension), any subsequent version mismatches (i.e. using symbols that were made part of the stable ABI, but in later versions than the provided wheel was built for), were left unreported. This is now fixed, by changing the audit rendering hook to include all offending symbols and their ABI versions. In case of a violation, the "not ABI3" value is given as ABI version, to clearly signal that the found symbol is not part of any version of the stable ABI. --- abi3audit/_audit.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/abi3audit/_audit.py b/abi3audit/_audit.py index b6884f8..8ac4f17 100644 --- a/abi3audit/_audit.py +++ b/abi3audit/_audit.py @@ -61,27 +61,30 @@ def __bool__(self) -> bool: return self.is_abi3() and self.is_abi3_baseline_compatible() def __rich_console__(self, console: Console, options: ConsoleOptions) -> RenderResult: - # Violating abi3 entirely is more "serious" than having the wrong abi3 - # version, so we check for it first when deciding the Rich representation. - if self.non_abi3_symbols: - yield f"[red]:thumbs_down: [green]{self.so}[/green] has non-ABI3 symbols" + """ + The rich representation of an audit result. - table = Table() - table.add_column("Symbol") - for sym in self.non_abi3_symbols: - table.add_row(sym.name) - - yield table - elif self.computed > self.baseline: - yield ( - f"[yellow]:thumbs_down: [green]{self.so}[/green] uses the Python " - f"[blue]{self.computed}[/blue] ABI, but is tagged for the Python " - f"[red]{self.baseline}[/red] ABI" - ) + If problems are found, renders a table of ABI3 violations/mismatches with + the name and ABI3 version (or a "not ABI3" marker) of each offending symbol. + If no problems are found, renders a short "OK" message. + """ + has_violations = self.non_abi3_symbols or self.computed > self.baseline + if has_violations: table = Table() table.add_column("Symbol") table.add_column("Version") + + if self.non_abi3_symbols: + yield f"[red]:thumbs_down: [green]{self.so}[/green] has non-ABI3 symbols" + if self.computed > self.baseline: + yield ( + f"[yellow]:thumbs_down: [green]{self.so}[/green] uses the Python " + f"[blue]{self.computed}[/blue] ABI, but is tagged for the Python " + f"[red]{self.baseline}[/red] ABI" + ) + for sym in self.non_abi3_symbols: + table.add_row(sym.name, "not ABI3") for obj in self.future_abi3_objects: table.add_row(obj.symbol.name, str(obj.added)) yield table