metaopt / optree

OpTree: Optimized PyTree Utilities
https://optree.readthedocs.io
Apache License 2.0
146 stars 7 forks source link

[Feature Request] Add flake8-comprehensions linter #32

Closed Skylion007 closed 1 year ago

Skylion007 commented 1 year ago

Required prerequisites

Motivation

Since this project is speed motivated, it would best best use flake8-comprehensions to ensure that any list/dict/tuple etc comprehensions. Skimming over the list, of checks it looks like most if not all the best practices are already implemented in this repo, best just to add it though to ensure that future sub-optimal codepaths are not accidentally introduced.

We recently enabled almost all the checks in the latest version of PyTorch.

Solution

Add flake8-comprehensions plugin

Alternatives

Do not add it, rely on code review to maintain performance and avoid useless or wasteful comprehensions, builtin calls, etc.

Additional context

We enabled all the checks in PyTorch anyhow.

XuehaiPan commented 1 year ago

Thanks for the advice. I'm going to investigate enabling more flake8 plugins.

Skylion007 commented 1 year ago

@XuehaiPan FYI, ruff has a pretty good list of plugins (and automated fixes for some): https://beta.ruff.rs/docs/rules/

XuehaiPan commented 1 year ago

@Skylion007 I opened a new PR #34 to resolve this.