Skip to content

Updates contextlib with ParamSpec #153623

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Skylion007
Copy link
Collaborator

@Skylion007 Skylion007 commented May 15, 2025

Copy link

pytorch-bot bot commented May 15, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/153623

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 3552243 with merge base 4f4ecc5 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@Skylion007 Skylion007 force-pushed the skylion007/torch-contextlib-attempt-1-2025-05-15 branch from ac1e39a to c487ef1 Compare May 15, 2025 15:27
@Skylion007 Skylion007 force-pushed the skylion007/torch-contextlib-attempt-1-2025-05-15 branch from 42ae24d to 3552243 Compare May 15, 2025 17:38
@Skylion007 Skylion007 marked this pull request as ready for review May 19, 2025 13:28
"""Allow a context manager to be used as a decorator without parentheses."""

def __new__(cls, orig_func=None):
@overload
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mypy doesn't like me returning a Callable from new here, but I am not sure what is the proper way to make it happy.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess this is supposed to only ever return an instance of cls ? :p

@Skylion007 Skylion007 requested review from atalman and ngimel May 19, 2025 14:16
@mikaylagawarecki mikaylagawarecki added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label May 20, 2025
Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

Mostly good!

if orig_func is None:
return super().__new__(cls)
return cls()(orig_func)
instance = super().__new__(cls)
return cast(Callable[P, R], instance(orig_func)) # type: ignore[misc]
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is dead code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wish it was... definitely deprecated code though

"""Allow a context manager to be used as a decorator without parentheses."""

def __new__(cls, orig_func=None):
@overload
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess this is supposed to only ever return an instance of cls ? :p

Copy link
Contributor

github-actions bot commented Aug 6, 2025

Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as Stale.
Feel free to remove the Stale label if you feel this was a mistake.
If you are unable to remove the Stale label please contact a maintainer in order to do so.
If you want the bot to never mark this PR stale again, add the no-stale label.
Stale pull requests will automatically be closed after 30 days of inactivity.

@github-actions github-actions bot added the Stale label Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/inductor module: dynamo open source release notes: python_frontend python frontend release notes category Stale triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants