Small python autocomplete related changes

This commit is contained in:
Andrix44 2023-01-14 18:38:27 +01:00 committed by Christian Heitman
parent c6bb33d599
commit 6ea044868a
3 changed files with 9 additions and 11 deletions

View file

@ -180,5 +180,9 @@ else()
set(TRITON_BOOST_INTERFACE OFF)
endif()
if(PYTHON_BINDINGS_AUTOCOMPLETE)
message(STATUS "Compiling with Python autocomplete stub")
endif()
add_subdirectory(src)
add_subdirectory(doc)

View file

@ -1,12 +1,8 @@
from __future__ import print_function
# triton_autocomplete will raise an import error.
# IDEs should still provide autocomplete based on
# the triton_autocomplete module
# The triton_autocomplete module has been replaced with a .pyi stub file
# which is automatically installed when using a precompiled Triton package
# IDEs should detect it and provide autocomplete without any extra imports
from triton import *
try:
from triton_autocomplete import *
except ImportError:
pass
ctx = TritonContext()

View file

@ -276,15 +276,13 @@ def get_namespaces(namespace_dir):
def gen_init_file(modules):
# type: (List[str]) -> str
global args
mod_str = """
from typing import List, Union, Callable, Tuple
mod_str = """from typing import List, Union, Callable, Tuple
import triton
{z3}
{modules}
raise ImportError
""".format(z3='import z3' if args.z3_enabled else '', modules='\n\n'.join(modules))
""".format(z3='import z3\n' if args.z3_enabled else '', modules='\n\n'.join(modules))
return mod_str
args = None