Page 3 of 4
Re: plugin CudaFormatter + its formatters
Posted: 06.03.2026 06:48
by dima8101
main Alexey wrote: ↑04.03.2026 16:45
when plugin error occurs, usually it is a plugin crash, so see the Console panel for crash (red) lines there ...
An error occurs when auto-formatting a python file. The file is not auto-formatted.
When auto-formatting a C++ file, no errors occur at all. The file is not auto-formatted. However, the status bar displays [AStyle (C++)] Cannot format text.
The content of the cuda__astyle_format.cfg file
Code: Select all
--style=google --indent=spaces=4 --suffix=none
Python file formatting error log:
Code: Select all
Traceback (most recent call last):
File "/home/user/.config/cudatext/py/cuda_fmt/__init__.py", line 258, in on_save_pre
run_format(ed_self, func, '['+caption+'] ', True)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.config/cudatext/py/cuda_fmt/fmtrun.py", line 210, in run_format
text = do_format(text1)
File "/home/user/.config/cudatext/py/cuda_fmt_python_reindent/__init__.py", line 8, in do_reindent
r.run()
~~~~~^^
File "/home/user/.config/cudatext/py/cuda_fmt_python_reindent/reindent.py", line 203, in run
for _token in tokens:
^^^^^^
File "/usr/lib/python3.14/tokenize.py", line 592, in _generate_tokens_from_c_tokenizer
raise e from None
File "/usr/lib/python3.14/tokenize.py", line 588, in _generate_tokens_from_c_tokenizer
for info in it:
^^
File "<string>", line 70
sys.exit(1)
^
IndentationError: unindent does not match any outer indentation level
ERROR: Exception in CudaText for on_save_pre: IndentationError: unindent does not match any outer indentation level (line 70, offset 16): 'sys.exit(1)'
Re: plugin CudaFormatter + its formatters
Posted: 06.03.2026 11:56
by main Alexey
First about Python error. It occurs in module cuda_fmt_python_reindent, which is separate addon:
Formatter for Python: ReIndent
can you uninstall it yet as temp solution?
I will see why AStyle formatter dont work.
Re: plugin CudaFormatter + its formatters
Posted: 06.03.2026 12:03
by main Alexey
I have Win10 with Python 3.14.2.
Installed formatter for Python: ReIndent.
it works here ok on this file:
Code: Select all
if TEXT_OS == 'linux':
import subprocess
try:
LSB_RELEASE = subprocess.check_output('cat /etc/lsb-release', shell=True).decode('utf-8')
if ("Ubuntu" in LSB_RELEASE or "Debian" in LSB_RELEASE) and (TEXT_CPU == 'amd64'):
DEBIAN_UBUNTU = True
except:
pass
maybe it crashes on specific Py script? can you give me minimal example?
Re: plugin CudaFormatter + its formatters
Posted: 06.03.2026 12:14
by main Alexey
Now about AStyle formatter. You have Python 3.14. Formatter is based on 'pyastyle' lib. I asked Qwen AI:
>Python PyAStyle library from
https://pypi.org/project/pyastyle/#files - does it work under Python 3.14 on Linux x64?
Reply:
Short Answer: No, pyastyle does not work under Python 3.14 on Linux x64 — and it is very unlikely to work without significant modifications.
Why It Won't Work Out-of-the-Box:
- Abandoned Project: The GitHub repository (
https://github.com/timonwong/pyastyle) has had no commits since December 2015
GitHub
. The project is effectively unmaintained.
- C Extension Compatibility Issues: pyastyle is a C extension module wrapping the Artistic Style C++ library. Python 3.14 introduced significant C API changes, including:
New configuration API (PEP 741)
www.c-sharpcorner.com
Free-threading/GIL-related changes (PEP 703)
Python
Extension modules must now be audited for multiple-interpreter compatibility
Python
- No Source Build Guarantee: Even if you attempt to build from the source distribution (pyastyle-1.1.5.zip), you would need:
A working C/C++ toolchain on Linux x64
Python 3.14 development headers
Likely manual patches to handle deprecated/removed C API functions
--------------
so sorry, AStyle formatter is not working for you and for me. Maybe I will remove it.
if you need some C++ formatter, I maybe will try to make one from 'clang' tool. No promise.
Re: plugin CudaFormatter + its formatters
Posted: 07.03.2026 06:35
by dima8101
Thanks for the detailed response. AStyle - removed. Python: ReIndent tried on your example, works. At first I did not understand, the error writes when there are some places that cannot process.
On C++: I noticed that in the window of removing plugins there is a C++ lexer, (lexer: C++). For work it requires an Assembly lexer. All installed, but in cudaformater in the settings of C++ is missing.
Re: plugin CudaFormatter + its formatters
Posted: 07.03.2026 08:15
by main Alexey
>in cudaformater in the settings of C++ is missing.
You removed AStyle-fmt, so now you don't have C++ formatter, so C++ is missing. It's ok. Or I don't understand the issue.
>ReIndent... At first I did not understand, the error writes when there are some places that cannot process.
Can you give me example file? To fix the crash.
Re: plugin CudaFormatter + its formatters
Posted: 07.03.2026 08:31
by main Alexey
BTW, for Python it's recomended to use new formatter+linter:
`Linter for Python, using Ruff`.
Needs ruff. See its readme/readme.txt.
It is not for CudaFormatter, but it is also a formatter! it gives the menu item: 'Plugins / Ruff / Format current file'.
Seems it cannot format 'on saving', sorry.
Re: plugin CudaFormatter + its formatters
Posted: 07.03.2026 08:56
by main Alexey
I removed 'formatter Python ReIndent' because it is based on old script
https://pypi.org/project/reindent/
which has several forks, none of which is new. one fork which makes fix for multiline strings, was removed from github.
Modern alternatives
- formatter Python Black
- linter Python Ruff
Re: plugin CudaFormatter + its formatters
Posted: 07.03.2026 09:39
by dima8101
main Alexey wrote: ↑07.03.2026 08:15
Can you give me example file? To fix the crash.
I took your example.
Code: Select all
if TEXT_OS == 'linux':
import subprocess
try:
LSB_RELEASE = subprocess.check_output('cat /etc/lsb-release', shell=True).decode('utf-8')
if ("Ubuntu" in LSB_RELEASE or "Debian" in LSB_RELEASE) and (TEXT_CPU == 'amd64'):
DEBIAN_UBUNTU = True
except:
pass
In line 5, I removed two spaces before the second "if". In this case, I get an error.
With installed "formatter Python ReIndent" (Python Black - not installed)
Code: Select all
Traceback (most recent call last):
File "/home/user/.config/cudatext/py/cuda_fmt/__init__.py", line 258, in on_save_pre
run_format(ed_self, func, '['+caption+'] ', True)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.config/cudatext/py/cuda_fmt/fmtrun.py", line 210, in run_format
text = do_format(text1)
File "/home/user/.config/cudatext/py/cuda_fmt_python_reindent/__init__.py", line 8, in do_reindent
r.run()
~~~~~^^
File "/home/user/.config/cudatext/py/cuda_fmt_python_reindent/reindent.py", line 203, in run
for _token in tokens:
^^^^^^
File "/usr/lib/python3.14/tokenize.py", line 592, in _generate_tokens_from_c_tokenizer
raise e from None
File "/usr/lib/python3.14/tokenize.py", line 588, in _generate_tokens_from_c_tokenizer
for info in it:
^^
File "<string>", line 5
if ("Ubuntu" in LSB_RELEASE or "Debian" in LSB_RELEASE) and (TEXT_CPU == 'amd64'):
^
IndentationError: unindent does not match any outer indentation level
ERROR: Exception in CudaText for on_save_pre: IndentationError: unindent does not match any outer indentation level (line 5, offset 89): 'if ("Ubuntu" in LSB_RELEASE or "Debian" in LSB_RELEASE) and (TEXT_CPU == 'amd64'):'
With installed "formatter Python Black": (Python ReIndent - removed)
Code: Select all
Traceback (most recent call last):
File "/home/user/.config/cudatext/py/cuda_fmt/__init__.py", line 258, in on_save_pre
run_format(ed_self, func, '['+caption+'] ', True)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.config/cudatext/py/cuda_fmt/fmtrun.py", line 210, in run_format
text = do_format(text1)
File "/home/user/.config/cudatext/py/cuda_fmt_python_black/__init__.py", line 82, in do_format
text = black.format_str(text, mode=mode)
File "/home/user/.config/cudatext/py/cuda_fmt_python_black/black/__init__.py", line 1208, in format_str
dst_contents = _format_str_once(src_contents, mode=mode, lines=lines)
File "/home/user/.config/cudatext/py/cuda_fmt_python_black/black/__init__.py", line 1222, in _format_str_once
src_node = lib2to3_parse(src_contents.lstrip(), mode.target_versions)
File "/home/user/.config/cudatext/py/cuda_fmt_python_black/black/parsing.py", line 73, in lib2to3_parse
result = drv.parse_string(src_txt, True)
File "/home/user/.config/cudatext/py/cuda_fmt_python_black/blib2to3/pgen2/driver.py", line 204, in parse_string
return self.parse_tokens(tokens, debug)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
File "/home/user/.config/cudatext/py/cuda_fmt_python_black/blib2to3/pgen2/driver.py", line 129, in parse_tokens
for quintuple in proxy:
^^^^^
File "/home/user/.config/cudatext/py/cuda_fmt_python_black/blib2to3/pgen2/driver.py", line 93, in __next__
token = next(self._tokens)
File "/home/user/.config/cudatext/py/cuda_fmt_python_black/blib2to3/pgen2/tokenize.py", line 748, in generate_tokens
raise IndentationError(
...<2 lines>...
)
File "<tokenize>", line 5
if ("Ubuntu" in LSB_RELEASE or "Debian" in LSB_RELEASE) and (TEXT_CPU == 'amd64'):
IndentationError: unindent does not match any outer indentation level
ERROR: Exception in CudaText for on_save_pre: IndentationError: unindent does not match any outer indentation level (line 5, offset 6): 'if ("Ubuntu" in LSB_RELEASE or "Debian" in LSB_RELEASE) and (TEXT_CPU == 'amd64'):'
Re: plugin CudaFormatter + its formatters
Posted: 07.03.2026 09:55
by main Alexey
Now I reproduce it, tks. Yes, all formatters crash with wrong indent on line 5. Do we need to catch the exception and show nice msg-box to user? Or is the wrong syntax - must be handled by the linter (e.g. Ruff linter)? Will think.