Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
akeeman committed Sep 25, 2020
1 parent 52b7aa8 commit 9f534ee
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions autoflake.py
Expand Up @@ -999,25 +999,19 @@ def process_setup_cfg(cfg_file_path):

reader = configparser.ConfigParser()
reader.read(cfg_file_path)
if "autoflake" not in reader.sections():
if not reader.has_section("autoflake"):
return None

config = {}
for opt in reader.options("autoflake"):
if opt in {
"check", "expand_star_imports", "ignore_init_module_imports",
"in_place", "recursive", "remove_all_unused_imports",
"remove_duplicate_keys", "remove_unused_variables",
}:
try:
value = reader.getboolean("autoflake", opt)
except ValueError:
value = "invalid value"
else:
value = reader.get("autoflake", opt)
config[opt] = value
bool_opts = {
"check", "expand_star_imports", "ignore_init_module_imports",
"in_place", "recursive", "remove_all_unused_imports",
"remove_duplicate_keys", "remove_unused_variables",
}

return config
return {
reader.BOOLEAN_STATES.get(v, v) if k in bool_opts else v
for k, v in reader["autoflake"].items()
}


def merge_configuration_file(args):
Expand Down

0 comments on commit 9f534ee

Please sign in to comment.