Skip to content

[BE] Resolve lint errors in .pyi stub files#150731

Closed
XuehaiPan wants to merge 32 commits intogh/XuehaiPan/268/basefrom
gh/XuehaiPan/268/head
Closed

[BE] Resolve lint errors in .pyi stub files#150731
XuehaiPan wants to merge 32 commits intogh/XuehaiPan/268/basefrom
gh/XuehaiPan/268/head

Conversation

@XuehaiPan
Copy link
Collaborator

@XuehaiPan XuehaiPan commented Apr 5, 2025

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Apr 5, 2025

🔗 Helpful Links

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

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit 4da6026 with merge base 8c16d0e (image):

UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:

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

[ghstack-poisoned]
[ghstack-poisoned]
@XuehaiPan XuehaiPan changed the title [BE] resolve lint errors in .pyi stub files [BE] Resolve lint errors in .pyi stub files Apr 5, 2025
[ghstack-poisoned]
[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Rebased gh/XuehaiPan/269/orig onto refs/remotes/origin/viable/strict because #150732 was rebased, please pull locally before adding more changes (for example, via ghstack checkout https://github.com/pytorch/pytorch/pull/150731)

XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Apr 7, 2025
ghstack-source-id: b60d2a1
Pull Request resolved: pytorch#150731
[ghstack-poisoned]
S = TypeVar("S", bound=torch.Tensor) # noqa: PYI001
P = ParamSpec("P") # noqa: PYI001
R = TypeVar("R", covariant=True) # return value (always covariant) # noqa: PYI001
T_co = TypeVar("T_co", covariant=True) # noqa: PYI001
Copy link
Contributor

Choose a reason for hiding this comment

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

Since it's "standard practice" why not have all of these start with an underscore? At least for R and T_co it can't be BC because you renamed them here...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These typevars are used in gen_pyi.py. The variable name without the underscore is easier to access.

pytorch/tools/pyi/gen_pyi.py

Lines 1118 to 1132 in 004dad4

"as_subclass": ["def as_subclass(self, cls: _Type[S]) -> S: ..."],
"_make_subclass": [
"@staticmethod \ndef _make_subclass({}) -> S: ...".format(
", ".join(
[
"cls: _Type[S]",
"data: Tensor",
"require_grad: _bool = False",
"dispatch_strides: _bool = False",
"dispatch_device: _bool = False",
"device_for_backend_keys: Optional[_device] = None",
]
)
)
],

[ghstack-poisoned]
@XuehaiPan XuehaiPan requested a review from aorenste May 15, 2025 15:24
[ghstack-poisoned]
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request May 16, 2025
ghstack-source-id: 424bb59
Pull Request resolved: pytorch#150731
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request May 17, 2025
ghstack-source-id: 7f7f13d
Pull Request resolved: pytorch#150731
@XuehaiPan XuehaiPan added the ciflow/trunk Trigger trunk jobs on your pull request label May 17, 2025
[ghstack-poisoned]
[ghstack-poisoned]
@XuehaiPan XuehaiPan requested review from a team, kulinseth and malfet as code owners May 17, 2025 10:14
@pytorch-bot pytorch-bot bot added the ciflow/mps Run MPS tests (subset of trunk) label May 17, 2025
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request May 17, 2025
ghstack-source-id: 2006754
Pull Request resolved: pytorch#150731
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request May 20, 2025
ghstack-source-id: 6fde54e
Pull Request resolved: pytorch#150731
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request May 26, 2025
ghstack-source-id: 2976383
Pull Request resolved: pytorch#150731
@XuehaiPan XuehaiPan closed this May 27, 2025
@github-actions github-actions bot deleted the gh/XuehaiPan/268/head branch June 27, 2025 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

better-engineering Relatively self-contained tasks for better engineering contributors ciflow/mps Run MPS tests (subset of trunk) ciflow/trunk Trigger trunk jobs on your pull request module: lint Issues related to our Python/C++ lint rules (run by Travis) module: typing Related to mypy type annotations open source topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants