diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2023-01-12 10:47:08 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2023-01-12 10:47:08 -0500 |
commit | a15b90268f37d5f3a06b28ecb9277e636b493b1d (patch) | |
tree | 04fa3e38f18bb1489abd2004abca81b23eb5e3ac /coverage | |
parent | 460dd98dae56d26f0611a0f6dc9c24e44435958f (diff) | |
download | python-coveragepy-git-a15b90268f37d5f3a06b28ecb9277e636b493b1d.tar.gz |
mypy: progress on test_plugins.py
Diffstat (limited to 'coverage')
-rw-r--r-- | coverage/config.py | 5 | ||||
-rw-r--r-- | coverage/plugin_support.py | 7 | ||||
-rw-r--r-- | coverage/types.py | 7 |
3 files changed, 14 insertions, 5 deletions
diff --git a/coverage/config.py b/coverage/config.py index ee30b8a4..046c1b00 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -20,7 +20,8 @@ from coverage.exceptions import ConfigError from coverage.misc import isolate_module, human_sorted_items, substitute_variables from coverage.tomlconfig import TomlConfigParser, TomlDecodeError from coverage.types import ( - TConfigurable, TConfigSectionIn, TConfigValueIn, TConfigSectionOut, TConfigValueOut, + TConfigurable, TConfigSectionIn, TConfigValueIn, TConfigSectionOut, + TConfigValueOut, TPluginConfig, ) os = isolate_module(os) @@ -166,7 +167,7 @@ DEFAULT_PARTIAL_ALWAYS = [ ] -class CoverageConfig(TConfigurable): +class CoverageConfig(TConfigurable, TPluginConfig): """Coverage.py configuration. The attributes of this class are the various settings that control the diff --git a/coverage/plugin_support.py b/coverage/plugin_support.py index 62985a06..4ed02c5c 100644 --- a/coverage/plugin_support.py +++ b/coverage/plugin_support.py @@ -12,11 +12,12 @@ import sys from types import FrameType from typing import Any, Dict, Iterable, Iterator, List, Optional, Set, Tuple, Union -from coverage.config import CoverageConfig from coverage.exceptions import PluginError from coverage.misc import isolate_module from coverage.plugin import CoveragePlugin, FileTracer, FileReporter -from coverage.types import TArc, TConfigurable, TDebugCtl, TLineNo, TSourceTokenLines +from coverage.types import ( + TArc, TConfigurable, TDebugCtl, TLineNo, TPluginConfig, TSourceTokenLines, +) os = isolate_module(os) @@ -38,7 +39,7 @@ class Plugins: def load_plugins( cls, modules: Iterable[str], - config: CoverageConfig, + config: TPluginConfig, debug: Optional[TDebugCtl] = None, ) -> Plugins: """Load plugins from `modules`. diff --git a/coverage/types.py b/coverage/types.py index 736269e0..3d21ac9d 100644 --- a/coverage/types.py +++ b/coverage/types.py @@ -136,6 +136,13 @@ class TConfigurable(Protocol): """ +class TPluginConfig(Protocol): + """Something that can provide options to a plugin.""" + + def get_plugin_options(self, plugin: str) -> TConfigSectionOut: + """Get the options for a plugin.""" + + ## Parsing TMorf = Union[ModuleType, str] |