Skip to content
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

style: Fix if-else-block-instead-of-if-exp (SIM108) (part 3) #4570

Merged

Conversation

echoix
Copy link
Member

@echoix echoix commented Oct 21, 2024

Last PR of this series. It finishes by enabling checking the rule with ruff.

PRs in this series: #4562, #4561

Ruff rule: https://docs.astral.sh/ruff/rules/if-else-block-instead-of-if-exp

@echoix echoix requested a review from ninsbl October 21, 2024 21:19
@github-actions github-actions bot added GUI wxGUI related Python Related code is in Python libraries labels Oct 21, 2024
@echoix
Copy link
Member Author

echoix commented Oct 21, 2024

On my fork I think it's bandit that will complain about the use of eval, that is only moved around

"" if keywords is None or keywords.text is None else keywords.text
)
shortcut = shortcut.text if shortcut is not None else ""
wxId = eval("wx." + wxId.text) if wxId is not None else wx.ID_ANY

Check warning

Code scanning / Bandit

Use of possibly insecure function - consider using safer ast.literal_eval. Warning

Use of possibly insecure function - consider using safer ast.literal_eval.
Co-authored-by: Anna Petrasova <[email protected]>
"" if keywords is None or keywords.text is None else keywords.text
)
shortcut = shortcut.text if shortcut is not None else ""
wxId = eval("wx." + wxId.text) if wxId is not None else wx.ID_ANY

Check warning

Code scanning / Bandit

Use of possibly insecure function - consider using safer ast.literal_eval.

Use of possibly insecure function - consider using safer ast.literal_eval.
@echoix echoix enabled auto-merge (squash) October 25, 2024 17:33
@echoix echoix disabled auto-merge October 25, 2024 17:34
@echoix echoix enabled auto-merge (squash) October 25, 2024 17:34
@echoix echoix merged commit 9e1e85d into OSGeo:main Oct 25, 2024
26 checks passed
@github-actions github-actions bot added this to the 8.5.0 milestone Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI wxGUI related libraries Python Related code is in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants