From 6132f14bcd2c1e1037b9ae51570ebbe906ab44ba Mon Sep 17 00:00:00 2001 From: David Salvisberg Date: Tue, 22 Sep 2026 16:56:59 +0200 Subject: [PATCH] Avoid accessing `__annotations__` in `get_directive_methods` With PEP-649/PEP-749 semantics this may invoke `__annotate__` with the default format of `Format.VALUE`, which may raise exceptions, but also cause unnecessary work, if the annotations are never inspected. --- dectate/app.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dectate/app.py b/dectate/app.py index 773cea0..d309cb5 100644 --- a/dectate/app.py +++ b/dectate/app.py @@ -100,6 +100,12 @@ def get_directive_methods( cls, ) -> Iterator[tuple[str, DirectiveMethod[Self, ...]]]: for name in dir(cls): + # NOTE: On Python 3.14+ this can invoke `__annotate__` with format + # `VALUE` which can raise a `NameError`, so it can both cause + # exceptions and also involve unnecessary work, so we explicitly + # avoid touching this attribute + if name == "__annotations__": + continue attr = getattr(cls, name) im_func = getattr(attr, "__func__", None) if im_func is None: