8000 [BE][Easy] Fix `PYI034`: non-self-return-type in tensor method hints by XuehaiPan · Pull Request #129886 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[BE][Easy] Fix PYI034: non-self-return-type in tensor method hints #129886

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

Closed
wants to merge 35 commits into from

Conversation

XuehaiPan
Copy link
Collaborator
@XuehaiPan XuehaiPan commented Jul 1, 2024

In gen_pyi.py, we add generated method hints for dunder magic methods for class TensorBase at:

${tensor_method_hints}

such as:

class TensorBase:
    @overload
    def __add__(self, other: Tensor) -> Tensor: ...
    @overload
    def __add__(self, other: Union[Number, _complex]) -> Tensor: ...
    @overload
    def __add__(self, other: Any) -> Tensor: ...
    @overload
    def __iadd__(self, other: Tensor) -> Tensor: ...
    @overload
    def __iadd__(self, other: Union[Number, _complex]) -> Tensor: ...
    @overload
    def __iadd__(self, other: Any) -> Tensor: ...

This PR changes the return type of in-place binary operations (e.g. __iadd__, __imul__, ...) from Tensor to Self to fix non-self-return-type (PYI034).

class TensorBase:
    @overload
    def __add__(self, other: Tensor) -> Tensor: ...
    @overload
    def __add__(self, other: Union[Number, _complex]) -> Tensor: ...
    @overload
    def __add__(self, other: Any) -> Tensor: ...
    @overload
    def __iadd__(self, other: Tensor) -> Self: ...
    @overload
    def __iadd__(self, other: Union[Number, _complex]) -> Self: ...
    @overload
    def __iadd__(self, other: Any) -> Self: ...

Stack from ghstack (oldest at bottom):

cc @ezyang @malfet @xuzhao9 @gramster

[ghstack-poisoned]
@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label Jul 1, 2024
Copy link
pytorch-bot bot commented Jul 1, 2024

🔗 Helpful Links

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

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

❌ 3 New Failures

As of commit f31f883 with merge base ffb9790 (image):

NEW FAILURES - The following jobs have failed:

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

[ghstack-poisoned]
[ghstack-poisoned]
@XuehaiPan XuehaiPan added the module: typing Related to mypy type annotations label Jul 1, 2024
@XuehaiPan XuehaiPan requested a review from Skylion007 July 1, 2024 18:29
XuehaiPan added 2 commits July 2, 2024 02:30
[ghstack-poisoned]
Update 8000
[ghstack-poisoned]
XuehaiPan added 2 commits July 2, 2024 03:17
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Copy link
Contributor
@malfet malfet left a comment

Choose a reason for hiding this comment

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

To be frank, I'm quite at loss if how PR title connected to any of the changes you are proposing here

@XuehaiPan
Copy link
Collaborator Author

To be frank, I'm quite at loss if how PR title connected to any of the changes you are proposing here

Sorry, I have updated the PR comment for what this PR is doing.

[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Jul 20, 2024
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Aug 1, 2024
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Aug 2, 2024
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Aug 2, 2024
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Aug 3, 2024
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Aug 3, 2024
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Aug 4, 2024
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Aug 4, 2024
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Aug 4, 2024
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Aug 12, 2024
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Aug 12, 2024
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Oct 11, 2024
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Oct 11, 2024
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Oct 11, 2024
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Oct 24, 2024
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Oct 24, 2024
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Nov 11, 2024 6D40
Copy link
Contributor

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 Jan 10, 2025
@github-actions github-actions bot closed this Feb 9, 2025
@github-actions github-actions bot deleted the gh/XuehaiPan/104/head branch March 12, 2025 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: typing Related to mypy type annotations open source Stale topic: not user facing topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0