From c7189d99ec36054a627dcdd2552cc5cb1ff86e0c Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Wed, 1 Oct 2025 13:18:11 -0400 Subject: [PATCH 1/4] feat(docs): docstring for `mypyc_attr` I find in-editor tooltips to be very helpful when learning new tools, so I added a simple docstring for mypyc_attr with info I wish I knew originally. Longer term I'd like to expand this docstring with info on the various attrs and what they do, but I don't want to start on that unless this is approved. --- mypy_extensions.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mypy_extensions.py b/mypy_extensions.py index 1910000..4046dd2 100644 --- a/mypy_extensions.py +++ b/mypy_extensions.py @@ -159,6 +159,16 @@ def trait(cls): def mypyc_attr(*attrs, **kwattrs): + """ + Define specific attributes for the decorated object when compiled with mypyc. + + This decorator can be used with args or with kwargs. The following 2 snippets are the same: + + `mypyc_attr("serializable", "allow_interpreted_subclasses")` + + `mypyc_attr(serializable=True, allow_interpreted_subclasses=True)` + """ + # TODO: add some information on the available attrs so it can be viewed directly in user's IDE return lambda x: x From d9d1698670340367083c1fdb2a4fe0da90781e8e Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Wed, 1 Oct 2025 13:38:23 -0400 Subject: [PATCH 2/4] Update mypy_extensions.py --- mypy_extensions.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mypy_extensions.py b/mypy_extensions.py index 4046dd2..88b2c9c 100644 --- a/mypy_extensions.py +++ b/mypy_extensions.py @@ -162,11 +162,17 @@ def mypyc_attr(*attrs, **kwattrs): """ Define specific attributes for the decorated object when compiled with mypyc. - This decorator can be used with args or with kwargs. The following 2 snippets are the same: - - `mypyc_attr("serializable", "allow_interpreted_subclasses")` - - `mypyc_attr(serializable=True, allow_interpreted_subclasses=True)` + Examples: + This decorator can be used with args or with kwargs. + The following 2 snippets are equivalent: + + Using positional arguments: + + mypyc_attr("serializable", "allow_interpreted_subclasses") + + Using keyword arguments: + + mypyc_attr(serializable=True, allow_interpreted_subclasses=True) """ # TODO: add some information on the available attrs so it can be viewed directly in user's IDE return lambda x: x From 625994316fae6fc6f70db9984517582b6407dc3b Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Wed, 1 Oct 2025 18:01:13 -0400 Subject: [PATCH 3/4] Update mypy_extensions.py --- mypy_extensions.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mypy_extensions.py b/mypy_extensions.py index 88b2c9c..3c718f2 100644 --- a/mypy_extensions.py +++ b/mypy_extensions.py @@ -168,11 +168,13 @@ def mypyc_attr(*attrs, **kwattrs): Using positional arguments: - mypyc_attr("serializable", "allow_interpreted_subclasses") + @mypyc_attr("serializable", "allow_interpreted_subclasses") + class MyClass: ... Using keyword arguments: - mypyc_attr(serializable=True, allow_interpreted_subclasses=True) + @mypyc_attr(serializable=True, allow_interpreted_subclasses=True) + class MyClass: ... """ # TODO: add some information on the available attrs so it can be viewed directly in user's IDE return lambda x: x From 2be4ed384aa0c86aeee2a20d07b5483f81a9be4c Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Wed, 1 Oct 2025 23:23:47 -0400 Subject: [PATCH 4/4] lint whitespace --- mypy_extensions.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mypy_extensions.py b/mypy_extensions.py index 3c718f2..f5fb4e0 100644 --- a/mypy_extensions.py +++ b/mypy_extensions.py @@ -167,12 +167,12 @@ def mypyc_attr(*attrs, **kwattrs): The following 2 snippets are equivalent: Using positional arguments: - + @mypyc_attr("serializable", "allow_interpreted_subclasses") class MyClass: ... - + Using keyword arguments: - + @mypyc_attr(serializable=True, allow_interpreted_subclasses=True) class MyClass: ... """