fake-bpy-module icon indicating copy to clipboard operation
fake-bpy-module copied to clipboard

Failed to format _.pyi

Open Road-hog123 opened this issue 1 year ago • 0 comments

When I run gen_module.sh I get the following error:

error: Failed to format _.pyi: source contains syntax errors: ParseError { error: Lexical(UnicodeError), offset: 396, source_path: "<filename>" }
Traceback (most recent call last):
  File "...\fake-bpy-module\src\gen.py", line 336, in <module>
    main()
  File "...\fake-bpy-module\src\gen.py", line 332, in main
    pkg_generator.generate()
  File "...\fake-bpy-module\src\fake_bpy_module\generator.py", line 1393, in generate
    self._generate(
  File "...\fake-bpy-module\src\fake_bpy_module\generator.py", line 1377, in _generate
    self._generate_by_rule(
  File "...\fake-bpy-module\src\fake_bpy_module\generator.py", line 1369, in _generate_by_rule
    rule.generator().generate(
  File "...\fake-bpy-module\src\fake_bpy_module\generator.py", line 518, in generate
    wt.format(style_config, self.file_format)
  File "...\fake-bpy-module\src\fake_bpy_module\generator.py", line 99, in format
    self._code_data = io.StringIO(subprocess.check_output(
                                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['ruff', 'format', '--isolated', '--stdin-filename=_.pyi']' returned non-zero exit status 2.

I have also seen the offset be 1723. Running gen_module.sh with GEN_MODULE_CODE_FORMAT=none succeeds.

I attempted to use vscode's Python debugger to debug gen.py, but this resulted in a different error on the same line:

[WinError 2] The system cannot find the file specified
  File "...\fake-bpy-module\src\fake_bpy_module\generator.py", line 99, in format
    self._code_data = io.StringIO(subprocess.check_output(
                                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\fake-bpy-module\src\fake_bpy_module\generator.py", line 518, in generate
    wt.format(style_config, self.file_format)
  File "...\fake-bpy-module\src\fake_bpy_module\generator.py", line 1369, in _generate_by_rule
    rule.generator().generate(
  File "...\fake-bpy-module\src\fake_bpy_module\generator.py", line 1377, in _generate
    self._generate_by_rule(
  File "...\fake-bpy-module\src\fake_bpy_module\generator.py", line 1393, in generate
    self._generate(
  File "...\fake-bpy-module\src\gen.py", line 332, in main
    pkg_generator.generate()
  File "...\fake-bpy-module\src\gen.py", line 336, in <module>
    main()
FileNotFoundError: [WinError 2] The system cannot find the file specified

I was able to dump out the source the apparently contains errors at offset 396 or 1723, but it's nowhere near long enough for that:

import sys
import typing
from . import types
from . import path
from . import utils



GenericType = typing.TypeVar("GenericType")

I am running gen_module.sh with parameters to generate modules for 4.0.2. I'm using Git Bash to be able to run the bash script on Windows 10; and I have created, activated and installed the requirements into a Python 3.11 venv.

Road-hog123 avatar Feb 08 '24 23:02 Road-hog123