mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-32411: IDLE: Remove line number sort in browser.py (#5011)
Insertion in line order makes sorting keys by line order unneeded.
This commit is contained in:
parent
e5f6207ba6
commit
1a4d9ffa1a
4 changed files with 22 additions and 17 deletions
|
@ -3,6 +3,8 @@ Released on 2019-10-20?
|
||||||
======================================
|
======================================
|
||||||
|
|
||||||
|
|
||||||
|
bpo-32411: Stop sorting dict created with desired line order.
|
||||||
|
|
||||||
bpo-37038: Make idlelib.run runnable; add test clause.
|
bpo-37038: Make idlelib.run runnable; add test clause.
|
||||||
|
|
||||||
bpo-36958: Print any argument other than None or int passed to
|
bpo-36958: Print any argument other than None or int passed to
|
||||||
|
|
|
@ -29,9 +29,10 @@ def transform_children(child_dict, modname=None):
|
||||||
The dictionary maps names to pyclbr information objects.
|
The dictionary maps names to pyclbr information objects.
|
||||||
Filter out imported objects.
|
Filter out imported objects.
|
||||||
Augment class names with bases.
|
Augment class names with bases.
|
||||||
Sort objects by line number.
|
The insertion order of the dictonary is assumed to have been in line
|
||||||
|
number order, so sorting is not necessary.
|
||||||
|
|
||||||
The current tree only calls this once per child_dic as it saves
|
The current tree only calls this once per child_dict as it saves
|
||||||
TreeItems once created. A future tree and tests might violate this,
|
TreeItems once created. A future tree and tests might violate this,
|
||||||
so a check prevents multiple in-place augmentations.
|
so a check prevents multiple in-place augmentations.
|
||||||
"""
|
"""
|
||||||
|
@ -51,7 +52,7 @@ def transform_children(child_dict, modname=None):
|
||||||
supers.append(sname)
|
supers.append(sname)
|
||||||
obj.name += '({})'.format(', '.join(supers))
|
obj.name += '({})'.format(', '.join(supers))
|
||||||
obs.append(obj)
|
obs.append(obj)
|
||||||
return sorted(obs, key=lambda o: o.lineno)
|
return obs
|
||||||
|
|
||||||
|
|
||||||
class ModuleBrowser:
|
class ModuleBrowser:
|
||||||
|
|
|
@ -61,16 +61,16 @@ class ModuleBrowserTest(unittest.TestCase):
|
||||||
# Nested tree same as in test_pyclbr.py except for supers on C0. C1.
|
# Nested tree same as in test_pyclbr.py except for supers on C0. C1.
|
||||||
mb = pyclbr
|
mb = pyclbr
|
||||||
module, fname = 'test', 'test.py'
|
module, fname = 'test', 'test.py'
|
||||||
f0 = mb.Function(module, 'f0', fname, 1)
|
C0 = mb.Class(module, 'C0', ['base'], fname, 1)
|
||||||
f1 = mb._nest_function(f0, 'f1', 2)
|
F1 = mb._nest_function(C0, 'F1', 3)
|
||||||
f2 = mb._nest_function(f1, 'f2', 3)
|
C1 = mb._nest_class(C0, 'C1', 6, [''])
|
||||||
c1 = mb._nest_class(f0, 'c1', 5)
|
C2 = mb._nest_class(C1, 'C2', 7)
|
||||||
C0 = mb.Class(module, 'C0', ['base'], fname, 6)
|
F3 = mb._nest_function(C2, 'F3', 9)
|
||||||
F1 = mb._nest_function(C0, 'F1', 8)
|
f0 = mb.Function(module, 'f0', fname, 11)
|
||||||
C1 = mb._nest_class(C0, 'C1', 11, [''])
|
f1 = mb._nest_function(f0, 'f1', 12)
|
||||||
C2 = mb._nest_class(C1, 'C2', 12)
|
f2 = mb._nest_function(f1, 'f2', 13)
|
||||||
F3 = mb._nest_function(C2, 'F3', 14)
|
c1 = mb._nest_class(f0, 'c1', 15)
|
||||||
mock_pyclbr_tree = {'f0': f0, 'C0': C0}
|
mock_pyclbr_tree = {'C0': C0, 'f0': f0}
|
||||||
|
|
||||||
# Adjust C0.name, C1.name so tests do not depend on order.
|
# Adjust C0.name, C1.name so tests do not depend on order.
|
||||||
browser.transform_children(mock_pyclbr_tree, 'test') # C0(base)
|
browser.transform_children(mock_pyclbr_tree, 'test') # C0(base)
|
||||||
|
@ -87,12 +87,12 @@ class TransformChildrenTest(unittest.TestCase):
|
||||||
transform = browser.transform_children
|
transform = browser.transform_children
|
||||||
# Parameter matches tree module.
|
# Parameter matches tree module.
|
||||||
tcl = list(transform(mock_pyclbr_tree, 'test'))
|
tcl = list(transform(mock_pyclbr_tree, 'test'))
|
||||||
eq(tcl, [f0, C0])
|
eq(tcl, [C0, f0])
|
||||||
eq(tcl[0].name, 'f0')
|
eq(tcl[0].name, 'C0(base)')
|
||||||
eq(tcl[1].name, 'C0(base)')
|
eq(tcl[1].name, 'f0')
|
||||||
# Check that second call does not change suffix.
|
# Check that second call does not change suffix.
|
||||||
tcl = list(transform(mock_pyclbr_tree, 'test'))
|
tcl = list(transform(mock_pyclbr_tree, 'test'))
|
||||||
eq(tcl[1].name, 'C0(base)')
|
eq(tcl[0].name, 'C0(base)')
|
||||||
# Nothing to traverse if parameter name isn't same as tree module.
|
# Nothing to traverse if parameter name isn't same as tree module.
|
||||||
tcl = list(transform(mock_pyclbr_tree, 'different name'))
|
tcl = list(transform(mock_pyclbr_tree, 'different name'))
|
||||||
eq(tcl, [])
|
eq(tcl, [])
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
In browser.py, remove extraneous sorting by line number since dictionary was
|
||||||
|
created in line number order.
|
Loading…
Add table
Add a link
Reference in a new issue