Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stubgen] Include simple decorators in stub files #18489

Merged
merged 1 commit into from
Jan 25, 2025

Conversation

cdce8p
Copy link
Collaborator

@cdce8p cdce8p commented Jan 19, 2025

Stubgen historically only included a selected number of decorators in the generated stubs. I couldn't find the actual reason for it, however it's likely fair to assume that decorator typing only started being possible with PEP 612 thus most had been untyped previously.

As it's fairly simple to annotate decorators with ParamSpec now, it's probably fair to include them in the stub file now.

Comment on lines +349 to +350
@decorator(x=1, y={"a": 1})
def foo_bar(x): ...
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decorator CallExpr are left for a future PR. For type checker to be able to infer the correct type, all arguments need to be passed along as well.

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@hauntsaninja hauntsaninja merged commit 3ced11a into python:master Jan 25, 2025
12 checks passed
@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Jan 25, 2025

Yeah, re: history, I think the PEP 612 thing is right

@cdce8p cdce8p deleted the stubgen-decorators-1 branch January 25, 2025 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants