limitations/language.md
Monty parses Python source with Ruff's parser but rejects several constructs
at parse time. Anything listed below raises NotImplementedError (prefixed
with "The monty syntax parser does not yet support ") at compile time, before
any code runs.
class definitions — bare class Foo: ... is not supported. There
is no in-sandbox class factory: @dataclass, typing.NamedTuple, and
collections.namedtuple are all unavailable inside the sandbox (and
collections is not importable). Host-supplied dataclass / namedtuple
values can be passed in and used; use a plain function or a host-defined
type for new structured data. See classes.md.with / async with statements — no context manager protocol. This
means no with open(...) as f: (call f.close() explicitly). See
open.md.yield / yield from expressions — no generator functions. Generator
expressions ((x for x in ...)) parse but currently materialize to a
list rather than a lazy iterator (this is a known temporary divergence;
see iter__generator_expr_type.py).match statements — structural pattern matching is not supported.del statements — neither del x nor del d[k] parse.try* / except* exception groups — PEP 654 syntax rejected.type aliases (PEP 695 type Foo = int).async for loops and async comprehensions.from m import *) — raises ImportError: "Wildcard imports (\from ... import *`) are not supported"`.[*xs, *ys],
f(*args)). Function calls with *args unpacking are not supported.**kwargs unpacking in a single call (f(**a, **b)).1j, 2+3j).:=) — also rejected.SyntaxError: Source is too deeply nested.with, etc.), including the synthetic nesting from a flat multi-item with — see with.md.too many nested parentheses, too many statically nested blocks, …).ModuleNotFoundError.from . import x) raise ImportError: "attempted relative import with no known parent package" — there is no package
system.__import__ is not defined.def, async def), nested functions, closures, decorators.try / except / else / finally, raise ... from ....for / while / if / elif / else, break, continue, pass,
assert, global, nonlocal, return.import x, import x.y, from x import y, z as w.= debug specifier, !r/!s/!a conversions, and
format specs.