1
0
forked from VimPlug/jedi

Remove some unnecessary utf-8 references

This commit is contained in:
Dave Halter
2020-07-02 03:30:41 +02:00
parent 8ee0c8593e
commit 332631434c
9 changed files with 6 additions and 22 deletions

View File

@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
#
# Jedi documentation build configuration file, created by
# sphinx-quickstart on Wed Dec 26 00:11:34 2012.
#

View File

@@ -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

View File

@@ -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,

View File

@@ -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]

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
"""
Profile a piece of Python code with ``profile``. Tries a completion on a
certain piece of code.

View File

@@ -400,7 +400,7 @@ def collect_dir_tests(base_dir, test_files, check_thirdparty=False):
path = os.path.join(base_dir, f_name)
with open(path, encoding='utf-8', newline='') as f:
with open(path, newline='') as f:
source = f.read()
for case in collect_file_tests(path, StringIO(source),

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
All character set and unicode related tests.
"""

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import warnings
import pytest

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from jedi import parser_utils
from parso import parse
from parso.python import tree