-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
[BE] Fix SIM118 in-dict-keys
#100339
[BE] Fix SIM118 in-dict-keys
#100339
Conversation
Use {key} in {dict} instead of {key} in {dict}.keys() [ghstack-poisoned]
Use {key} in {dict} instead of {key} in {dict}.keys() ghstack-source-id: d6afa1f8deadc56deb609100f84534802a0f3fc7 Pull Request resolved: #100339
torch/profiler/_utils.py
Outdated
@@ -96,7 +96,7 @@ def __init__(self, prof: profile): | |||
self.profile = prof | |||
self.metrics: Dict[EventKey, EventMetrics] = {} | |||
self.compute_self_time() | |||
self.event_keys = sorted((e for e in self.metrics.keys()), | |||
self.event_keys = sorted((e for e in self.metrics), |
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.
self.event_keys = sorted((e for e in self.metrics), | |
self.event_keys = sorted(self.metrics, |
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.
Done
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.
I just opened an issue to add a new flake8 comprehension rule to detect these. :) adamchainz/flake8-comprehensions#503
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.
There probably is one already IIRC. I am not sure if it is enabled in our config
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.
@justinchuby Nah, I enabled almost every flake8-comprehension rule in our config, even the ones I added recently. :)
Use {key} in {dict} instead of {key} in {dict}.keys() cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire [ghstack-poisoned]
Use {key} in {dict} instead of {key} in {dict}.keys() cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire [ghstack-poisoned]
Use {key} in {dict} instead of {key} in {dict}.keys() ghstack-source-id: a8b1f7c7e412fd43c17ee60e599df8ca96c21fe4 Pull Request resolved: pytorch#100339 Signed-off-by: Justin Chu <justinchu@microsoft.com>
Use {key} in {dict} instead of {key} in {dict}.keys() cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire [ghstack-poisoned]
Use {key} in {dict} instead of {key} in {dict}.keys() ghstack-source-id: a8b1f7c7e412fd43c17ee60e599df8ca96c21fe4 Pull Request resolved: pytorch#100339 Signed-off-by: Justin Chu <justinchu@microsoft.com>
Use {key} in {dict} instead of {key} in {dict}.keys() cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire [ghstack-poisoned]
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.
changes in this file LGTM
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.
Also LGTM
@@ -269,7 +269,7 @@ def update_bn(loader, model, device=None): | |||
|
|||
model(input) | |||
|
|||
for bn_module in momenta.keys(): | |||
for bn_module in momenta: |
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.
Would it be better to use an items() call here since we access the key in the next line?
k | ||
for k in dict(module.named_parameters()).keys() | ||
if LINEAR_SKIP in k | ||
k for k in dict(module.named_parameters()) if LINEAR_SKIP in k |
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 dict() call here is unnecessary now, just unpack the tuple.
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.
Changes under torch/utils/data/datapipes/iter
LGTM!
Hey! This comment applies to most PRs in this stack. |
Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as |
Stack from ghstack (oldest at bottom):
suppressible-exception
#100336unused-loop-control-variable
#100341reimplemented-builtin
#100338in-dict-keys
#100339Use {key} in {dict} instead of {key} in {dict}.keys()
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @peterbell10 @ipiszy @ngimel @yf225 @chenyang78 @anijain2305 @soumith @desertfire