This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author devarakondapranav
Recipients benjamin.peterson, devarakondapranav, xtreak
Date 2018-10-15.18:08:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1539626913.21.0.788709270274.issue34978@psf.upfronthosting.co.za>
In-reply-to
Content
Thank you very much for pointing out some helpful things,  Karthikeyan. 

>True if 1 in list(a.keys()) if type(a) == dict else a.keys() else False

True that the fixer would return a syntax error in this case. I missed adding a pair of parenthesis to the whole if statement. I mean

True if 1 in (list(a.keys()) if type(a) == dict else  a.keys()) else False

is valid code. So adding parenthesis would solve the problem as I did in the updated patch I uploaded.

I don't see this updated fixer returning errors in other cases like nested if conditions or list comprehensions, since the fixer would convert the respective function calls of dict objects into separate statements, would not interfere with other if statements(or any other statements for that matter) and set the order of precedence appropriately.

Please do point out if there any other cases I missed. 

I know this is a less pythonic but is more accurate :) Thanks.
History
Date User Action Args
2018-10-15 18:08:33devarakondapranavsetrecipients: + devarakondapranav, benjamin.peterson, xtreak
2018-10-15 18:08:33devarakondapranavsetmessageid: <1539626913.21.0.788709270274.issue34978@psf.upfronthosting.co.za>
2018-10-15 18:08:33devarakondapranavlinkissue34978 messages
2018-10-15 18:08:33devarakondapranavcreate