GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — graphlib.TopologicalSorter.prepare() should be idempotent · Issue #130914 · python/cpython Closed Labels stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement DescriptionFeature or enhancementProposal:Proposed Behaviour
>>> import graphlib >>> ts = graphlib.TopologicalSorter() >>> ts.prepare() >>> ts.prepare() If you have called >>> import graphlib >>> ts = graphlib.TopologicalSorter() >>> ts.prepare() >>> ts.get_ready() () >>> ts.prepare() Traceback (most recent call last): ... ValueError: cannot prepare() after mutating prepared sorter Rationale
>>> import graphlib >>> ts = graphlib.TopologicalSorter() >>> ts.prepare() >>> ts.prepare() Traceback (most recent call last): File "<python-input-3>", line 1, in <module> ts.prepare() ~~~~~~~~~~^^ File "/home/mauve/.local/share/ext-python/python-3.13.0.82/lib/python3.13/graphlib.py", line 95, in prepare raise ValueError("cannot prepare() more than once") ValueError: cannot prepare() more than once This is rather unfortunate because if you return a def get_sorter(targets) -> TopologicalSorter[str]: """Get a TopologicalSorter that pursues the given targets.""" deps = filter_deps(load_deps(), targets) ts = TopologicalSorter(deps) ts.prepare() return ts because then you cannot run >>> get_sorter().static_order() Traceback (most recent call last): ... ValueError: cannot prepare() more than once while if you don't Therefore I think Has this already been discussed elsewhere?This is a minor feature, which does not need previous discussion elsewhere Links to previous discussion of this feature:This is related to #91301 which discusses removing Linked PRsActivity
MetadataMetadataAssigneesLabelsstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |