diff --git a/coverage/config.py b/coverage/config.py index 3e4a8dd08..783bbbb75 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -291,12 +291,15 @@ def from_file(self, filename: str, warn: Callable[[str], None], our_file: bool) else: cp = HandyConfigParser(our_file) + print(f"{cp=}") self.attempted_config_files.append(filename) try: files_read = cp.read(filename) except (configparser.Error, TomlDecodeError) as err: + print(f"{err=}") raise ConfigError(f"Couldn't read config file {filename}: {err}") from err + print(f"{files_read=}") if not files_read: return False @@ -308,6 +311,7 @@ def from_file(self, filename: str, warn: Callable[[str], None], our_file: bool) was_set = self._set_attr_from_config_option(cp, *option_spec) if was_set: any_set = True + print(f"{any_set=} because {option_spec=}") except ValueError as err: raise ConfigError(f"Couldn't read config file {filename}: {err}") from err @@ -332,20 +336,24 @@ def from_file(self, filename: str, warn: Callable[[str], None], our_file: bool) for option in cp.options('paths'): self.paths[option] = cp.getlist('paths', option) any_set = True + print(f"{any_set=} because paths:{option}") # plugins can have options for plugin in self.plugins: if cp.has_section(plugin): self.plugin_options[plugin] = cp.get_section(plugin) any_set = True + print(f"{any_set=} because {plugin=}:{option}") # Was this file used as a config file? If it's specifically our file, # then it was used. If we're piggybacking on someone else's file, # then it was only used if we found some settings in it. + print(f"{our_file=}") if our_file: used = True else: used = any_set + print(f"{used=}") if used: self.config_file = os.path.abspath(filename) @@ -591,7 +599,9 @@ def read_coverage_config( files_to_try = config_files_to_try(config_file) for fname, our_file, specified_file in files_to_try: + print(f"Reading {fname=}") config_read = config.from_file(fname, warn, our_file=our_file) + print(f"{config_read=}") if config_read: break if specified_file: diff --git a/coverage/tomlconfig.py b/coverage/tomlconfig.py index a7d390420..891d9c420 100644 --- a/coverage/tomlconfig.py +++ b/coverage/tomlconfig.py @@ -43,12 +43,15 @@ def read(self, filenames): try: with open(filename, encoding='utf-8') as fp: toml_text = fp.read() - except OSError: + except OSError as err: + print(f"OSError {err=}") return [] + print(f"{tomllib=}") if tomllib is not None: try: self.data = tomllib.loads(toml_text) except tomllib.TOMLDecodeError as err: + print(f"TomlDecodeError {err=}") raise TomlDecodeError(str(err)) from err return [filename] else: