[New Rule] Replace hasattr
if else with getattr
when appropiate
#180
Labels
enhancement
New feature or request
hasattr
if else with getattr
when appropiate
#180
Explanation
This code is more succinct, readable, and slightly more efficient. We recently opened a few PRs to add this to the PyTorch codebase. Exhibit A: pytorch/pytorch#100360 If you are aware of a different flake8-plugin / ruleset that implements this rule, feel free to recommend it.
Example
The text was updated successfully, but these errors were encountered: