forked from VimPlug/jedi
Remove some unnecessary utf-8 references
This commit is contained in:
@@ -134,14 +134,6 @@ class ImplicitNSInfo(object):
|
||||
self.paths = paths
|
||||
|
||||
|
||||
try:
|
||||
encoding = sys.stdout.encoding
|
||||
if encoding is None:
|
||||
encoding = 'utf-8'
|
||||
except AttributeError:
|
||||
encoding = 'ascii'
|
||||
|
||||
|
||||
def u(string, errors='strict'):
|
||||
"""Cast to unicode DAMMIT!
|
||||
Written because Python2 repr always implicitly casts to a string, so we
|
||||
|
||||
@@ -106,8 +106,7 @@ class Script(object):
|
||||
also ways to modify the sys path and other things.
|
||||
"""
|
||||
def __init__(self, code=None, line=None, column=None, path=None,
|
||||
encoding=None, sys_path=None, environment=None,
|
||||
project=None, source=None):
|
||||
sys_path=None, environment=None, project=None, source=None):
|
||||
self._orig_path = path
|
||||
# An empty path (also empty string) should always result in no path.
|
||||
self.path = os.path.abspath(path) if path else None
|
||||
@@ -160,7 +159,6 @@ class Script(object):
|
||||
self._module_node, code = self._inference_state.parse_and_get_code(
|
||||
code=code,
|
||||
path=self.path,
|
||||
encoding=encoding,
|
||||
use_latest_grammar=path and path.endswith('.pyi'),
|
||||
cache=False, # No disk cache, because the current script often changes.
|
||||
diff_cache=settings.fast_parser,
|
||||
@@ -841,7 +839,7 @@ class Interpreter(Script):
|
||||
)
|
||||
|
||||
|
||||
def names(source=None, path=None, encoding='utf-8', all_scopes=False,
|
||||
def names(source=None, path=None, all_scopes=False,
|
||||
definitions=True, references=False, environment=None):
|
||||
warnings.warn(
|
||||
"Deprecated since version 0.16.0. Use Script(...).get_names instead.",
|
||||
@@ -849,7 +847,7 @@ def names(source=None, path=None, encoding='utf-8', all_scopes=False,
|
||||
stacklevel=2
|
||||
)
|
||||
|
||||
return Script(source, path=path, encoding=encoding).get_names(
|
||||
return Script(source, path=path).get_names(
|
||||
all_scopes=all_scopes,
|
||||
definitions=definitions,
|
||||
references=references,
|
||||
|
||||
@@ -176,14 +176,14 @@ class InferenceState(object):
|
||||
|
||||
return helpers.infer_call_of_leaf(context, name)
|
||||
|
||||
def parse_and_get_code(self, code=None, path=None, encoding='utf-8',
|
||||
def parse_and_get_code(self, code=None, path=None,
|
||||
use_latest_grammar=False, file_io=None, **kwargs):
|
||||
if code is None:
|
||||
if file_io is None:
|
||||
file_io = FileIO(path)
|
||||
code = file_io.read()
|
||||
# We cannot just use parso, because it doesn't use errors='replace'.
|
||||
code = parso.python_bytes_to_unicode(code, encoding=encoding, errors='replace')
|
||||
code = parso.python_bytes_to_unicode(code, encoding='utf-8', errors='replace')
|
||||
|
||||
if len(code) > settings._cropped_file_size:
|
||||
code = code[:settings._cropped_file_size]
|
||||
|
||||
Reference in New Issue
Block a user