From 4783c065dafb81353b1aa667c88b6a6e8f410601 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Tue, 21 Jul 2020 21:26:46 +0100 Subject: [PATCH 1/6] Configure editors for uniform whitespace handling --- .editorconfig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..5374960a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.py] +indent_size = 4 + +[*.md] +indent_size = 2 From 9505dabfef7483306ae62232f8a1fa4a0aca687b Mon Sep 17 00:00:00 2001 From: Peter Law Date: Tue, 21 Jul 2020 21:28:56 +0100 Subject: [PATCH 2/6] Reflow for linting --- jedi/inference/gradual/annotation.py | 6 ++++-- jedi/settings.py | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/jedi/inference/gradual/annotation.py b/jedi/inference/gradual/annotation.py index fa3aa5ae..eadcfc2e 100644 --- a/jedi/inference/gradual/annotation.py +++ b/jedi/inference/gradual/annotation.py @@ -53,8 +53,10 @@ def _infer_annotation_string(context, string, index=None): value_set = context.infer_node(node) if index is not None: value_set = value_set.filter( - lambda value: value.array_type == 'tuple' # noqa - and len(list(value.py__iter__())) >= index + lambda value: ( + value.array_type == 'tuple' + and len(list(value.py__iter__())) >= index + ) ).py__simple_getitem__(index) return value_set diff --git a/jedi/settings.py b/jedi/settings.py index 6764a3e5..ced021e1 100644 --- a/jedi/settings.py +++ b/jedi/settings.py @@ -69,8 +69,11 @@ Adds an opening bracket after a function for completions. # ---------------- if platform.system().lower() == 'windows': - _cache_directory = os.path.join(os.getenv('LOCALAPPDATA') or - os.path.expanduser('~'), 'Jedi', 'Jedi') + _cache_directory = os.path.join( + os.getenv('LOCALAPPDATA') or os.path.expanduser('~'), + 'Jedi', + 'Jedi', + ) elif platform.system().lower() == 'darwin': _cache_directory = os.path.join('~', 'Library', 'Caches', 'Jedi') else: From 6ef18bea502eba818301f528cfb5a178b74b6c09 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Tue, 21 Jul 2020 21:34:37 +0100 Subject: [PATCH 3/6] Make this noqa more specific --- jedi/inference/base_value.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jedi/inference/base_value.py b/jedi/inference/base_value.py index c0f960d4..c5b2cec0 100644 --- a/jedi/inference/base_value.py +++ b/jedi/inference/base_value.py @@ -111,7 +111,7 @@ class HelperValueMixin(object): .py__getattribute__('__anext__').execute_with_values() .py__getattribute__('__await__').execute_with_values() .py__stop_iteration_returns() - ) # noqa + ) # noqa: E124 ]) return self.py__iter__(contextualized_node) From 5e6138d16f867063c46d3e0302d953b6be1df60b Mon Sep 17 00:00:00 2001 From: Peter Law Date: Tue, 21 Jul 2020 21:34:58 +0100 Subject: [PATCH 4/6] Update to flake8 3.8.x In particular this improves support for detecting usage of various type annotation usages and adds support for correctly parsing type: ignore comments which contain a reason tag. --- setup.cfg | 2 ++ setup.py | 2 +- test/test_api/test_call_signatures.py | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 39633dc1..6929ce30 100644 --- a/setup.cfg +++ b/setup.cfg @@ -13,6 +13,8 @@ ignore = E721, # Line break before binary operator W503, + # Single letter loop variables are often fine + E741, exclude = jedi/third_party/* .tox/* [pycodestyle] diff --git a/setup.py b/setup.py index 044d7d5a..bf9be8c2 100755 --- a/setup.py +++ b/setup.py @@ -45,7 +45,7 @@ setup(name='jedi', 'Django<3.1', # For now pin this. ], 'qa': [ - 'flake8==3.7.9', + 'flake8==3.8.3', ], }, package_data={'jedi': ['*.pyi', 'third_party/typeshed/LICENSE', diff --git a/test/test_api/test_call_signatures.py b/test/test_api/test_call_signatures.py index 59e3a640..2f0cf90c 100644 --- a/test/test_api/test_call_signatures.py +++ b/test/test_api/test_call_signatures.py @@ -122,10 +122,10 @@ def test_multiple_signatures(Script): def test_get_signatures_whitespace(Script): s = dedent("""\ - abs( + abs( def x(): pass - """) # noqa + """) assert_signature(Script, s, 'abs', 0, line=1, column=5) From 403564315c3111ae26b0240836eb84a42e94d4e6 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Tue, 21 Jul 2020 22:44:42 +0100 Subject: [PATCH 5/6] Reflow test to ensure trailing space is preserved Many editors strip trailing space, so avoid using a multiline string where the space is actually needed. --- test/test_api/test_call_signatures.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/test_api/test_call_signatures.py b/test/test_api/test_call_signatures.py index 2f0cf90c..664eec86 100644 --- a/test/test_api/test_call_signatures.py +++ b/test/test_api/test_call_signatures.py @@ -121,11 +121,8 @@ def test_multiple_signatures(Script): def test_get_signatures_whitespace(Script): - s = dedent("""\ - abs( - def x(): - pass - """) + # note: trailing space after 'abs' + s = 'abs( \ndef x():\n pass\n' assert_signature(Script, s, 'abs', 0, line=1, column=5) From b651c6541a6bf881ef09ac761b2cfbc85d3a1eea Mon Sep 17 00:00:00 2001 From: Peter Law Date: Tue, 21 Jul 2020 23:15:20 +0100 Subject: [PATCH 6/6] Configure travis' flake8 call more explicitly I'm basing this on '{posargs:jedi}' looking like it was a tox thing, which we're no longer using. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d7c418a4..89102f4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ env: matrix: include: - python: 3.8 - script: + script: - 'pip install coverage' - 'coverage run --source jedi -m pytest' - 'coverage report' @@ -31,7 +31,7 @@ matrix: - 'pip install .[qa]' script: # Ignore F401, which are unused imports. flake8 is a primitive tool and is sometimes wrong. - - 'flake8 --extend-ignore F401 {posargs:jedi}' + - 'flake8 --extend-ignore F401 jedi setup.py' install: - sudo apt-get -y install python3-venv - pip install .[testing]