Skip to content

Commit

Permalink
Apply and improve reviewer's suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed Aug 29, 2023
1 parent 845836e commit 326abf8
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,7 @@ def _split_lines(self, text: str, width: int) -> List[str]:

def _toml_to_parseconfig(toml_dict: Dict[str, Any]) -> Dict[str, Any]:
"""Convert a dict read from a TOML file to the parseconfig.read_dict() format."""
parseconfig_dict = {}
for key, value in toml_dict.items():
if value is False:
pass
elif value is True:
parseconfig_dict[key] = ""
else:
parseconfig_dict[key] = value
return parseconfig_dict
return {k: "" if v is True else v for k, v in toml_dict.items() if v is not False}


def parse_options(
Expand Down Expand Up @@ -579,9 +571,8 @@ def parse_options(
for toml_file in toml_files:
with open(toml_file, "rb") as f:
data = tomllib.load(f).get("tool", {})
for tool, tool_dict in data.items():
if tool == "codespell": # only "codespell" for performance
data[tool] = _toml_to_parseconfig(tool_dict)
if "codespell" in data:
data["codespell"] = _toml_to_parseconfig(data["codespell"])
config.read_dict(data)

# Collect which config files are going to be used
Expand Down

0 comments on commit 326abf8

Please sign in to comment.