File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99# the file COPYING, distributed as part of this software.
1010#-----------------------------------------------------------------------------
1111
12+ import warnings
13+ from collections .abc import Iterable , Sequence
14+ from typing import TypeVar
1215
13- def uniq_stable (elems ):
16+
17+ T = TypeVar ("T" )
18+
19+
20+ def uniq_stable (elems : Iterable [T ]) -> list [T ]:
1421 """uniq_stable(elems) -> list
1522
23+ .. deprecated:: 9.8
24+ This function is deprecated and will be removed in a future version.
25+ It is not used within IPython and was never part of the public API.
26+
1627 Return from an iterable, a list of all the unique elements in the input,
1728 but maintaining the order in which they first appear.
1829
1930 Note: All elements in the input must be hashable for this routine
2031 to work, as it internally uses a set for efficiency reasons.
2132 """
22- seen = set ()
23- return [x for x in elems if x not in seen and not seen .add (x )]
24-
25-
26- def chop (seq , size ):
33+ warnings .warn (
34+ "uniq_stable is deprecated since IPython 9.8 and will be removed in a future version. "
35+ "It was never part of the public API." ,
36+ DeprecationWarning ,
37+ stacklevel = 2 ,
38+ )
39+ seen : set [T ] = set ()
40+ result : list [T ] = []
41+ for x in elems :
42+ if x not in seen :
43+ seen .add (x )
44+ result .append (x )
45+ return result
46+
47+
48+ def chop (seq : Sequence [T ], size : int ) -> list [Sequence [T ]]:
2749 """Chop a sequence into chunks of the given size."""
28- return [seq [i :i + size ] for i in range (0 ,len (seq ),size )]
50+ return [seq [i :i + size ] for i in range (0 , len (seq ), size )]
2951
3052
You can’t perform that action at this time.
0 commit comments