Skip to content

Redundant f-string in graphlib.TopologicalSorter prepare method. #115238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kyurais opened this issue Feb 10, 2024 · 0 comments
Closed

Redundant f-string in graphlib.TopologicalSorter prepare method. #115238

kyurais opened this issue Feb 10, 2024 · 0 comments
Labels
stdlib Python modules in the Lib dir

Comments

@kyurais
Copy link
Contributor

kyurais commented Feb 10, 2024

The prepare() method of graphlib.TopologicalSorter class raises a CycleError if any cycles are detected in the graph.

cpython/Lib/graphlib.py

Lines 104 to 106 in e2c4038

cycle = self._find_cycle()
if cycle:
raise CycleError(f"nodes are in a cycle", cycle)

The docstring for CycleError promises the cycle (list of nodes) to be accessible in the Exception's args attribute.

The detected cycle can be accessed via the second
element in the args attribute of the exception instance

The f-string for the first argument to the CycleError is therefore redundant and may cause confusion.

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

3 participants