diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-08-05 05:19:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-05 05:19:54 -0700 |
commit | 602e2106edfe437adf56bced4da2e09eb32ca765 (patch) | |
tree | 17ae7ebe1f7b8f61032aa69fce11a8111463fb4e /coverage/config.py | |
parent | 57a691f15dc8296f91ec1e321d3ed53e165a1f10 (diff) | |
download | python-coveragepy-git-602e2106edfe437adf56bced4da2e09eb32ca765.tar.gz |
feat: unrecognized options are now a warning rather than error. #1035 (#1206)
Because they are warnings issued while parsing the configuration file, it's not
possible to suppress them with the coverage configuration.
Diffstat (limited to 'coverage/config.py')
-rw-r--r-- | coverage/config.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/coverage/config.py b/coverage/config.py index 7287e963..3b873579 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -248,7 +248,7 @@ class CoverageConfig: setattr(self, k, v) @contract(filename=str) - def from_file(self, filename, our_file): + def from_file(self, filename, warn, our_file): """Read configuration from a .rc file. `filename` is a file name to read. @@ -297,7 +297,7 @@ class CoverageConfig: real_section = cp.has_section(section) if real_section: for unknown in set(cp.options(section)) - options: - raise CoverageException( + warn( "Unrecognized option '[{}] {}=' in config file {}".format( real_section, unknown, filename ) @@ -517,12 +517,13 @@ def config_files_to_try(config_file): return files_to_try -def read_coverage_config(config_file, **kwargs): +def read_coverage_config(config_file, warn, **kwargs): """Read the coverage.py configuration. Arguments: config_file: a boolean or string, see the `Coverage` class for the tricky details. + warn: a function to issue warnings. all others: keyword arguments from the `Coverage` class, used for setting values in the configuration. @@ -541,7 +542,7 @@ def read_coverage_config(config_file, **kwargs): files_to_try = config_files_to_try(config_file) for fname, our_file, specified_file in files_to_try: - config_read = config.from_file(fname, our_file=our_file) + config_read = config.from_file(fname, warn, our_file=our_file) if config_read: break if specified_file: |