From 2ebe37e71b2747c062d80c42ec02d1044ad668fa Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sat, 8 May 2021 14:52:12 -0300 Subject: [PATCH 01/37] Updating submodules --- submodules/astroid | 2 +- submodules/autopep8 | 2 +- submodules/mccabe | 2 +- submodules/pycodestyle | 2 +- submodules/pydocstyle | 2 +- submodules/pyflakes | 2 +- submodules/pylint | 2 +- submodules/rope | 2 +- submodules/toml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/submodules/astroid b/submodules/astroid index 2d25e845..36dda3fc 160000 --- a/submodules/astroid +++ b/submodules/astroid @@ -1 +1 @@ -Subproject commit 2d25e84587c3e392751280490355aaeda7afd116 +Subproject commit 36dda3fc8a5826b19a33a0ff29402b61d6a64fc2 diff --git a/submodules/autopep8 b/submodules/autopep8 index 972093da..32c78a3a 160000 --- a/submodules/autopep8 +++ b/submodules/autopep8 @@ -1 +1 @@ -Subproject commit 972093dad2021ca5214133864af3cd0595830a94 +Subproject commit 32c78a3a07d7ee35500e6f20bfcd621f3132c42e diff --git a/submodules/mccabe b/submodules/mccabe index 535e2c5d..2d4dd943 160000 --- a/submodules/mccabe +++ b/submodules/mccabe @@ -1 +1 @@ -Subproject commit 535e2c5dc8cb9ea8afe79fc4cae5386c20d57394 +Subproject commit 2d4dd9435fcb05aaa89ba0392a84cb1d30a87dc9 diff --git a/submodules/pycodestyle b/submodules/pycodestyle index d4143838..930e2cad 160000 --- a/submodules/pycodestyle +++ b/submodules/pycodestyle @@ -1 +1 @@ -Subproject commit d414383860c483c57d1fafc12c630b46a5616d3c +Subproject commit 930e2cad15df3661306740c30a892a6f1902ef1d diff --git a/submodules/pydocstyle b/submodules/pydocstyle index 33244595..5f59f6eb 160000 --- a/submodules/pydocstyle +++ b/submodules/pydocstyle @@ -1 +1 @@ -Subproject commit 3324459514ddb048fc919ab2ed1f52471b801ab0 +Subproject commit 5f59f6eba0d8f0168c6ab45ee97485569b861b77 diff --git a/submodules/pyflakes b/submodules/pyflakes index c72d6cf1..95fe313b 160000 --- a/submodules/pyflakes +++ b/submodules/pyflakes @@ -1 +1 @@ -Subproject commit c72d6cf1a9a119c1dd7a7674f36da21aea32d828 +Subproject commit 95fe313ba5ca384041472cd171ea60fad910c207 diff --git a/submodules/pylint b/submodules/pylint index 8197144d..3eb0362d 160000 --- a/submodules/pylint +++ b/submodules/pylint @@ -1 +1 @@ -Subproject commit 8197144d82469ed39d1f4f3c345efee198ec9212 +Subproject commit 3eb0362dc42642e3e2774d7523a1e73d71394064 diff --git a/submodules/rope b/submodules/rope index 939dd974..f4b19fd8 160000 --- a/submodules/rope +++ b/submodules/rope @@ -1 +1 @@ -Subproject commit 939dd974835479495cc30710208f7c4a566dd38b +Subproject commit f4b19fd8ccc5325ded9db1c11fe6d25f6082de0c diff --git a/submodules/toml b/submodules/toml index a86fc1fb..3f637dba 160000 --- a/submodules/toml +++ b/submodules/toml @@ -1 +1 @@ -Subproject commit a86fc1fbd650a19eba313c3f642c9e2c679dc8d6 +Subproject commit 3f637dba5f68db63d4b30967fedda51c82459471 From cc29770fa1a1bc9759e50f1b9909e930a5fc0eeb Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sat, 8 May 2021 15:08:41 -0300 Subject: [PATCH 02/37] Update github action/workflow --- .github/workflows/test_pymode.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_pymode.yml b/.github/workflows/test_pymode.yml index 7b6bab70..e7efc4fc 100644 --- a/.github/workflows/test_pymode.yml +++ b/.github/workflows/test_pymode.yml @@ -3,15 +3,15 @@ name: Testing python-mode on: [push] jobs: - test-python-3_6: + test-python-3: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - name: Install dependencies run: | sudo apt update - sudo apt install -yqq libncurses5-dev libatk1.0-dev python-dev python3-dev lua5.1 lua5.1-dev libperl-dev git - sudo apt remove --purge vim vim-runtime gvim + sudo apt install -yqq libncurses5-dev libgtk2.0-dev libatk1.0-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev python3-dev lua5.2 liblua5.2-dev libperl-dev git + sudo apt remove --purge -yqq vim vim-runtime gvim - name: build and install vim from source working-directory: /tmp run: | From f867d28caa6daf8e71788819e7eddcb47827d304 Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sat, 8 May 2021 15:20:20 -0300 Subject: [PATCH 03/37] Test for python 3.8 and 3.9 --- .github/workflows/test_pymode.yml | 39 +++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_pymode.yml b/.github/workflows/test_pymode.yml index e7efc4fc..332dcdad 100644 --- a/.github/workflows/test_pymode.yml +++ b/.github/workflows/test_pymode.yml @@ -3,21 +3,56 @@ name: Testing python-mode on: [push] jobs: - test-python-3: + test-python-3_8: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - name: Install dependencies run: | sudo apt update + export PYTHON_CONFIGURE_OPTS="--enable-shared" sudo apt install -yqq libncurses5-dev libgtk2.0-dev libatk1.0-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev python3-dev lua5.2 liblua5.2-dev libperl-dev git sudo apt remove --purge -yqq vim vim-runtime gvim - name: build and install vim from source working-directory: /tmp run: | + export PYTHON_CONFIGURE_OPTS="--enable-shared" git clone https://github.com/vim/vim.git cd vim - ./configure --with-features=huge --enable-multibyte --enable-python3interp=yes --with-python3-config-dir=/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu --enable-perlinterp=yes --enable-luainterp=yes --enable-cscope --prefix=/usr/local + ./configure --with-features=huge --enable-multibyte --enable-python3interp=yes --with-python3-config-dir=/usr/lib/python3.8/config-3.8m-x86_64-linux-gnu --enable-perlinterp=yes --enable-luainterp=yes --enable-cscope --prefix=/usr/local + sudo make && sudo make install + - name: Install python-mode + run: | + export PYMODE_DIR="${HOME}/work/python-mode/python-mode" + mkdir -p ${HOME}/.vim/pack/foo/start/ + ln -s ${PYMODE_DIR} ${HOME}/.vim/pack/foo/start/python-mode + cp ${PYMODE_DIR}/tests/utils/pymoderc ${HOME}/.pymoderc + cp ${PYMODE_DIR}/tests/utils/vimrc ${HOME}/.vimrc + touch ${HOME}/.vimrc.before ${HOME}/.vimrc.after + - name: Run python-mode test script + run: | + alias python=python3 + cd ${HOME}/work/python-mode/python-mode + git submodule update --init --recursive + git submodule sync + bash tests/test.sh + test-python-3_9: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Install dependencies + run: | + sudo apt update + export PYTHON_CONFIGURE_OPTS="--enable-shared" + sudo apt install -yqq libncurses5-dev libgtk2.0-dev libatk1.0-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev python3-dev lua5.2 liblua5.2-dev libperl-dev git + sudo apt remove --purge -yqq vim vim-runtime gvim + - name: build and install vim from source + working-directory: /tmp + run: | + export PYTHON_CONFIGURE_OPTS="--enable-shared" + git clone https://github.com/vim/vim.git + cd vim + ./configure --with-features=huge --enable-multibyte --enable-python3interp=yes --with-python3-config-dir=/usr/lib/python3.9/config-3.9m-x86_64-linux-gnu --enable-perlinterp=yes --enable-luainterp=yes --enable-cscope --prefix=/usr/local sudo make && sudo make install - name: Install python-mode run: | From 4a0cc9688c013e898308580ae7b4955cabf3f7e6 Mon Sep 17 00:00:00 2001 From: Nathan Pemberton Date: Fri, 9 Jul 2021 09:31:57 -0700 Subject: [PATCH 04/37] Add configurable prefix for rope commands (currently hard-coded to ) --- doc/pymode.txt | 4 ++++ plugin/pymode.vim | 37 ++++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/doc/pymode.txt b/doc/pymode.txt index 73660a61..13ed77f1 100644 --- a/doc/pymode.txt +++ b/doc/pymode.txt @@ -413,6 +413,10 @@ Turn on the rope script *'g:pymode_rope' > let g:pymode_rope = 1 +Set the prefix for rope commands *'g:pymode_rope_prefix'* +> + let g:pymode_rope_refix = '' + .ropeproject Folder ~ *.ropeproject* diff --git a/plugin/pymode.vim b/plugin/pymode.vim index e69f9746..0b509735 100644 --- a/plugin/pymode.vim +++ b/plugin/pymode.vim @@ -1,6 +1,7 @@ " vi: fdl=1 let g:pymode_version = "0.13.0" + " Enable pymode by default :) call pymode#default('g:pymode', 1) call pymode#default('g:pymode_debug', 0) @@ -182,6 +183,7 @@ call pymode#default('g:pymode_breakpoint_cmd', '') " " Rope support call pymode#default('g:pymode_rope', 0) +call pymode#default('g:pymode_rope_prefix', '') " System plugin variable if g:pymode_rope @@ -210,7 +212,7 @@ if g:pymode_rope call pymode#default('g:pymode_rope_autoimport_modules', ['os', 'shutil', 'datetime']) " Bind keys to autoimport module for object under cursor - call pymode#default('g:pymode_rope_autoimport_bind', 'ra') + call pymode#default('g:pymode_rope_autoimport_bind', g:pymode_rope_prefix . 'ra') " Automatic completion on dot call pymode#default('g:pymode_rope_complete_on_dot', 1) @@ -219,56 +221,57 @@ if g:pymode_rope call pymode#default('g:pymode_rope_completion_bind', '') " Bind keys for goto definition (leave empty for disable) - call pymode#default('g:pymode_rope_goto_definition_bind', 'g') + " call pymode#default('g:pymode_rope_goto_definition_bind', g:pymode_rope_prefix . 'g') + call pymode#default('g:pymode_rope_goto_definition_bind', g:pymode_rope_prefix . 'g') " set command for open definition (e, new, vnew) call pymode#default('g:pymode_rope_goto_definition_cmd', 'new') " Bind keys for show documentation (leave empty for disable) - call pymode#default('g:pymode_rope_show_doc_bind', 'd') + call pymode#default('g:pymode_rope_show_doc_bind', g:pymode_rope_prefix . 'd') " Bind keys for find occurencies (leave empty for disable) - call pymode#default('g:pymode_rope_find_it_bind', 'f') + call pymode#default('g:pymode_rope_find_it_bind', g:pymode_rope_prefix . 'f') " Bind keys for organize imports (leave empty for disable) - call pymode#default('g:pymode_rope_organize_imports_bind', 'ro') + call pymode#default('g:pymode_rope_organize_imports_bind', g:pymode_rope_prefix . 'ro') " Bind keys for rename variable/method/class in the project (leave empty for disable) - call pymode#default('g:pymode_rope_rename_bind', 'rr') + call pymode#default('g:pymode_rope_rename_bind', g:pymode_rope_prefix . 'rr') " Bind keys for rename module - call pymode#default('g:pymode_rope_rename_module_bind', 'r1r') + call pymode#default('g:pymode_rope_rename_module_bind', g:pymode_rope_prefix . 'r1r') " Bind keys for convert module to package - call pymode#default('g:pymode_rope_module_to_package_bind', 'r1p') + call pymode#default('g:pymode_rope_module_to_package_bind', g:pymode_rope_prefix . 'r1p') " Creates a new function or method (depending on the context) from the selected lines - call pymode#default('g:pymode_rope_extract_method_bind', 'rm') + call pymode#default('g:pymode_rope_extract_method_bind', g:pymode_rope_prefix . 'rm') " Creates a variable from the selected lines - call pymode#default('g:pymode_rope_extract_variable_bind', 'rl') + call pymode#default('g:pymode_rope_extract_variable_bind', g:pymode_rope_prefix . 'rl') " Inline refactoring - call pymode#default('g:pymode_rope_inline_bind', 'ri') + call pymode#default('g:pymode_rope_inline_bind', g:pymode_rope_prefix . 'ri') " Move refactoring - call pymode#default('g:pymode_rope_move_bind', 'rv') + call pymode#default('g:pymode_rope_move_bind', g:pymode_rope_prefix . 'rv') " Generate function - call pymode#default('g:pymode_rope_generate_function_bind', 'rnf') + call pymode#default('g:pymode_rope_generate_function_bind', g:pymode_rope_prefix . 'rnf') " Generate class - call pymode#default('g:pymode_rope_generate_class_bind', 'rnc') + call pymode#default('g:pymode_rope_generate_class_bind', g:pymode_rope_prefix . 'rnc') " Generate package - call pymode#default('g:pymode_rope_generate_package_bind', 'rnp') + call pymode#default('g:pymode_rope_generate_package_bind', g:pymode_rope_prefix . 'rnp') " Change signature - call pymode#default('g:pymode_rope_change_signature_bind', 'rs') + call pymode#default('g:pymode_rope_change_signature_bind', g:pymode_rope_prefix . 'rs') " Tries to find the places in which a function can be used and changes the " code to call it instead - call pymode#default('g:pymode_rope_use_function_bind', 'ru') + call pymode#default('g:pymode_rope_use_function_bind', g:pymode_rope_prefix . 'ru') " Regenerate project cache on every save call pymode#default('g:pymode_rope_regenerate_on_write', 1) From 04caeebcc76158ee269b222b6710555406b05284 Mon Sep 17 00:00:00 2001 From: Nathan Pemberton Date: Fri, 9 Jul 2021 09:46:30 -0700 Subject: [PATCH 05/37] Add NathanTP to authors --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 6c2c6b95..a4bcbf28 100644 --- a/AUTHORS +++ b/AUTHORS @@ -75,3 +75,4 @@ Contributors: * Yury A. Kartynnik (https://github.com/kartynnik); * Xiangyu Xu (https://github.com/bkbncn); * Zach Himsel (https://github.com/zhimsel); +* Nathan Pemberton (https://github.com/NathanTP); From 97b72094b336a9549f49203e9fd21ceee8c16468 Mon Sep 17 00:00:00 2001 From: Nathan Pemberton Date: Tue, 13 Jul 2021 09:48:12 -0700 Subject: [PATCH 06/37] Remove extraneous commented line --- plugin/pymode.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin/pymode.vim b/plugin/pymode.vim index 0b509735..5dabc6d9 100644 --- a/plugin/pymode.vim +++ b/plugin/pymode.vim @@ -221,7 +221,6 @@ if g:pymode_rope call pymode#default('g:pymode_rope_completion_bind', '') " Bind keys for goto definition (leave empty for disable) - " call pymode#default('g:pymode_rope_goto_definition_bind', g:pymode_rope_prefix . 'g') call pymode#default('g:pymode_rope_goto_definition_bind', g:pymode_rope_prefix . 'g') " set command for open definition (e, new, vnew) From 7487b7965b3174c5c7f52e0f0022492089c65e07 Mon Sep 17 00:00:00 2001 From: Jongwook Choi Date: Thu, 12 Aug 2021 04:32:31 -0400 Subject: [PATCH 07/37] Add option g:pymode_indent_hanging_width This is an option for hanging indent size after an open parenthesis in line continuations. It defaults to `&shiftwidth` but can be assigned a different value. For example, hanging indent size can be set to 4 (even if the tabsize or shiftwidth is not 4) as per Google Python Style Guide. --- autoload/pymode/indent.vim | 4 +++- doc/pymode.txt | 10 ++++++++++ plugin/pymode.vim | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/autoload/pymode/indent.vim b/autoload/pymode/indent.vim index efd41f29..e964f378 100644 --- a/autoload/pymode/indent.vim +++ b/autoload/pymode/indent.vim @@ -24,7 +24,9 @@ function! pymode#indent#get_indent(lnum) if closing_paren return indent(parlnum) else - return indent(parlnum) + &shiftwidth + let l:indent_width = (g:pymode_indent_hanging_width > 0 ? + \ g:pymode_indent_hanging_width : &shiftwidth) + return indent(parlnum) + l:indent_width endif else return parcol diff --git a/doc/pymode.txt b/doc/pymode.txt index 73660a61..6d047698 100644 --- a/doc/pymode.txt +++ b/doc/pymode.txt @@ -170,6 +170,16 @@ Enable pymode indentation *'g:pymode_indent' > let g:pymode_indent = 1 + +Customization: + +Hanging indent size after an open parenthesis or bracket (but nothing after the +parenthesis), when vertical alignment is not used. Defaults to `&shiftwidth`. + *'g:pymode_indent_hanging_width'* +> + let g:pymode_indent_hanging_width = &shiftwidth + let g:pymode_indent_hanging_width = 4 + ------------------------------------------------------------------------------- 2.3 Python folding ~ *pymode-folding* diff --git a/plugin/pymode.vim b/plugin/pymode.vim index e69f9746..9c01a9d5 100644 --- a/plugin/pymode.vim +++ b/plugin/pymode.vim @@ -38,6 +38,9 @@ call pymode#default('g:pymode_doc_bind', 'K') " Enable/Disable pymode PEP8 indentation call pymode#default("g:pymode_indent", 1) +" Customize hanging indent size different than &shiftwidth +call pymode#default("g:pymode_indent_hanging_width", -1) + " TODO: currently folding suffers from a bad performance and incorrect " implementation. This feature should be considered experimental. " Enable/disable pymode folding for pyfiles. From 0c47c692fa3f8ae2c360c63d59b91d1beeca4087 Mon Sep 17 00:00:00 2001 From: Lie Ryan Date: Thu, 2 Sep 2021 22:22:28 +1000 Subject: [PATCH 08/37] Fix MoveRefactoring Global and Module Move refactoring requires that `dest` be a rope module, while Method Move refactoring requires that `dest` be an attribute name. --- pymode/rope.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pymode/rope.py b/pymode/rope.py index ba5f55b2..fc567a12 100644 --- a/pymode/rope.py +++ b/pymode/rope.py @@ -701,6 +701,15 @@ def get_refactor(ctx): offset = None return move.create_move(ctx.project, ctx.resource, offset) + @staticmethod + def get_changes(refactor, input_str, in_hierarchy=False): + with RopeContext() as ctx: + if isinstance(refactor, (move.MoveGlobal, move.MoveModule)): + dest = ctx.project.pycore.find_module(input_str) + else: + dest = input_str + return super(MoveRefactoring, MoveRefactoring).get_changes(refactor, dest, in_hierarchy=in_hierarchy) + class ChangeSignatureRefactoring(Refactoring): From 724d2c4dfeacfdf66e2bde60bac3d4f8bcce76df Mon Sep 17 00:00:00 2001 From: Lie Ryan Date: Thu, 2 Sep 2021 23:12:32 +1000 Subject: [PATCH 09/37] Document how to use Global Move refactoring --- doc/pymode.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/pymode.txt b/doc/pymode.txt index 6d047698..cf5688ab 100644 --- a/doc/pymode.txt +++ b/doc/pymode.txt @@ -613,14 +613,24 @@ code to call it instead. let g:pymode_rope_use_function_bind = 'ru' -Move method/fields ~ +Move refactoring ~ *pymode-rope-move* +Moving method/fields + It happens when you perform move refactoring on a method of a class. In this refactoring, a method of a class is moved to the class of one of its attributes. The old method will call the new method. If you want to change all of the occurrences of the old method to use the new method you can inline it afterwards. + +Moving global variable/class/function into another module + +It happens when you perform move refactoring on global variable/class/function. +In this refactoring, the object being refactored will be moved to a destination +module. All references to the object being moved will be updated to point to +the new location. + > let g:pymode_rope_move_bind = 'rv' From b70ec576e97ff509dd13981ef74383074e906de8 Mon Sep 17 00:00:00 2001 From: Lie Ryan Date: Thu, 2 Sep 2021 23:22:32 +1000 Subject: [PATCH 10/37] Document how to use Module Move refactoring --- doc/pymode.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/pymode.txt b/doc/pymode.txt index cf5688ab..33b2bfa8 100644 --- a/doc/pymode.txt +++ b/doc/pymode.txt @@ -631,6 +631,13 @@ In this refactoring, the object being refactored will be moved to a destination module. All references to the object being moved will be updated to point to the new location. +Moving module variable/class/function into a package + +It happens when you perform move refactoring on a name referencing a module. +In this refactoring, the module being refactored will be moved to a destination +package. All references to the object being moved will be updated to point to +the new location. + > let g:pymode_rope_move_bind = 'rv' From 577f3ed1a1d28679c3d7d52237a65c8b032ef032 Mon Sep 17 00:00:00 2001 From: Lie Ryan Date: Sat, 18 Sep 2021 14:41:18 +1000 Subject: [PATCH 11/37] Update rope submodule --- submodules/rope | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/rope b/submodules/rope index f4b19fd8..4912fec6 160000 --- a/submodules/rope +++ b/submodules/rope @@ -1 +1 @@ -Subproject commit f4b19fd8ccc5325ded9db1c11fe6d25f6082de0c +Subproject commit 4912fec66b3387a7a5173dca79135d9e5b182128 From 89ae9a1c73a0ec0a90af37fda479f2d68b7f3b86 Mon Sep 17 00:00:00 2001 From: Lie Ryan Date: Sun, 19 Sep 2021 23:16:09 +1000 Subject: [PATCH 12/37] Update rope submodule to 0.20.1 --- submodules/rope | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/rope b/submodules/rope index 4912fec6..62af070a 160000 --- a/submodules/rope +++ b/submodules/rope @@ -1 +1 @@ -Subproject commit 4912fec66b3387a7a5173dca79135d9e5b182128 +Subproject commit 62af070aa5ed3505a2629a76778003ce7fd383f0 From 6c51814bfe723d0bfb2994f4ebd728026f944785 Mon Sep 17 00:00:00 2001 From: Lie Ryan Date: Mon, 20 Sep 2021 03:10:54 +1000 Subject: [PATCH 13/37] Refactor extract get_code_actions() --- pymode/rope.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pymode/rope.py b/pymode/rope.py index ba5f55b2..c15a0018 100644 --- a/pymode/rope.py +++ b/pymode/rope.py @@ -463,10 +463,11 @@ def run(self): if not input_str: return False + code_actions = self.get_code_actions() action = env.user_input_choices( - 'Choose what to do:', 'perform', 'preview', - 'perform in class hierarchy', - 'preview in class hierarchy') + 'Choose what to do:', + *code_actions, + ) in_hierarchy = action.endswith("in class hierarchy") @@ -492,6 +493,14 @@ def run(self): except Exception as e: # noqa env.error('Unhandled exception in Pymode: %s' % e) + def get_code_actions(self): + return [ + 'perform', + 'preview', + 'perform in class hierarchy', + 'preview in class hierarchy', + ] + @staticmethod def get_refactor(ctx): """ Get refactor object. """ From 41ed4df22ba41ed01d15b19bfe2ade0770b95cbb Mon Sep 17 00:00:00 2001 From: Lie Ryan Date: Mon, 20 Sep 2021 03:37:31 +1000 Subject: [PATCH 14/37] Don't present irrelevant in_hierarchy options --- pymode/rope.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/pymode/rope.py b/pymode/rope.py index c15a0018..3c0d16ac 100644 --- a/pymode/rope.py +++ b/pymode/rope.py @@ -497,8 +497,6 @@ def get_code_actions(self): return [ 'perform', 'preview', - 'perform in class hierarchy', - 'preview in class hierarchy', ] @staticmethod @@ -555,6 +553,14 @@ def get_input_str(self, refactor, ctx): return newname + def get_code_actions(self): + return [ + 'perform', + 'preview', + 'perform in class hierarchy', + 'preview in class hierarchy', + ] + @staticmethod def get_changes(refactor, input_str, in_hierarchy=False): """ Get changes. @@ -710,6 +716,14 @@ def get_refactor(ctx): offset = None return move.create_move(ctx.project, ctx.resource, offset) + def get_code_actions(self): + return [ + 'perform', + 'preview', + 'perform in class hierarchy', + 'preview in class hierarchy', + ] + class ChangeSignatureRefactoring(Refactoring): @@ -737,6 +751,14 @@ def get_refactor(ctx): return change_signature.ChangeSignature( ctx.project, ctx.resource, offset) + def get_code_actions(self): + return [ + 'perform', + 'preview', + 'perform in class hierarchy', + 'preview in class hierarchy', + ] + def get_changes(self, refactor, input_string, in_hierarchy=False): """ Function description. From f78ff46ddd241a1b605144b0a1bcfa9ea49ef64b Mon Sep 17 00:00:00 2001 From: Lie Ryan Date: Fri, 1 Oct 2021 09:41:20 +1000 Subject: [PATCH 15/37] Implement select logical line --- after/ftplugin/python.vim | 2 ++ autoload/pymode/rope.vim | 4 ++++ pymode/environment.py | 3 +++ pymode/rope.py | 14 +++++++++++++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/after/ftplugin/python.vim b/after/ftplugin/python.vim index 0fdd01a3..6b5a8839 100644 --- a/after/ftplugin/python.vim +++ b/after/ftplugin/python.vim @@ -42,6 +42,8 @@ if g:pymode_motion vnoremap aM :call pymode#motion#select('^s*(asyncs+)=@', '^s*(asyncs+)=defs', 0) vnoremap iM :call pymode#motion#select('^s*(asyncs+)=@', '^s*(asyncs+)=defs', 1) + onoremap V :call pymode#rope#select_logical_line() + endif if g:pymode_rope && g:pymode_rope_completion diff --git a/autoload/pymode/rope.vim b/autoload/pymode/rope.vim index c1a2de0c..36344d0a 100644 --- a/autoload/pymode/rope.vim +++ b/autoload/pymode/rope.vim @@ -194,3 +194,7 @@ fun! pymode#rope#generate_package() "{{{ endif PymodePython rope.GenerateElementRefactoring('package').run() endfunction "}}} + +fun! pymode#rope#select_logical_line() "{{{ + PymodePython rope.select_logical_line() +endfunction "}}} diff --git a/pymode/environment.py b/pymode/environment.py index 30ae0e50..86527f56 100644 --- a/pymode/environment.py +++ b/pymode/environment.py @@ -242,5 +242,8 @@ def goto_buffer(bufnr): if str(bufnr) != '-1': vim.command('buffer %s' % bufnr) + def select_line(self, start, end): + vim.command('normal %sggV%sgg' % (start, end)) + env = VimPymodeEnviroment() diff --git a/pymode/rope.py b/pymode/rope.py index ba5f55b2..c44dcc30 100644 --- a/pymode/rope.py +++ b/pymode/rope.py @@ -5,7 +5,7 @@ import site import sys -from rope.base import project, libutils, exceptions, change, worder, pycore +from rope.base import project, libutils, exceptions, change, worder, pycore, codeanalyze from rope.base.fscommands import FileSystemCommands # noqa from rope.base.taskhandle import TaskHandle # noqa from rope.contrib import autoimport as rope_autoimport, codeassist, findit, generate # noqa @@ -921,6 +921,18 @@ def _insert_import(name, module, ctx): reload_changes(changes) +@env.catch_exceptions +def select_logical_line(): + source, offset = env.get_offset_params() + + lines = codeanalyze.SourceLinesAdapter(source) + lineno = lines.get_line_number(offset) + line_finder = codeanalyze.LogicalLineFinder(lines) + start, end = line_finder.logical_line_in(lineno) + + env.select_line(start, end) + + # Monkey patch Rope def find_source_folders(self, folder): """Look only python files an packages.""" From c47e6dbc55abf1d52cc61ac600a333ade3ba0f51 Mon Sep 17 00:00:00 2001 From: Lie Ryan Date: Fri, 1 Oct 2021 10:17:48 +1000 Subject: [PATCH 16/37] Fix documentation class and function text objects don't work in normal mode --- doc/pymode.txt | 8 ++++---- pymode/rope.py | 10 +++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/doc/pymode.txt b/doc/pymode.txt index 6d047698..8b824618 100644 --- a/doc/pymode.txt +++ b/doc/pymode.txt @@ -209,10 +209,10 @@ Key Command ]] Jump to next class or function (normal, visual, operator modes) [M Jump to previous class or method (normal, visual, operator modes) ]M Jump to next class or method (normal, visual, operator modes) -aC Select a class. Ex: vaC, daC, yaC, caC (normal, operator modes) -iC Select inner class. Ex: viC, diC, yiC, ciC (normal, operator modes) -aM Select a function or method. Ex: vaM, daM, yaM, caM (normal, operator modes) -iM Select inner function or method. Ex: viM, diM, yiM, ciM (normal, operator modes) +aC Select a class. Ex: vaC, daC, yaC, caC (operator modes) +iC Select inner class. Ex: viC, diC, yiC, ciC (operator modes) +aM Select a function or method. Ex: vaM, daM, yaM, caM (operator modes) +iM Select inner function or method. Ex: viM, diM, yiM, ciM (operator modes) ==== ============================ Enable pymode-motion *'g:pymode_motion'* diff --git a/pymode/rope.py b/pymode/rope.py index c44dcc30..3f77f839 100644 --- a/pymode/rope.py +++ b/pymode/rope.py @@ -924,13 +924,17 @@ def _insert_import(name, module, ctx): @env.catch_exceptions def select_logical_line(): source, offset = env.get_offset_params() + count = int(env.var('v:count1')) lines = codeanalyze.SourceLinesAdapter(source) - lineno = lines.get_line_number(offset) + start_line = lines.get_line_number(offset) line_finder = codeanalyze.LogicalLineFinder(lines) - start, end = line_finder.logical_line_in(lineno) - env.select_line(start, end) + start_lineno, _ = line_finder.logical_line_in(start_line) + for _, (_, end_lineno) in zip(range(count), line_finder.generate_regions(start_line)): + pass + + env.select_line(start_lineno, end_lineno) # Monkey patch Rope From a50403cb81c71493bc5c77f5270c87372de2a93b Mon Sep 17 00:00:00 2001 From: Lie Ryan Date: Fri, 1 Oct 2021 10:18:42 +1000 Subject: [PATCH 17/37] Document logical line selection --- doc/pymode.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/pymode.txt b/doc/pymode.txt index 8b824618..3a9e9035 100644 --- a/doc/pymode.txt +++ b/doc/pymode.txt @@ -213,6 +213,7 @@ aC Select a class. Ex: vaC, daC, yaC, caC (operator modes) iC Select inner class. Ex: viC, diC, yiC, ciC (operator modes) aM Select a function or method. Ex: vaM, daM, yaM, caM (operator modes) iM Select inner function or method. Ex: viM, diM, yiM, ciM (operator modes) +V Select logical line. Ex: dV, yV, cV (operator modes), also works with count ==== ============================ Enable pymode-motion *'g:pymode_motion'* From 9b4a338a8876c119f3798696f64910882757766f Mon Sep 17 00:00:00 2001 From: Lie Ryan Date: Fri, 1 Oct 2021 12:25:58 +1000 Subject: [PATCH 18/37] Fix logical line off by one --- pymode/rope.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pymode/rope.py b/pymode/rope.py index 3f77f839..4694fe1f 100644 --- a/pymode/rope.py +++ b/pymode/rope.py @@ -930,8 +930,8 @@ def select_logical_line(): start_line = lines.get_line_number(offset) line_finder = codeanalyze.LogicalLineFinder(lines) - start_lineno, _ = line_finder.logical_line_in(start_line) - for _, (_, end_lineno) in zip(range(count), line_finder.generate_regions(start_line)): + start_lineno, end_lineno = line_finder.logical_line_in(start_line) + for _, (_, end_lineno) in zip(range(count - 1), line_finder.generate_regions(start_line)): pass env.select_line(start_lineno, end_lineno) From 0beb5f8538901e4f300afccc91ec87a3a8e20f57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Pobo=C5=99il?= Date: Sun, 14 Nov 2021 15:15:52 +0100 Subject: [PATCH 19/37] Add syntax highlight for walrus operator `:=` operator (PEP 572) --- doc/pymode.txt | 4 ++++ syntax/python.vim | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/doc/pymode.txt b/doc/pymode.txt index 9991ab21..4e565879 100644 --- a/doc/pymode.txt +++ b/doc/pymode.txt @@ -674,6 +674,10 @@ Highlight '=' operator *'g:pymode_syntax_highlight_equal_operator' > let g:pymode_syntax_highlight_equal_operator = g:pymode_syntax_all +Highlight ':=' operator *'g:pymode_syntax_highlight_walrus_operator'* +> + let g:pymode_syntax_highlight_walrus_operator = g:pymode_syntax_all + Highlight '*' operator *'g:pymode_syntax_highlight_stars_operator'* > let g:pymode_syntax_highlight_stars_operator = g:pymode_syntax_all diff --git a/syntax/python.vim b/syntax/python.vim index b7666d86..70bcfa0c 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -23,6 +23,9 @@ call pymode#default("g:pymode_syntax_highlight_async_await", g:pymode_syntax_all " Highlight '=' operator call pymode#default('g:pymode_syntax_highlight_equal_operator', g:pymode_syntax_all) +" Highlight ':=' operator +call pymode#default('g:pymode_syntax_highlight_walrus_operator', g:pymode_syntax_all) + " Highlight '*' operator call pymode#default('g:pymode_syntax_highlight_stars_operator', g:pymode_syntax_all) @@ -114,6 +117,10 @@ endif syn match pythonExtraOperator "\%(=\)" endif + if g:pymode_syntax_highlight_walrus_operator + syn match pythonExtraOperator "\%(:=\)" + endif + if g:pymode_syntax_highlight_stars_operator syn match pythonExtraOperator "\%(\*\|\*\*\)" endif From 000232fc4514c68e7a4f4bb6cae0f8282a06ebc5 Mon Sep 17 00:00:00 2001 From: Lie Ryan Date: Tue, 7 Dec 2021 07:58:19 +1100 Subject: [PATCH 20/37] Add tests for logical line text object --- .../test_procedures_vimscript/textobject.vim | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tests/test_procedures_vimscript/textobject.vim b/tests/test_procedures_vimscript/textobject.vim index cee9f985..cbd4ef05 100644 --- a/tests/test_procedures_vimscript/textobject.vim +++ b/tests/test_procedures_vimscript/textobject.vim @@ -1,3 +1,6 @@ +set noautoindent +let g:pymode_rope=1 + " Load sample python file. " With 'def'. execute "normal! idef func1():\ a = 1\" @@ -22,6 +25,57 @@ let content=getline('^', '$') call assert_true(content == ['class Class2():', ' b = 2', '', 'class Class1():', ' a = 1']) +" Clean file. +%delete + +" With 'def'. +execute "normal! iprint(\ 1\)\" +execute "normal! iprint(\ 2\)\" +execute "normal! iprint(\ 3\)\" +normal 4ggdV + +let content=getline('^', '$') +call assert_true(content == [ +\ "print(", " 1", ")", +\ "print(", " 3", ")", +\ "" +\]) + + +" Clean file. +%delete + +" With 'def'. +execute "normal! iprint(\ 1\)\" +execute "normal! iprint(\ 2\)\" +execute "normal! iprint(\ 3\)\" +execute "normal! iprint(\ 4\)\" +normal 5ggd2V + +let content=getline('^', '$') +call assert_true(content == [ +\ "print(", " 1", ")", +\ "print(", " 4", ")", +\ "" +\]) + +" Clean file. +%delete + +" With 'def'. +execute "normal! iprint(\ 1\)\" +execute "normal! iprint(\ 2\)\" +execute "normal! iprint(\ 3\)\" +execute "normal! iprint(\ 4\)\" +normal 5ggd2V + +let content=getline('^', '$') +call assert_true(content == [ +\ "print(", " 1", ")", +\ "print(", " 4", ")", +\ "" +\]) + if len(v:errors) > 0 cquit! else From 7c5731dc16ab4e4369aa08560d609a9d08022988 Mon Sep 17 00:00:00 2001 From: Lie Ryan Date: Tue, 7 Dec 2021 07:58:59 +1100 Subject: [PATCH 21/37] Fix logical line text object when used with count --- pymode/rope.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymode/rope.py b/pymode/rope.py index 4694fe1f..c34817b2 100644 --- a/pymode/rope.py +++ b/pymode/rope.py @@ -931,7 +931,7 @@ def select_logical_line(): line_finder = codeanalyze.LogicalLineFinder(lines) start_lineno, end_lineno = line_finder.logical_line_in(start_line) - for _, (_, end_lineno) in zip(range(count - 1), line_finder.generate_regions(start_line)): + for _, (_, end_lineno) in zip(range(count), line_finder.generate_regions(start_lineno)): pass env.select_line(start_lineno, end_lineno) From d090c736ace5bbaaa82b4f123662b36f3e7f3cb3 Mon Sep 17 00:00:00 2001 From: Neil Girdhar Date: Sun, 5 Dec 2021 12:15:05 -0500 Subject: [PATCH 22/37] Remove dead keywords and builtins; add match, case --- syntax/python.vim | 55 +++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 70bcfa0c..5a76d2b0 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -94,7 +94,7 @@ endif syn match pythonClassParameters "[^,\*]*" contained contains=pythonBuiltin,pythonBuiltinObj,pythonBuiltinType,pythonExtraOperatorpythonStatement,pythonBrackets,pythonString,pythonComment skipwhite syn keyword pythonRepeat for while - syn keyword pythonConditional if elif else + syn keyword pythonConditional if elif else match case syn keyword pythonInclude import from syn keyword pythonException try except finally syn keyword pythonOperator and in is not or @@ -269,26 +269,29 @@ endif " Builtin objects and types if g:pymode_syntax_builtin_objs - syn keyword pythonBuiltinObj True False Ellipsis None NotImplemented - syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ + " True, False, Ellipsis, and None are in fact keywords. + syn keyword pythonBuiltinObj True False Ellipsis None + syn keyword pythonBuiltinObj NotImplemented + syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ __loader__ + syn keyword pythonBuiltinObj __spec__ __cached__ __annotations__ endif if g:pymode_syntax_builtin_types syn keyword pythonBuiltinType type object - syn keyword pythonBuiltinType str basestring unicode buffer bytearray bytes chr unichr - syn keyword pythonBuiltinType dict int long bool float complex set frozenset list tuple - syn keyword pythonBuiltinType file super + syn keyword pythonBuiltinType str bytearray bytes chr + syn keyword pythonBuiltinType dict int bool float complex set frozenset list tuple + syn keyword pythonBuiltinType super endif " Builtin functions if g:pymode_syntax_builtin_funcs - syn keyword pythonBuiltinFunc __import__ abs all any apply - syn keyword pythonBuiltinFunc bin callable classmethod cmp coerce compile + syn keyword pythonBuiltinFunc __import__ abs all any + syn keyword pythonBuiltinFunc bin callable classmethod compile syn keyword pythonBuiltinFunc delattr dir divmod enumerate eval execfile filter syn keyword pythonBuiltinFunc format getattr globals locals hasattr hash help hex id - syn keyword pythonBuiltinFunc input intern isinstance issubclass iter len map max min - syn keyword pythonBuiltinFunc next oct open ord pow property range xrange - syn keyword pythonBuiltinFunc raw_input reduce reload repr reversed round setattr + syn keyword pythonBuiltinFunc input isinstance issubclass iter len map max min + syn keyword pythonBuiltinFunc next oct open ord pow property range + syn keyword pythonBuiltinFunc repr reversed round setattr syn keyword pythonBuiltinFunc slice sorted staticmethod sum vars zip if g:pymode_syntax_print_as_function @@ -299,31 +302,31 @@ endif " Builtin exceptions and warnings if g:pymode_syntax_highlight_exceptions - syn keyword pythonExClass BaseException - syn keyword pythonExClass Exception StandardError ArithmeticError - syn keyword pythonExClass LookupError EnvironmentError - syn keyword pythonExClass AssertionError AttributeError BufferError EOFError - syn keyword pythonExClass FloatingPointError GeneratorExit IOError - syn keyword pythonExClass ImportError IndexError KeyError - syn keyword pythonExClass KeyboardInterrupt MemoryError NameError + syn keyword pythonExClass BaseException Exception ArithmeticError + syn keyword pythonExClass BufferError LookupError + syn keyword pythonExClass AssertionError AttributeError EOFError + syn keyword pythonExClass FloatingPointError GeneratorExit + syn keyword pythonExClass ImportError ModuleNotFoundError IndexError + syn keyword pythonExClass KeyError KeyboardInterrupt MemoryError NameError syn keyword pythonExClass NotImplementedError OSError OverflowError - syn keyword pythonExClass ReferenceError RuntimeError StopIteration - syn keyword pythonExClass SyntaxError IndentationError TabError + syn keyword pythonExClass RecursionError ReferenceError RuntimeError StopIteration + syn keyword pythonExClass StopAsyncIteration SyntaxError IndentationError TabError syn keyword pythonExClass SystemError SystemExit TypeError syn keyword pythonExClass UnboundLocalError UnicodeError syn keyword pythonExClass UnicodeEncodeError UnicodeDecodeError - syn keyword pythonExClass UnicodeTranslateError ValueError VMSError + syn keyword pythonExClass UnicodeTranslateError ValueError + syn keyword pythonExClass ZeroDivisionError EnvironmentError IOError + syn keyword pythonExClass WindowsError syn keyword pythonExClass BlockingIOError ChildProcessError ConnectionError syn keyword pythonExClass BrokenPipeError ConnectionAbortedError syn keyword pythonExClass ConnectionRefusedError ConnectionResetError syn keyword pythonExClass FileExistsError FileNotFoundError InterruptedError syn keyword pythonExClass IsADirectoryError NotADirectoryError PermissionError syn keyword pythonExClass ProcessLookupError TimeoutError - syn keyword pythonExClass WindowsError ZeroDivisionError - syn keyword pythonExClass Warning UserWarning BytesWarning DeprecationWarning - syn keyword pythonExClass PendingDepricationWarning SyntaxWarning - syn keyword pythonExClass RuntimeWarning FutureWarning - syn keyword pythonExClass ImportWarning UnicodeWarning + syn keyword pythonExClass Warning UserWarning DeprecationWarning PendingDeprecationWarning + syn keyword pythonExClass SyntaxWarning RuntimeWarning FutureWarning + syn keyword pythonExClass ImportWarning UnicodeWarning EncodingWarning + syn keyword pythonExClass BytesWarning ResourceWarning endif " }}} From 3dc75c2a97e729dc89a9ea3c4b61a9097d1810bf Mon Sep 17 00:00:00 2001 From: Lie Ryan Date: Fri, 25 Nov 2022 17:05:13 +1100 Subject: [PATCH 23/37] Update rope==1.5.1 --- .gitmodules | 9 +++++++++ pymode/libs/appdirs.py | 1 + pymode/libs/pytoolconfig | 1 + pymode/libs/tomli | 1 + submodules/appdirs | 1 + submodules/pytoolconfig | 1 + submodules/rope | 2 +- submodules/tomli | 1 + 8 files changed, 16 insertions(+), 1 deletion(-) create mode 120000 pymode/libs/appdirs.py create mode 120000 pymode/libs/pytoolconfig create mode 120000 pymode/libs/tomli create mode 160000 submodules/appdirs create mode 160000 submodules/pytoolconfig create mode 160000 submodules/tomli diff --git a/.gitmodules b/.gitmodules index 4874edc5..1ef5f423 100644 --- a/.gitmodules +++ b/.gitmodules @@ -48,3 +48,12 @@ [submodule "submodules/toml"] path = submodules/toml url = https://github.com/uiri/toml.git +[submodule "submodules/pytoolconfig"] + path = submodules/pytoolconfig + url = git@github.com:bagel897/pytoolconfig.git +[submodule "submodules/tomli"] + path = submodules/tomli + url = git@github.com:hukkin/tomli.git +[submodule "submodules/appdirs"] + path = submodules/appdirs + url = git@github.com:ActiveState/appdirs.git diff --git a/pymode/libs/appdirs.py b/pymode/libs/appdirs.py new file mode 120000 index 00000000..da7cbf20 --- /dev/null +++ b/pymode/libs/appdirs.py @@ -0,0 +1 @@ +../../submodules/appdirs/appdirs.py \ No newline at end of file diff --git a/pymode/libs/pytoolconfig b/pymode/libs/pytoolconfig new file mode 120000 index 00000000..0a2d520c --- /dev/null +++ b/pymode/libs/pytoolconfig @@ -0,0 +1 @@ +../../submodules/pytoolconfig/pytoolconfig/ \ No newline at end of file diff --git a/pymode/libs/tomli b/pymode/libs/tomli new file mode 120000 index 00000000..2413e2b5 --- /dev/null +++ b/pymode/libs/tomli @@ -0,0 +1 @@ +../../submodules/tomli/src/tomli \ No newline at end of file diff --git a/submodules/appdirs b/submodules/appdirs new file mode 160000 index 00000000..193a2cbb --- /dev/null +++ b/submodules/appdirs @@ -0,0 +1 @@ +Subproject commit 193a2cbba58cce2542882fcedd0e49f6763672ed diff --git a/submodules/pytoolconfig b/submodules/pytoolconfig new file mode 160000 index 00000000..549787fa --- /dev/null +++ b/submodules/pytoolconfig @@ -0,0 +1 @@ +Subproject commit 549787fa7d100c93333f48aaa9b07619f171736e diff --git a/submodules/rope b/submodules/rope index 62af070a..c0433a82 160000 --- a/submodules/rope +++ b/submodules/rope @@ -1 +1 @@ -Subproject commit 62af070aa5ed3505a2629a76778003ce7fd383f0 +Subproject commit c0433a82503ab4f8103f53d82655a004c6f9a93b diff --git a/submodules/tomli b/submodules/tomli new file mode 160000 index 00000000..7e563eed --- /dev/null +++ b/submodules/tomli @@ -0,0 +1 @@ +Subproject commit 7e563eed5286b5d46b8290a9f56a86d955b23a9a From 149ccf7c5be0753f5e9872c023ab2eeec3442105 Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Fri, 25 Nov 2022 09:28:37 -0300 Subject: [PATCH 24/37] Update git submodule reference to use https instead of git@ --- .gitmodules | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 1ef5f423..59d00541 100644 --- a/.gitmodules +++ b/.gitmodules @@ -50,10 +50,10 @@ url = https://github.com/uiri/toml.git [submodule "submodules/pytoolconfig"] path = submodules/pytoolconfig - url = git@github.com:bagel897/pytoolconfig.git + url = https://github.com/bagel897/pytoolconfig.git [submodule "submodules/tomli"] path = submodules/tomli - url = git@github.com:hukkin/tomli.git + url = https://github.com/hukkin/tomli.git [submodule "submodules/appdirs"] path = submodules/appdirs - url = git@github.com:ActiveState/appdirs.git + url = https://github.com/ActiveState/appdirs.git From dedf83eb162f5ba91ed0cbd176fa69625af24859 Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Fri, 23 Jun 2023 23:41:26 -0300 Subject: [PATCH 25/37] Bump dependencies --- submodules/astroid | 2 +- submodules/autopep8 | 2 +- submodules/mccabe | 2 +- submodules/pycodestyle | 2 +- submodules/pyflakes | 2 +- submodules/pylama | 2 +- submodules/pylint | 2 +- submodules/rope | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/submodules/astroid b/submodules/astroid index 36dda3fc..8523ba82 160000 --- a/submodules/astroid +++ b/submodules/astroid @@ -1 +1 @@ -Subproject commit 36dda3fc8a5826b19a33a0ff29402b61d6a64fc2 +Subproject commit 8523ba827006d56a770a1f6efa77215718ef26c0 diff --git a/submodules/autopep8 b/submodules/autopep8 index 32c78a3a..6e6d4ba4 160000 --- a/submodules/autopep8 +++ b/submodules/autopep8 @@ -1 +1 @@ -Subproject commit 32c78a3a07d7ee35500e6f20bfcd621f3132c42e +Subproject commit 6e6d4ba4a043da1a56ca0ec7280a7d4f40283215 diff --git a/submodules/mccabe b/submodules/mccabe index 2d4dd943..85185224 160000 --- a/submodules/mccabe +++ b/submodules/mccabe @@ -1 +1 @@ -Subproject commit 2d4dd9435fcb05aaa89ba0392a84cb1d30a87dc9 +Subproject commit 851852240f2fa4453c226ccc5ae88bc03b467388 diff --git a/submodules/pycodestyle b/submodules/pycodestyle index 930e2cad..1063db87 160000 --- a/submodules/pycodestyle +++ b/submodules/pycodestyle @@ -1 +1 @@ -Subproject commit 930e2cad15df3661306740c30a892a6f1902ef1d +Subproject commit 1063db8747e7d4e213160458aa3792e5ec05bc10 diff --git a/submodules/pyflakes b/submodules/pyflakes index 95fe313b..b37f91a1 160000 --- a/submodules/pyflakes +++ b/submodules/pyflakes @@ -1 +1 @@ -Subproject commit 95fe313ba5ca384041472cd171ea60fad910c207 +Subproject commit b37f91a1ae25cfc242d5043985b05159e152091a diff --git a/submodules/pylama b/submodules/pylama index f436ccc6..53ad214d 160000 --- a/submodules/pylama +++ b/submodules/pylama @@ -1 +1 @@ -Subproject commit f436ccc6b55b33381a295ded753e467953cf4379 +Subproject commit 53ad214de0aa9534e59bcd5f97d9d723d16cfdb8 diff --git a/submodules/pylint b/submodules/pylint index 3eb0362d..fc34a4b6 160000 --- a/submodules/pylint +++ b/submodules/pylint @@ -1 +1 @@ -Subproject commit 3eb0362dc42642e3e2774d7523a1e73d71394064 +Subproject commit fc34a4b6abe56f3ac07ca15d846b1c1955545f85 diff --git a/submodules/rope b/submodules/rope index c0433a82..b0c8a5fc 160000 --- a/submodules/rope +++ b/submodules/rope @@ -1 +1 @@ -Subproject commit c0433a82503ab4f8103f53d82655a004c6f9a93b +Subproject commit b0c8a5fc03ecbc94bd85dff46fc8b3f98f26a91e From 25b30ced6e9545a53a6bceb3bde3c5d95630f649 Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Fri, 23 Jun 2023 23:49:23 -0300 Subject: [PATCH 26/37] Fix pylama import --- pymode/lint.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pymode/lint.py b/pymode/lint.py index ba187558..c03bd255 100644 --- a/pymode/lint.py +++ b/pymode/lint.py @@ -6,7 +6,7 @@ import os.path -from pylama.lint.extensions import LINTERS +from pylama.lint import LINTERS try: from pylama.lint.pylama_pylint import Linter @@ -35,11 +35,11 @@ def code_check(): # Fixed in v0.9.3: these two parameters may be passed as strings. # DEPRECATE: v:0.10.0: need to be set as lists. if isinstance(env.var('g:pymode_lint_ignore'), str): - raise ValueError ('g:pymode_lint_ignore should have a list type') + raise ValueError('g:pymode_lint_ignore should have a list type') else: ignore = env.var('g:pymode_lint_ignore') if isinstance(env.var('g:pymode_lint_select'), str): - raise ValueError ('g:pymode_lint_select should have a list type') + raise ValueError('g:pymode_lint_select should have a list type') else: select = env.var('g:pymode_lint_select') options = parse_options( From 4ad80be8bb9a0e55422ac0ee9654e9506be00e4a Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sat, 24 Jun 2023 00:16:57 -0300 Subject: [PATCH 27/37] Fix shellcheck in test --- tests/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index fe9fcae1..48345ad5 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -4,7 +4,7 @@ set -e which vim 1>/dev/null 2>/dev/null -cd $(dirname $0) +cd "$(dirname "$0")" # Source common variables. source ./test_helpers_bash/test_variables.sh @@ -49,7 +49,7 @@ RETURN_CODES=$(cat $VIM_OUTPUT_FILE | grep -i "Return code") echo -e "${RETURN_CODES}" # Exit the script with error if there are any return codes different from 0. -if echo $RETURN_CODES | grep -E "Return code: [1-9]" 1>/dev/null 2>/dev/null +if echo "${RETURN_CODES}" | grep -E "Return code: [1-9]" 1>/dev/null 2>/dev/null then exit 1 else From 74a7c7bf17fa48d46f4265be55ea6bf0e99bfc55 Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sat, 24 Jun 2023 00:32:49 -0300 Subject: [PATCH 28/37] Fix import error --- pymode/lint.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pymode/lint.py b/pymode/lint.py index c03bd255..d7d24449 100644 --- a/pymode/lint.py +++ b/pymode/lint.py @@ -65,7 +65,8 @@ def code_check(): return env.stop() if env.options.get('debug'): - from pylama.core import LOGGER, logging + import logging + from pylama.core import LOGGER LOGGER.setLevel(logging.DEBUG) errors = run(path, code='\n'.join(env.curbuf) + '\n', options=options) From d89385a205c23670456723a7f57cdb5e1b1e2acd Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sat, 24 Jun 2023 01:23:32 -0300 Subject: [PATCH 29/37] Fix erros due to pylama Erro class changes --- pymode/lint.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pymode/lint.py b/pymode/lint.py index d7d24449..c5304043 100644 --- a/pymode/lint.py +++ b/pymode/lint.py @@ -84,11 +84,16 @@ def __sort(e): env.debug("Find sorting: ", sort_rules) errors = sorted(errors, key=__sort) + errors_list = [] for e in errors: - e._info['bufnr'] = env.curbuf.number - if e._info['col'] is None: - e._info['col'] = 1 - - env.run('g:PymodeLocList.current().extend', [e._info for e in errors]) + if e.col is None: + e.col = 1 + err_dict = e.to_dict() + err_dict['bufnr'] = env.curbuf.number + err_dict['type'] = e.etype + err_dict['text'] = e.message + errors_list.append(err_dict) + + env.run('g:PymodeLocList.current().extend', errors_list) # pylama:ignore=W0212,E1103 From d44851ce678d53832f5fc021e1f845eb5290645a Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sat, 24 Jun 2023 10:18:06 -0300 Subject: [PATCH 30/37] Improve tests outputs --- tests/test.sh | 6 +++--- tests/test_bash/test_autocommands.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index 48345ad5..acf75076 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -26,9 +26,9 @@ declare -a TEST_ARRAY=( set +e for ONE_TEST in "${TEST_ARRAY[@]}" do - echo "Starting test: $ONE_TEST" >> $VIM_OUTPUT_FILE - bash -x "$ONE_TEST" - echo -e "\n$ONE_TEST: Return code: $?" >> $VIM_OUTPUT_FILE + echo "Starting test: $ONE_TEST" | tee $VIM_OUTPUT_FILE + bash "$ONE_TEST" + echo -e "\n$ONE_TEST: Return code: $?" | tee $VIM_OUTPUT_FILE bash ./test_helpers_bash/test_prepare_between_tests.sh done diff --git a/tests/test_bash/test_autocommands.sh b/tests/test_bash/test_autocommands.sh index bc46b9d5..9fabebfd 100644 --- a/tests/test_bash/test_autocommands.sh +++ b/tests/test_bash/test_autocommands.sh @@ -19,7 +19,7 @@ declare -a TEST_PYMODE_COMMANDS_ARRAY=( set +e for ONE_PYMODE_COMMANDS_TEST in "${TEST_PYMODE_COMMANDS_ARRAY[@]}" do - echo "Starting test: $0:$ONE_PYMODE_COMMANDS_TEST" >> $VIM_OUTPUT_FILE + echo "Starting test: $0:$ONE_PYMODE_COMMANDS_TEST" | tee $VIM_OUTPUT_FILE RETURN_CODE=$(vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source $ONE_PYMODE_COMMANDS_TEST" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1) ### Enable the following to execute one test at a time. @@ -27,7 +27,7 @@ do ### FOR PINPOINT TESTING ### exit 1 RETURN_CODE=$? - echo -e "\n$0:$ONE_PYMODE_COMMANDS_TEST: Return code: $RETURN_CODE" >> $VIM_OUTPUT_FILE + echo -e "\n$0:$ONE_PYMODE_COMMANDS_TEST: Return code: $RETURN_CODE" | tee $VIM_OUTPUT_FILE bash ./test_helpers_bash/test_prepare_between_tests.sh done From a4731b47b1847bbf80eb7c5d5a6cee50a2b42b48 Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sat, 24 Jun 2023 15:54:15 -0300 Subject: [PATCH 31/37] [Tests] apply shellcheck on shell test files and import tests outputs --- tests/test.sh | 41 ++++++++-------- tests/test_bash/test_autocommands.sh | 12 +++-- tests/test_bash/test_autopep8.sh | 5 +- tests/test_bash/test_folding.sh | 47 +++++++------------ tests/test_bash/test_pymodelint.sh | 9 ++-- tests/test_bash/test_textobject.sh | 12 ++--- tests/test_helpers_bash/test_createvimrc.sh | 45 +++++++++--------- .../test_prepare_between_tests.sh | 9 ++-- tests/test_helpers_bash/test_prepare_once.sh | 4 +- tests/test_helpers_bash/test_variables.sh | 12 +++-- 10 files changed, 97 insertions(+), 99 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index acf75076..eb4ec018 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -22,38 +22,37 @@ declare -a TEST_ARRAY=( "./test_bash/test_folding.sh" "./test_bash/test_textobject.sh" ) +MAIN_RETURN=0 ## now loop through the above array set +e -for ONE_TEST in "${TEST_ARRAY[@]}" +for TEST in "${TEST_ARRAY[@]}" do - echo "Starting test: $ONE_TEST" | tee $VIM_OUTPUT_FILE - bash "$ONE_TEST" - echo -e "\n$ONE_TEST: Return code: $?" | tee $VIM_OUTPUT_FILE + echo "Starting test: ${TEST}" | tee -a "${VIM_OUTPUT_FILE}" + bash "${TEST}" + R=$? + MAIN_RETURN=$(( MAIN_RETURN + R )) + echo -e "${TEST}: Return code: ${R}\n" | tee -a "${VIM_OUTPUT_FILE}" bash ./test_helpers_bash/test_prepare_between_tests.sh done -# Show errors: -E1=$(grep -E "^E[0-9]+:" $VIM_OUTPUT_FILE) -E2=$(grep -E "^Error" $VIM_OUTPUT_FILE) -E3="$E1\n$E2" -if [ "$E3" = "\n" ] -then - echo "No errors." -else - echo "Errors:" - echo -e "$E3\n" -fi +echo "=========================================================================" +echo " RESULTS" +echo "=========================================================================" # Show return codes. -RETURN_CODES=$(cat $VIM_OUTPUT_FILE | grep -i "Return code") +RETURN_CODES=$(grep -i "Return code" < "${VIM_OUTPUT_FILE}" | grep -v "Return code: 0") echo -e "${RETURN_CODES}" -# Exit the script with error if there are any return codes different from 0. -if echo "${RETURN_CODES}" | grep -E "Return code: [1-9]" 1>/dev/null 2>/dev/null -then - exit 1 +# Show errors: +E1=$(grep -E "^E[0-9]+:" "${VIM_OUTPUT_FILE}") +E2=$(grep -Ei "^Error" "${VIM_OUTPUT_FILE}") +if [[ "${MAIN_RETURN}" == "0" ]]; then + echo "No errors." else - exit 0 + echo "Errors:" + echo -e "${E1}\n${E2}" fi +# Exit the script with error if there are any return codes different from 0. +exit ${MAIN_RETURN} # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_bash/test_autocommands.sh b/tests/test_bash/test_autocommands.sh index 9fabebfd..89d8a70d 100644 --- a/tests/test_bash/test_autocommands.sh +++ b/tests/test_bash/test_autocommands.sh @@ -15,20 +15,24 @@ declare -a TEST_PYMODE_COMMANDS_ARRAY=( ### FOR PINPOINT TESTING ### "./test_procedures_vimscript/pymoderun.vim" ### FOR PINPOINT TESTING ### ) +RETURN_CODE=0 + ## now loop through the above array set +e for ONE_PYMODE_COMMANDS_TEST in "${TEST_PYMODE_COMMANDS_ARRAY[@]}" do - echo "Starting test: $0:$ONE_PYMODE_COMMANDS_TEST" | tee $VIM_OUTPUT_FILE - RETURN_CODE=$(vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source $ONE_PYMODE_COMMANDS_TEST" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1) + CONTENT="$(vim --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ${ONE_PYMODE_COMMANDS_TEST}" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" ### Enable the following to execute one test at a time. ### FOR PINPOINT TESTING ### vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source $ONE_PYMODE_COMMANDS_TEST" $VIM_DISPOSABLE_PYFILE ### FOR PINPOINT TESTING ### exit 1 - RETURN_CODE=$? - echo -e "\n$0:$ONE_PYMODE_COMMANDS_TEST: Return code: $RETURN_CODE" | tee $VIM_OUTPUT_FILE + SUB_TEST_RETURN_CODE=$? + echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" + RETURN_CODE=$(( RETURN_CODE + SUB_TEST_RETURN_CODE )) + echo -e "\tSubTest: $0:${ONE_PYMODE_COMMANDS_TEST}: Return code: ${SUB_TEST_RETURN_CODE}" | tee -a "${VIM_OUTPUT_FILE}" bash ./test_helpers_bash/test_prepare_between_tests.sh done +exit ${RETURN_CODE} # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_bash/test_autopep8.sh b/tests/test_bash/test_autopep8.sh index 05585725..2a70072a 100644 --- a/tests/test_bash/test_autopep8.sh +++ b/tests/test_bash/test_autopep8.sh @@ -2,9 +2,10 @@ # Source file. set +e -RETURN_CODE=$(vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/autopep8.vim" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1) +CONTENT="$(vim --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ./test_procedures_vimscript/autopep8.vim" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" RETURN_CODE=$? +echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" set -e -exit $RETURN_CODE +exit ${RETURN_CODE} # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_bash/test_folding.sh b/tests/test_bash/test_folding.sh index d0ac884a..60e60c42 100644 --- a/tests/test_bash/test_folding.sh +++ b/tests/test_bash/test_folding.sh @@ -2,35 +2,24 @@ # Note: a solution with unix 'timeout' program was tried but it was unsuccessful. The problem with folding 4 is that in the case of a crash one expects the folding to just stay in an infinite loop, thus never existing with error. An improvement is suggested to this case. -# Source file. -set +e -source ./test_helpers_bash/test_prepare_between_tests.sh -vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding1.vim" $VIM_DISPOSABLE_PYFILE > /dev/null -R1=$? -source ./test_helpers_bash/test_prepare_between_tests.sh -vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding2.vim" $VIM_DISPOSABLE_PYFILE > /dev/null -R2=$? -source ./test_helpers_bash/test_prepare_between_tests.sh -# TODO: enable folding3.vim script back. -# vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding3.vim" $VIM_DISPOSABLE_PYFILE > /dev/null -# R3=$? -source ./test_helpers_bash/test_prepare_between_tests.sh -vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding4.vim" $VIM_DISPOSABLE_PYFILE > /dev/null -R4=$? -set -e +declare -a TEST_PYMODE_FOLDING_TESTS_ARRAY=( + "./test_procedures_vimscript/folding1.vim" + "./test_procedures_vimscript/folding2.vim" + # "./test_procedures_vimscript/folding3.vim" + "./test_procedures_vimscript/folding4.vim" + ) + +RETURN_CODE=0 -if [[ "$R1" -ne 0 ]] -then - exit 1 -elif [[ "$R2" -ne 0 ]] -then - exit 2 -# elif [[ "$R3" -ne 0 ]] -# then -# exit 3 -elif [[ "$R4" -ne 0 ]] -then - exit 4 -fi +set +e +for SUB_TEST in "${TEST_PYMODE_FOLDING_TESTS_ARRAY[@]}"; do + CONTENT="$(vim --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ${SUB_TEST}" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" + SUB_TEST_RETURN_CODE=$? + echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" + RETURN_CODE=$(( RETURN_CODE + SUB_TEST_RETURN_CODE )) + echo -e "\tSubTest: $0:${SUB_TEST}: Return code: ${SUB_TEST_RETURN_CODE}" | tee -a "${VIM_OUTPUT_FILE}" + bash ./test_helpers_bash/test_prepare_between_tests.sh +done +exit ${RETURN_CODE} # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_bash/test_pymodelint.sh b/tests/test_bash/test_pymodelint.sh index 583d0774..9f903955 100644 --- a/tests/test_bash/test_pymodelint.sh +++ b/tests/test_bash/test_pymodelint.sh @@ -5,10 +5,11 @@ # Source file. set +e -vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/pymodelint.vim" $VIM_DISPOSABLE_PYFILE -# RETURN_CODE=$(vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/pymodeversion.vim" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1) -# RETURN_CODE=$? +# vim --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ./test_procedures_vimscript/pymodelint.vim" "${VIM_DISPOSABLE_PYFILE}" >> "${VIM_OUTPUT_FILE}" 2>&1 +CONTENT="$(vim --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ./test_procedures_vimscript/pymodeversion.vim" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" +RETURN_CODE=$? +echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" set -e -# exit $RETURN_CODE +exit ${RETURN_CODE} # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_bash/test_textobject.sh b/tests/test_bash/test_textobject.sh index 43a799f9..cf90c87a 100644 --- a/tests/test_bash/test_textobject.sh +++ b/tests/test_bash/test_textobject.sh @@ -2,14 +2,12 @@ # Source file. set +e +# shellcheck source=../test_helpers_bash/test_prepare_between_tests.sh source ./test_helpers_bash/test_prepare_between_tests.sh -vim --clean -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/textobject.vim" $VIM_DISPOSABLE_PYFILE > /dev/null -R1=$? +CONTENT="$(vim --clean -i NONE -u "${VIM_TEST_VIMRC}" -c "source ./test_procedures_vimscript/textobject.vim" "${VIM_DISPOSABLE_PYFILE}" 2>&1)" +RETURN_CODE=$? +echo -e "${CONTENT}" >> "${VIM_OUTPUT_FILE}" set -e -if [[ "$R1" -ne 0 ]] -then - exit 1 -fi - +exit ${RETURN_CODE} # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_helpers_bash/test_createvimrc.sh b/tests/test_helpers_bash/test_createvimrc.sh index ae763b95..d816df98 100644 --- a/tests/test_helpers_bash/test_createvimrc.sh +++ b/tests/test_helpers_bash/test_createvimrc.sh @@ -1,26 +1,27 @@ #! /bin/bash # Create minimal vimrc. -echo -e "syntax on\nfiletype plugin indent on\nset nocompatible" >> $VIM_TEST_VIMRC -echo "call has('python3')" >> $VIM_TEST_VIMRC -echo "set paste" >> $VIM_TEST_VIMRC -echo "set shortmess=at" >> $VIM_TEST_VIMRC -echo "set cmdheight=10" >> $VIM_TEST_VIMRC -echo "set ft=python" >> $VIM_TEST_VIMRC -echo "set shell=bash" >> $VIM_TEST_VIMRC -echo "set noswapfile" >> $VIM_TEST_VIMRC -echo "set backupdir=" >> $VIM_TEST_VIMRC -echo "set undodir=" >> $VIM_TEST_VIMRC -echo "set viewdir=" >> $VIM_TEST_VIMRC -echo "set directory=" >> $VIM_TEST_VIMRC -echo -e "set runtimepath=" >> $VIM_TEST_VIMRC -echo -e "set runtimepath+=$(dirname $PWD)\n" >> $VIM_TEST_VIMRC -echo -e "set packpath+=/tmp\n" >> $VIM_TEST_VIMRC -# echo -e "redir! >> $VIM_OUTPUT_FILE\n" >> $VIM_TEST_VIMRC -echo -e "set verbosefile=$VIM_OUTPUT_FILE\n" >> $VIM_TEST_VIMRC -echo -e "let g:pymode_debug = 1" >> $VIM_TEST_VIMRC - -echo "set nomore" >> $VIM_TEST_VIMRC - - +cat <<-EOF >> "${VIM_TEST_VIMRC}" + syntax on + filetype plugin indent on + set nocompatible + call has('python3') + set paste + set shortmess=at + set cmdheight=10 + set ft=python + set shell=bash + set noswapfile + set backupdir= + set undodir= + set viewdir= + set directory= + set runtimepath= + set runtimepath+="$(dirname "${PWD}")" + set packpath+=/tmp + " redir! >> "${VIM_OUTPUT_FILE}" + set verbosefile="${VIM_OUTPUT_FILE}" + let g:pymode_debug = 1 + set nomore +EOF # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_helpers_bash/test_prepare_between_tests.sh b/tests/test_helpers_bash/test_prepare_between_tests.sh index cdce9869..7a8f52e7 100644 --- a/tests/test_helpers_bash/test_prepare_between_tests.sh +++ b/tests/test_helpers_bash/test_prepare_between_tests.sh @@ -2,11 +2,12 @@ # Prepare tests. set +e -if [ -f $VIM_DISPOSABLE_PYFILE ]; then - rm $VIM_DISPOSABLE_PYFILE +if [ -f "${VIM_DISPOSABLE_PYFILE}" ]; then + rm "${VIM_DISPOSABLE_PYFILE}" fi -export VIM_DISPOSABLE_PYFILE=`mktemp /tmp/pymode.tmpfile.XXXXXXXXXX.py` +VIM_DISPOSABLE_PYFILE="$(mktemp /tmp/pymode.tmpfile.XXXXXXXXXX.py)" +export VIM_DISPOSABLE_PYFILE set -e -touch $VIM_DISPOSABLE_PYFILE +touch "${VIM_DISPOSABLE_PYFILE}" # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_helpers_bash/test_prepare_once.sh b/tests/test_helpers_bash/test_prepare_once.sh index dad77182..da986b53 100644 --- a/tests/test_helpers_bash/test_prepare_once.sh +++ b/tests/test_helpers_bash/test_prepare_once.sh @@ -2,11 +2,11 @@ # Prepare tests. set +e -rm $VIM_OUTPUT_FILE $VIM_TEST_VIMRC $VIM_TEST_PYMODECOMMANDS $VIM_DISPOSABLE_PYFILE 2&>/dev/null +rm "${VIM_OUTPUT_FILE}" "${VIM_TEST_VIMRC}" "${VIM_TEST_PYMODECOMMANDS}" "${VIM_DISPOSABLE_PYFILE}" 2&>/dev/null rm /tmp/*pymode* 2&>/dev/null rm -rf /tmp/pack mkdir -p /tmp/pack/test_plugins/start -ln -s $(dirname $(pwd)) /tmp/pack/test_plugins/start/ +ln -s "$(dirname "$(pwd)")" /tmp/pack/test_plugins/start/ set -e # vim: set fileformat=unix filetype=sh wrap tw=0 : diff --git a/tests/test_helpers_bash/test_variables.sh b/tests/test_helpers_bash/test_variables.sh index 53edb5e5..f1995022 100644 --- a/tests/test_helpers_bash/test_variables.sh +++ b/tests/test_helpers_bash/test_variables.sh @@ -3,9 +3,13 @@ # Define variables for common test scripts. # Set variables. -export VIM_DISPOSABLE_PYFILE=`mktemp /tmp/pymode.tmpfile.XXXXXXXXXX.py` -export VIM_OUTPUT_FILE=/tmp/pymode.out -export VIM_TEST_VIMRC=/tmp/pymode_vimrc -export VIM_TEST_PYMODECOMMANDS=/tmp/pymode_commands.txt +VIM_DISPOSABLE_PYFILE="$(mktemp /tmp/pymode.tmpfile.XXXXXXXXXX.py)" +export VIM_DISPOSABLE_PYFILE +VIM_OUTPUT_FILE=/tmp/pymode.out +export VIM_OUTPUT_FILE +VIM_TEST_VIMRC=/tmp/pymode_vimrc +export VIM_TEST_VIMRC +VIM_TEST_PYMODECOMMANDS=/tmp/pymode_commands.txt +export VIM_TEST_PYMODECOMMANDS # vim: set fileformat=unix filetype=sh wrap tw=0 : From a87f7896ea847c91f3b08ea1c95bf0f1043ebaf3 Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sun, 2 Jul 2023 22:17:01 -0300 Subject: [PATCH 32/37] Replace pep8 with pycodestyle For more info see: https://github.com/python-mode/python-mode/pull/1170#issuecomment-1610771071 --- doc/pymode.txt | 10 +++++----- plugin/pymode.vim | 8 ++++---- pymode/lint.py | 6 ++++++ tests/utils/pymoderc | 4 ++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/doc/pymode.txt b/doc/pymode.txt index c8f9dd2b..3565a4c3 100644 --- a/doc/pymode.txt +++ b/doc/pymode.txt @@ -293,7 +293,7 @@ Manually set breakpoint command (leave empty for automatic detection) 3. Code checking ~ *pymode-lint* -Pymode supports `pylint`, `pep257`, `pep8`, `pyflakes`, `mccabe` code +Pymode supports `pylint`, `pep257`, `pycodestyle`, `pyflakes`, `mccabe` code checkers. You could run several similar checkers. Pymode uses Pylama library for code checking. Many options like skip @@ -330,9 +330,9 @@ Show error message if cursor placed at the error line *'g:pymode_lint_message' Default code checkers (you could set several) *'g:pymode_lint_checkers'* > - let g:pymode_lint_checkers = ['pyflakes', 'pep8', 'mccabe'] + let g:pymode_lint_checkers = ['pyflakes', 'pycodestyle', 'mccabe'] -Values may be chosen from: `pylint`, `pep8`, `mccabe`, `pep257`, `pyflakes`. +Values may be chosen from: `pylint`, `pycodestyle`, `mccabe`, `pep257`, `pyflakes`. Skip errors and warnings *'g:pymode_lint_ignore'* E.g. ["W", "E2"] (Skip all Warnings and the Errors starting with E2) etc. @@ -376,9 +376,9 @@ Definitions for |signs| Pymode has the ability to set code checkers options from pymode variables: -Set PEP8 options *'g:pymode_lint_options_pep8'* +Set PEP8 options *'g:pymode_lint_options_pycodestyle'* > - let g:pymode_lint_options_pep8 = + let g:pymode_lint_options_pycodestyle = \ {'max_line_length': g:pymode_options_max_line_length} See https://pep8.readthedocs.org/en/1.4.6/intro.html#configuration for more diff --git a/plugin/pymode.vim b/plugin/pymode.vim index 232dc2af..82ab95ff 100644 --- a/plugin/pymode.vim +++ b/plugin/pymode.vim @@ -122,8 +122,8 @@ call pymode#default("g:pymode_lint_on_fly", 0) " Show message about error in command line call pymode#default("g:pymode_lint_message", 1) -" Choices are: pylint, pyflakes, pep8, mccabe and pep257 -call pymode#default("g:pymode_lint_checkers", ['pyflakes', 'pep8', 'mccabe']) +" Choices are: pylint, pyflakes, pycodestyle, mccabe and pep257 +call pymode#default("g:pymode_lint_checkers", ['pyflakes', 'pycodestyle', 'mccabe']) " Skip errors and warnings (e.g. E4,W) call pymode#default("g:pymode_lint_ignore", []) @@ -152,8 +152,8 @@ call pymode#default("g:pymode_lint_info_symbol", "II") call pymode#default("g:pymode_lint_pyflakes_symbol", "FF") " Code checkers options -" TODO: check if most adequate name name is pep8 or pycodestyle. -call pymode#default("g:pymode_lint_options_pep8", +" TODO: check if most adequate name name is pycodestyle. +call pymode#default("g:pymode_lint_options_pycodestyle", \ {'max_line_length': g:pymode_options_max_line_length}) call pymode#default("g:pymode_lint_options_pylint", diff --git a/pymode/lint.py b/pymode/lint.py index c5304043..b0103a50 100644 --- a/pymode/lint.py +++ b/pymode/lint.py @@ -42,6 +42,12 @@ def code_check(): raise ValueError('g:pymode_lint_select should have a list type') else: select = env.var('g:pymode_lint_select') + if 'pep8' in linters: + # TODO: Add a user visible deprecation warning here + env.message('pep8 linter is deprecated, please use pycodestyle.') + linters.remove('pep8') + linters.append('pycodestyle') + options = parse_options( linters=linters, force=1, ignore=ignore, diff --git a/tests/utils/pymoderc b/tests/utils/pymoderc index 222c6ceb..3a8477ea 100644 --- a/tests/utils/pymoderc +++ b/tests/utils/pymoderc @@ -25,7 +25,7 @@ let g:pymode_lint_on_write = 1 let g:pymode_lint_unmodified = 0 let g:pymode_lint_on_fly = 0 let g:pymode_lint_message = 1 -let g:pymode_lint_checkers = ['pyflakes', 'pep8', 'mccabe'] +let g:pymode_lint_checkers = ['pyflakes', 'pycodestyle', 'mccabe'] let g:pymode_lint_ignore = ["E501", "W",] let g:pymode_lint_select = ["E501", "W0011", "W430"] let g:pymode_lint_sort = [] @@ -37,7 +37,7 @@ let g:pymode_lint_visual_symbol = 'RR' let g:pymode_lint_error_symbol = 'EE' let g:pymode_lint_info_symbol = 'II' let g:pymode_lint_pyflakes_symbol = 'FF' -let g:pymode_lint_options_pep8 = +let g:pymode_lint_options_pycodestyle = \ {'max_line_length': g:pymode_options_max_line_length} let g:pymode_lint_options_pyflakes = { 'builtins': '_' } let g:pymode_lint_options_mccabe = { 'complexity': 12 } From a28ace5bee0ea292be9f979f3c651c47cc39b284 Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sun, 2 Jul 2023 22:20:11 -0300 Subject: [PATCH 33/37] Update changelog --- CHANGELOG.md | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 001a9194..f8e3dbf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,36 @@ ## TODO +- Update submodules + - Fix Errors related to these updates +- Improve tests outputs +- Fix Global and Module MoveRefactoring (#1141) Thanks to @lieryan +- Text object/operator/motion mapping to select logical line (#1145). Thanks to + @lieryan +- Remove dead keywords and builtins; add match, case (#1149). Thanks to + @NeilGirdhar +- Add syntax highlight for walrus (#1147) Thanks to @fpob +- Add configurable prefix for rope commands (#1137) TThanks to @NathanTP +- Add option g:pymode_indent_hanging_width for different hanging indentation + width (#1138). Thanks to @wookayin + +## 2020-10-08 0.13.0 + +- Add toml submodule + +## 2020-10-08 0.12.0 + +- Improve breakpoint feature +- Improve debugging script +- Update submodules +- Improve tests + +## 2020-05-28 0.11.0 + - Move changelog rst syntax to markdown - `pymode_rope`: check disables -- Remove supoort for python 2. From 0.11.0 on we will focus on supporting - python 3+ (probably 3.5+). +- BREAKING CHANGE: Remove supoort for python 2. From 0.11.0 on we will focus on + supporting python 3+ (probably 3.5+). - Inspect why files starting with the following code do not get loaded: ```python @@ -16,6 +42,12 @@ main() ``` +- added github actions test suit and remove travis +- improved submodules cloning (shallow) +- Removes `six` submodule +- Fix motion mapping +- Fix breakpoint feature + ## 2019-05-11 0.10.0 After many changes, including moving most of our dependencies from copied From aee5c38a63b5d191ca1e0304903f1aa57256d5a5 Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sun, 2 Jul 2023 22:22:56 -0300 Subject: [PATCH 34/37] Update bumpversion --- .bumpversion.cfg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 613addba..0eda784d 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -8,3 +8,7 @@ tag_name = {new_version} [bumpversion:file:doc/pymode.txt] search = Version: {current_version} replace = Version: {new_version} + +[bumpversion:file:CHANGELOG.md] +search = Version: {current_version} +replace = Version: {new_version} From d69efa5624a60244b94d47d09e7309e0ac04b8e9 Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Sun, 2 Jul 2023 22:20:47 -0300 Subject: [PATCH 35/37] =?UTF-8?q?Bump=20version:=200.13.0=20=E2=86=92=200.?= =?UTF-8?q?14.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- CHANGELOG.md | 2 ++ doc/pymode.txt | 2 +- plugin/pymode.vim | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 0eda784d..84607ec8 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,6 +1,6 @@ [bumpversion] commit = True -current_version = 0.13.0 +current_version = 0.14.0 files = plugin/pymode.vim tag = True tag_name = {new_version} diff --git a/CHANGELOG.md b/CHANGELOG.md index f8e3dbf7..4e7668dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## TODO +## 2023-07-02 0.14.0 + - Update submodules - Fix Errors related to these updates - Improve tests outputs diff --git a/doc/pymode.txt b/doc/pymode.txt index 3565a4c3..7235b5d5 100644 --- a/doc/pymode.txt +++ b/doc/pymode.txt @@ -6,7 +6,7 @@ (__) (__) (__) (_) (_)(_____)(_)\_) (_/\/\_)(_____)(____/(____) ~ - Version: 0.13.0 + Version: 0.14.0 =============================================================================== CONTENTS *pymode-contents* diff --git a/plugin/pymode.vim b/plugin/pymode.vim index 82ab95ff..b0d99270 100644 --- a/plugin/pymode.vim +++ b/plugin/pymode.vim @@ -1,5 +1,5 @@ " vi: fdl=1 -let g:pymode_version = "0.13.0" +let g:pymode_version = "0.14.0" " Enable pymode by default :) From afc201a3e7416d95fb3238558b589223ffc0b07f Mon Sep 17 00:00:00 2001 From: Jongwook Choi Date: Thu, 21 Sep 2023 22:45:53 -0400 Subject: [PATCH 36/37] Fix PathFinder.find_module AttributeError for Python 3.12 PathFinder.find_module() has been deprecated since Python 3.4 in favor of find_spec(), and it's finally removed in Python 3.12. This line will throw an AttributeError which makes pymode completely unusable with python 3.12. It was a hacky workaround introduced in #1028. Maybe we can completely remove this workaround because it's 4 years ago and the minimum supported python version is now 3.6+. --- pymode/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pymode/__init__.py b/pymode/__init__.py index aba22870..906d7059 100644 --- a/pymode/__init__.py +++ b/pymode/__init__.py @@ -6,7 +6,13 @@ import vim # noqa if not hasattr(vim, 'find_module'): - vim.find_module = _PathFinder.find_module + try: + vim.find_module = _PathFinder.find_module # deprecated + except AttributeError: + def _find_module(package_name): + spec = _PathFinder.find_spec(package_name) + return spec.loader if spec else None + vim.find_module = _find_module def auto(): From d43292ed5edfd19beea41b1b6ca8b69275bd1c38 Mon Sep 17 00:00:00 2001 From: "Sean M. Collins" Date: Thu, 16 May 2024 12:20:30 -0400 Subject: [PATCH 37/37] Move to pycodestyle 2.11.0 https://github.com/PyCQA/flake8/issues/1845#issuecomment-1766073353 --- submodules/pycodestyle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/pycodestyle b/submodules/pycodestyle index 1063db87..21abd9b6 160000 --- a/submodules/pycodestyle +++ b/submodules/pycodestyle @@ -1 +1 @@ -Subproject commit 1063db8747e7d4e213160458aa3792e5ec05bc10 +Subproject commit 21abd9b6dcbfa38635bc85a2c2327ec11ad91ffc