Skip to content

Commit

Permalink
Add --builtins-whitelist option
Browse files Browse the repository at this point in the history
  • Loading branch information
gsingh93 authored and gforcada committed Oct 8, 2022
1 parent 552face commit af2a709
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion flake8_builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
}


BUILTINS = [a[0] for a in inspect.getmembers(builtins) if a[0] not in WHITE_LIST]
# Will be initialized in `BuiltinsChecker.parse_options`
BUILTINS = None

if sys.version_info >= (3, 8):
NamedExpr = ast.NamedExpr
Expand All @@ -32,6 +33,25 @@ def __init__(self, tree, filename):
self.tree = tree
self.filename = filename

def add_options(option_manager):
option_manager.add_option(
'--builtins-whitelist',
metavar='builtins',
parse_from_config=True,
comma_separated_list=True,
help='A comma separated list of builtins to skip checking',
)

def parse_options(option_manager, options, args):
global BUILTINS

if options.builtins_whitelist is not None:
WHITE_LIST.update(options.builtins_whitelist)

BUILTINS = [
a[0] for a in inspect.getmembers(builtins) if a[0] not in WHITE_LIST
]

def run(self):
tree = self.tree

Expand Down

0 comments on commit af2a709

Please sign in to comment.