mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Rewrite py__package__ to return a list
This commit is contained in:
@@ -28,7 +28,7 @@ py__simple_getitem__(index: int/str) Returns a a set of types of the index.
|
||||
py__getitem__(indexes: ContextSet) Returns a a set of types of the index.
|
||||
py__file__() Only on modules. Returns None if does
|
||||
not exist.
|
||||
py__package__() Only on modules. For the import system.
|
||||
py__package__() -> List[str] Only on modules. For the import system.
|
||||
py__path__() Only on modules. For the import system.
|
||||
py__get__(call_object) Only on instances. Simulates
|
||||
descriptors.
|
||||
|
||||
@@ -181,9 +181,9 @@ class ModuleContext(ModuleMixin, TreeContext):
|
||||
|
||||
def py__package__(self):
|
||||
if self._get_init_directory() is None:
|
||||
return re.sub(r'\.?[^.]+$', '', self.py__name__())
|
||||
return re.sub(r'\.?[^.]+$', '', self.py__name__()).split('.')
|
||||
else:
|
||||
return self.py__name__()
|
||||
return self.string_names
|
||||
|
||||
def _py__path__(self):
|
||||
search_path = self.evaluator.get_sys_path()
|
||||
|
||||
@@ -39,7 +39,7 @@ class ImplicitNamespaceContext(Context):
|
||||
@property
|
||||
@evaluator_method_cache()
|
||||
def name(self):
|
||||
string_name = self.py__package__().rpartition('.')[-1]
|
||||
string_name = self.py__package__()[-1]
|
||||
return ImplicitNSName(self, string_name)
|
||||
|
||||
def py__file__(self):
|
||||
@@ -48,7 +48,7 @@ class ImplicitNamespaceContext(Context):
|
||||
def py__package__(self):
|
||||
"""Return the fullname
|
||||
"""
|
||||
return self._fullname
|
||||
return self._fullname.split('.')
|
||||
|
||||
def py__path__(self):
|
||||
return self._paths
|
||||
|
||||
@@ -247,7 +247,7 @@ class Importer(object):
|
||||
self._fixed_sys_path = None
|
||||
self._inference_possible = True
|
||||
if level:
|
||||
base = module_context.py__package__().split('.')
|
||||
base = module_context.py__package__()
|
||||
if base == [''] or base == ['__main__']:
|
||||
base = []
|
||||
# We need to care for two cases, the first one is if it's a valid
|
||||
|
||||
Reference in New Issue
Block a user