-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add TorchScopedLibraryVisitor #22
Conversation
@@ -0,0 +1 @@ | |||
3:11 TOR901 Use `torch.library._scoped_library` instead of `torch.library.Library` in PyTorch tests files. See https://github.com/pytorch/pytorch/pull/118318 for details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there is a way to suppress the lint? We'll probably want to allow some usages of torch.library.Library (just to test that API).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's disabled by default. When we enable it for some files, usual flake8 noqa
comments can be used to ignore some lines.
cst.metadata.WhitespaceInclusivePositionProvider, node | ||
) | ||
|
||
self.violations.append( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what limits this rule to files under test/ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rule is disabled by default. We can enable it for test/ in the CI config in pytorch/pytorch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the explanation, this is cool!
This PR adds a new category of rules, 'internal': rules that are used for PyTorch code itself, not for PyTorch users.
These rules starts with TOR9 and are not enabled by default.
The TorchScopedLibraryVisitor rule is based on pytorch/pytorch#118318 and a lint-only for now.
I'll try to add a codemod for it in the next PR. Codemod would be somewhat complicated, but probably worth it as the
pytorch/test/test_python_dispatch.py
file is thousands of lines of code.