mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Make sure that sequence literals have the right generic classes, fixes #1416
This commit is contained in:
@@ -206,9 +206,6 @@ class Sequence(LazyAttributeOverwrite, IterableMixin):
|
|||||||
def py__bool__(self):
|
def py__bool__(self):
|
||||||
return None # We don't know the length, because of appends.
|
return None # We don't know the length, because of appends.
|
||||||
|
|
||||||
def py__class__(self):
|
|
||||||
return compiled.builtin_from_name(self.inference_state, self.array_type)
|
|
||||||
|
|
||||||
@safe_property
|
@safe_property
|
||||||
def parent(self):
|
def parent(self):
|
||||||
return self.inference_state.builtins_module
|
return self.inference_state.builtins_module
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from typing import List, Dict, overload
|
|||||||
lst: list
|
lst: list
|
||||||
list_alias: List
|
list_alias: List
|
||||||
list_str: List[str]
|
list_str: List[str]
|
||||||
|
list_str: List[int]
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# With base classes
|
# With base classes
|
||||||
@@ -41,3 +42,33 @@ overload_f3(lst)
|
|||||||
overload_f3(list_alias)
|
overload_f3(list_alias)
|
||||||
#? str()
|
#? str()
|
||||||
overload_f3(list_str)
|
overload_f3(list_str)
|
||||||
|
|
||||||
|
# -------------------------
|
||||||
|
# Generics Matching
|
||||||
|
# -------------------------
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def overload_f1(value: List[str]) -> str: ...
|
||||||
|
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def overload_f1(value: Dict[str, str]) -> Dict[str, str]: ...
|
||||||
|
|
||||||
|
def overload_f1():
|
||||||
|
pass
|
||||||
|
|
||||||
|
#? str()
|
||||||
|
overload_f1([''])
|
||||||
|
#? str() dict()
|
||||||
|
overload_f1(1)
|
||||||
|
#? dict()
|
||||||
|
overload_f1({'': ''})
|
||||||
|
|
||||||
|
#? str() dict()
|
||||||
|
overload_f1(lst)
|
||||||
|
#? str() dict()
|
||||||
|
overload_f1(list_alias)
|
||||||
|
#? str()
|
||||||
|
overload_f1(list_str)
|
||||||
|
#? str() dict()
|
||||||
|
overload_f1(list_int)
|
||||||
|
|||||||
Reference in New Issue
Block a user