Page MenuHomePhabricator

[lint] Require flake8-builtins to ensure we do not add shadowing of python builtins
ClosedPublic

Authored by sdulfari on Apr 19 2023, 17:51.

Details

Summary

D13739 eliminates arguments that shadow python builtins (A002) so we should start enforcing that lint rule right away.

A001 (shadowing of variables) can and should be eliminated since it poses similar risk to A002. There are currently 30 instances of A001 in the code base so these need to be cleaned up before we enable this in our linter config.

A003 will remain ignored because it is mostly useless. A003 catches shadowing of class attributes but this does not make sense. For example, the python builtin set() conflicts with a common API pattern that is currently in use by ECKey and ECPubKey. Updating this API just to not conflict with python builtins will be confusing and not actually achieve anything since the attribute cannot conflict with the builtin function call anyway.

Depends on D13739

Test Plan
pip3 install flake8-builtins

Revert changes to any file from D13675 then:

arc lint

Observe an A002 error code.

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Apr 19 2023, 19:15