diff --git a/docs/conf.py b/docs/conf.py index 57015f3f..ef0525e1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# # Jedi documentation build configuration file, created by # sphinx-quickstart on Wed Dec 26 00:11:34 2012. # diff --git a/jedi/_compatibility.py b/jedi/_compatibility.py index 3b3e24fb..e9b27350 100644 --- a/jedi/_compatibility.py +++ b/jedi/_compatibility.py @@ -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 diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index 2c9b3ef6..8dd8dbea 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -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, diff --git a/jedi/inference/__init__.py b/jedi/inference/__init__.py index c1c0047c..1a616d25 100644 --- a/jedi/inference/__init__.py +++ b/jedi/inference/__init__.py @@ -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] diff --git a/scripts/profile_output.py b/scripts/profile_output.py index 3497ce6b..36b230ba 100755 --- a/scripts/profile_output.py +++ b/scripts/profile_output.py @@ -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. diff --git a/test/run.py b/test/run.py index eca96229..70b2b399 100755 --- a/test/run.py +++ b/test/run.py @@ -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), diff --git a/test/test_api/test_unicode.py b/test/test_api/test_unicode.py index c1066acd..f488e508 100644 --- a/test/test_api/test_unicode.py +++ b/test/test_api/test_unicode.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ All character set and unicode related tests. """ diff --git a/test/test_deprecation.py b/test/test_deprecation.py index ad698250..39e2baa9 100644 --- a/test/test_deprecation.py +++ b/test/test_deprecation.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import warnings import pytest diff --git a/test/test_parso_integration/test_parser_utils.py b/test/test_parso_integration/test_parser_utils.py index dd128b78..0a744639 100644 --- a/test/test_parso_integration/test_parser_utils.py +++ b/test/test_parso_integration/test_parser_utils.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from jedi import parser_utils from parso import parse from parso.python import tree