-
Notifications
You must be signed in to change notification settings - Fork 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
{Pylint} Fix use-dict-literal #30308
Conversation
️✔️AzureCLI-FullTest
|
Hi @atombrella, |
️✔️AzureCLI-BreakingChangeTest
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
Thanks for your contribution. The disabled rules were introduced in #20192. I think it's okay to fix them. Could you please also remove them from |
dict()
with {}
, set([])
with set()
I can do that, but it'll be quite a bit of work. You unfortunately still accept PRs with |
#20192 was created by me. I ignored them simply because we didn't have bandwidth to work on those issues. So yes, please also remove them from Line 45 in be4af71
|
I will fix |
@atombrella, could you remove Line 45 in be4af71
|
dict()
with {}
, set([])
with set()
13492c3
to
9350692
Compare
I did check with ruff to find all of them :) I hadn't heard of ruff before, it seems to quite useful/powerful. C408 is indeed a superset of https://pylint.readthedocs.io/en/stable/user_guide/messages/refactor/use-dict-literal.html There are many great suggestions from flake8-comprehensions. For instance, I experimented briefly today with one of the examples from https://www.geeksforgeeks.org/python-dictionary-fromkeys-method/ to check the performance improvements of using Note that in some places, I reformatted the code slightly. IMO it improves readability to split comprehensions over more lines. One case is: info_dict = {
lun: {"managedDisk": {'storageAccountType': None}}
for lun in dummy_expected if lun != "os"
} |
fc63718
to
0aeed99
Compare
@bebound Could you help with the failed "Azure.azure-cli (Codegen Coverage)". I don't think my changes are related. |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
I created a PR, but I couldn't reproduce the issue. I'll try running |
@@ -107,11 +107,14 @@ def test_subscription_recording_processor_for_response(self): | |||
|
|||
for template in body_templates: | |||
mock_sub_id = str(uuid.uuid4()) | |||
mock_response = dict({'body': {}}) |
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.
This dict()
is a no-op, not sure why it was written like that in the first place.
@atombrella, Thank you very much for the contribution! |
@jiasli You're welcome 😃 Note that since my PR was approved and merged, something was merged that now violates the fixed linting rule.
|
Fixed by #30442 |
Related command
Various commands are "affected" by this. Please check the diff.
Description
flake8-comprehensions has the two suggestions I try to remedy.
You can check the marginal benefits with
timeit
inipython
.I wonder why these two rules are disabled in
pylintrc
. Maybe it's for historic reasons.The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.