forked from VimPlug/jedi
Implement random.choice
This commit is contained in:
@@ -31,7 +31,6 @@ class BaseContextSet(object):
|
|||||||
Used to work with an iterable of set.
|
Used to work with an iterable of set.
|
||||||
"""
|
"""
|
||||||
aggregated = set()
|
aggregated = set()
|
||||||
sets = list(sets)
|
|
||||||
for set_ in sets:
|
for set_ in sets:
|
||||||
if isinstance(set_, BaseContextSet):
|
if isinstance(set_, BaseContextSet):
|
||||||
aggregated |= set_._set
|
aggregated |= set_._set
|
||||||
|
|||||||
@@ -344,6 +344,15 @@ def _return_first_param(evaluator, firsts):
|
|||||||
return firsts
|
return firsts
|
||||||
|
|
||||||
|
|
||||||
|
@argument_clinic('seq')
|
||||||
|
def _random_choice(evaluator, sequences):
|
||||||
|
return ContextSet.from_sets(
|
||||||
|
lazy_context.infer()
|
||||||
|
for sequence in sequences
|
||||||
|
for lazy_context in sequence.py__iter__()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
_implemented = {
|
_implemented = {
|
||||||
'builtins': {
|
'builtins': {
|
||||||
'getattr': builtins_getattr,
|
'getattr': builtins_getattr,
|
||||||
@@ -365,6 +374,13 @@ _implemented = {
|
|||||||
},
|
},
|
||||||
'functools': {
|
'functools': {
|
||||||
'partial': functools_partial,
|
'partial': functools_partial,
|
||||||
|
'wraps': _return_first_param,
|
||||||
|
},
|
||||||
|
'_weakref': {
|
||||||
|
'proxy': _return_first_param,
|
||||||
|
},
|
||||||
|
'random': {
|
||||||
|
'choice': _random_choice,
|
||||||
},
|
},
|
||||||
'abc': {
|
'abc': {
|
||||||
# Not sure if this is necessary, but it's used a lot in typeshed and
|
# Not sure if this is necessary, but it's used a lot in typeshed and
|
||||||
|
|||||||
Reference in New Issue
Block a user