A backslash-character pair that is not a valid escape sequence now generates a SyntaxWarning, instead of DeprecationWarning. For example, re.compile("\d+.\d+") now emits a SyntaxWarning ("\d" is an invalid escape sequence), use raw strings for regular expression: re.compile(r"\d+.\d+"). In a future Python version, SyntaxError will eventually be raised, instead of SyntaxWarning. (Contributed by Victor Stinner in gh-98401.)
So, I think the regular expressions that we use in our snippets need to either be tweaked, or converted to raw strings which is probably easier. Otherwise, I get such warnings (with YouCompleteMe):
An error occured. This is either a bug in UltiSnips or a bug in a
snippet definition. If you think this is a bug, please report it to
https://github.com/SirVer/ultisnips/issues/new
Please read and follow:
https://github.com/SirVer/ultisnips/blob/master/CONTRIBUTING.md#reproducing-bugs
Following is the full stack trace:
Traceback (most recent call last):
File "/home/asinha/.vim/plugged/ultisnips/pythonx/UltiSnips/err_to_scratch_buffer.py", line 47, in wrapper
return func(self, *args, **kwds)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/asinha/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet_manager.py", line 205, in snippets_in_current_scope
snippets = self._snips(before, True)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/asinha/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet_manager.py", line 679, in _snips
source.ensure(filetypes)
File "/home/asinha/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet/source/file/base.py", line 32, in ensure
self._load_snippets_for(ft)
File "/home/asinha/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet/source/file/base.py", line 53, in _load_snippets_for
for fn in self._get_all_snippet_files_for(ft):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/asinha/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet/source/file/ulti_snips.py", line 218, in _get_all_snippet_files_for
return find_all_snippet_files(ft)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/asinha/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet/source/file/ulti_snips.py", line 74, in find_all_snippet_files
for directory in find_all_snippet_directories():
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/asinha/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet/source/file/ulti_snips.py", line 39, in find_all_snippet_directories
if vim_helper.eval("exists('b:UltiSnipsSnippetDirectories')") == "1":
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/asinha/.vim/plugged/ultisnips/pythonx/UltiSnips/vim_helper.py", line 123, in eval
return vim.eval(text)
^^^^^^^^^^^^^^
vim.error: Vim:<global-snippets>:15: SyntaxWarning: invalid escape sequence '\w'
No such warnings are received on Python <= 3.11.
Expected behavior:
No warnings
Actual behavior:
Warnings related to escape sequences.
Steps to reproduce
Use provided vimrc file, install plugins: vim -u <path to vimrc> -c :PlugInstall
Open a new Java file with vim, but using provided vimrc file : vim -u <path to vimrc> test.java
Enter insert mode with i. Type a letter, like p. View error message at bottom, or use :messages.
Operating System: : Fedora 39
Vim Version: VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Sep 05 2023 00:00:00); Included patches: 1-1872
With Python 3.12, invalid escape sequences throw SyntaxWarnings instead of Deprecation warnings:
So, I think the regular expressions that we use in our snippets need to either be tweaked, or converted to raw strings which is probably easier. Otherwise, I get such warnings (with YouCompleteMe):
No such warnings are received on Python <= 3.11.
Expected behavior:
No warnings
Actual behavior:
Warnings related to escape sequences. Steps to reproduce
vim -u <path to vimrc> -c :PlugInstall
vim -u <path to vimrc> test.java
i
. Type a letter, likep
. View error message at bottom, or use:messages
.Operating System: : Fedora 39
Vim Version: VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Sep 05 2023 00:00:00); Included patches: 1-1872
UltiSnips Version: https://github.com/SirVer/ultisnips/commit/24a3ebb36687b6d59a19d63173713575b486d739
Python inside Vim: 3.12.0rc3 (main, Sep 19 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)]
Docker repo/vimrc: