From 326abf816335648abcae9622eb2d9afbee4d0b35 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Tue, 29 Aug 2023 14:34:19 +0300 Subject: [PATCH] Apply and improve reviewer's suggestions --- codespell_lib/_codespell.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py index f509ef458af..ae6bc370251 100644 --- a/codespell_lib/_codespell.py +++ b/codespell_lib/_codespell.py @@ -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( @@ -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