Skip to content

Conversation

@jparise
Copy link
Member

@jparise jparise commented Apr 10, 2025

First, represent FunctionType as an enum.Enum. This is more about the data type's concept than any higher-level Enum features.

Then use FunctionType so improve the typing of various dictionaries and function signatures.

Lastly, use setattr() for our AST monkey patching. I tried a few other approaches here (using ast.(Async)FunctionDef subclasses, introducing a new protocol, etc.), but the monkey patching approach always came out the simplest and most obvious. Using setattr() avoids typing errors related to unknown direct attribute assignments.

First, represent FunctionType as an enum.Enum. This is more about the
data type's concept than any actual high-level features.

Then use FunctionType so improve the typing of various dictionaries and
function signatures.

Lastly, use setattr() for our AST monkey patching. I tried a few other
approaches here (using ast.(Async)FunctionDef subclasses, introducing a
new protocol, etc.), but the monkey patching approach always came out
the simplest and most obvious. Using setattr() avoids typing errors
related to unknown direct attribute assignments.
@jparise jparise requested a review from sigmavirus24 April 10, 2025 12:58
@jparise jparise merged commit d4e33d0 into PyCQA:main Apr 10, 2025
6 checks passed
@jparise jparise deleted the function-type branch April 10, 2025 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants