mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-09 07:11:25 +08:00
Remove most version_info.major usages
This commit is contained in:
@@ -58,15 +58,14 @@ def _create_stub_map(directory_path_info):
|
||||
|
||||
|
||||
def _get_typeshed_directories(version_info):
|
||||
check_version_list = ['2and3', str(version_info.major)]
|
||||
check_version_list = ['2and3', '3']
|
||||
for base in ['stdlib', 'third_party']:
|
||||
base_path = os.path.join(TYPESHED_PATH, base)
|
||||
base_list = os.listdir(base_path)
|
||||
for base_list_entry in base_list:
|
||||
match = re.match(r'(\d+)\.(\d+)$', base_list_entry)
|
||||
if match is not None:
|
||||
if int(match.group(1)) == version_info.major \
|
||||
and int(match.group(2)) <= version_info.minor:
|
||||
if int(match.group(1)) == '3' and int(match.group(2)) <= version_info.minor:
|
||||
check_version_list.append(base_list_entry)
|
||||
|
||||
for check_version in check_version_list:
|
||||
|
||||
@@ -122,11 +122,7 @@ def get_names_of_node(node):
|
||||
|
||||
|
||||
def is_string(value):
|
||||
if value.inference_state.environment.version_info.major == 2:
|
||||
str_classes = (unicode, bytes)
|
||||
else:
|
||||
str_classes = (unicode,)
|
||||
return value.is_compiled() and isinstance(value.get_safe_value(default=None), str_classes)
|
||||
return value.is_compiled() and isinstance(value.get_safe_value(default=None), str)
|
||||
|
||||
|
||||
def is_literal(value):
|
||||
|
||||
@@ -258,10 +258,7 @@ class _BaseTreeInstance(AbstractInstanceValue):
|
||||
for generator in self.execute_function_slots(iter_slot_names):
|
||||
if generator.is_instance() and not generator.is_compiled():
|
||||
# `__next__` logic.
|
||||
if self.inference_state.environment.version_info.major == 2:
|
||||
name = u'next'
|
||||
else:
|
||||
name = u'__next__'
|
||||
name = u'__next__'
|
||||
next_slot_names = generator.get_function_slot_names(name)
|
||||
if next_slot_names:
|
||||
yield LazyKnownValues(
|
||||
|
||||
@@ -26,9 +26,6 @@ class _ModuleAttributeName(AbstractNameDefinition):
|
||||
def infer(self):
|
||||
if self._string_value is not None:
|
||||
s = self._string_value
|
||||
if self.parent_context.inference_state.environment.version_info.major == 2 \
|
||||
and not isinstance(s, bytes):
|
||||
s = s.encode('utf-8')
|
||||
return ValueSet([
|
||||
create_simple_object(self.parent_context.inference_state, s)
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user