Linting dynamic

This commit is contained in:
Gouvernathor 2024-04-01 22:05:24 +02:00
parent 5e0513b2ce
commit 60244e258a

View File

@ -1,5 +1,14 @@
python early hide:
import inspect
try:
from renpy.lint import python_builtins, renpy_builtins
except ImportError:
import builtins
python_builtins = set(dir(builtins))
del builtins
renpy_builtins = set()
__register_params = frozenset(inspect.signature(renpy.register_statement).parameters).difference({"name", "parse"})
def register_decorator(cls):
"""
@ -54,6 +63,12 @@ python early hide:
evaled = {n: eval(e) for n, e in self.items()}
renpy.dynamic(**evaled)
def lint(self):
for domain, st in (("Python", python_builtins), ("Ren'Py", renpy_builtins)):
inter = st.intersection(self)
if inter:
renpy.error(f"Dynamic statement redefines one or several {domain} builtins: {', '.join(map(repr, inter))}")
@register_decorator
class chibi:
@staticmethod