Skip to content

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

Closed
@lukavada

Description

@lukavada

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions