From b7eb6e2abd86f6fea7a6db9a7698e06fd5a55ef4 Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Sun, 16 Nov 2025 18:47:06 -0400 Subject: [PATCH 1/2] feat: validate mypyc attrs --- mypyc/irbuild/util.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mypyc/irbuild/util.py b/mypyc/irbuild/util.py index 3028e940f7f9..b7610fcf2738 100644 --- a/mypyc/irbuild/util.py +++ b/mypyc/irbuild/util.py @@ -137,6 +137,12 @@ def get_mypyc_attrs( lines: dict[MypycAttr, int] = {} def set_mypyc_attr(key: str, value: Any, line: int) -> None: + if ( + (key == "native_class" and value is False and attrs.get("allow_interpreted_subclasses") is True) + or (key == "allow_interpreted_subclasses" and value is True and attrs.get("native_class") is False) + ): + errors.error("'allow_interpreted_subclasses' cannot be True if 'native_class' is False" + if key in MYPYC_ATTRS: key = cast(MypycAttr, key) attrs[key] = value From f3d98028adc1667b08603f8d89f3790580e915a4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 16 Nov 2025 22:50:44 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mypyc/irbuild/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypyc/irbuild/util.py b/mypyc/irbuild/util.py index b7610fcf2738..c2ba8f04b808 100644 --- a/mypyc/irbuild/util.py +++ b/mypyc/irbuild/util.py @@ -142,7 +142,7 @@ def set_mypyc_attr(key: str, value: Any, line: int) -> None: or (key == "allow_interpreted_subclasses" and value is True and attrs.get("native_class") is False) ): errors.error("'allow_interpreted_subclasses' cannot be True if 'native_class' is False" - + if key in MYPYC_ATTRS: key = cast(MypycAttr, key) attrs[key] = value