rename internal ConfigContainer class to ConfigContainerInternal
keeps the `qutebrowser.config.config.ConfigContainer` import around by adding it as an alias to `qutebrowser.config.configcontainer_types.ConfigContainer`
This commit is contained in:
parent
2dfaabf39d
commit
890adf3a65
|
|
@ -27,7 +27,7 @@ if TYPE_CHECKING:
|
|||
|
||||
|
||||
# An easy way to access the config from other code via config.val.foo
|
||||
val = cast('ConfigContainer', None)
|
||||
val = cast('ConfigContainerInternal', None)
|
||||
instance = cast('Config', None)
|
||||
key_instance = cast('KeyConfig', None)
|
||||
cache = cast('configcache.ConfigCache', None)
|
||||
|
|
@ -568,7 +568,7 @@ class Config(QObject):
|
|||
return '\n'.join(lines)
|
||||
|
||||
|
||||
class ConfigContainer:
|
||||
class ConfigContainerInternal:
|
||||
|
||||
"""An object implementing config access via __getattr__.
|
||||
|
||||
|
|
@ -606,9 +606,9 @@ class ConfigContainer:
|
|||
text = f"While {action}"
|
||||
self._configapi.errors.append(configexc.ConfigErrorDesc(text, e))
|
||||
|
||||
def _with_prefix(self, prefix: str) -> 'ConfigContainer':
|
||||
def _with_prefix(self, prefix: str) -> 'ConfigContainerInternal':
|
||||
"""Get a new ConfigContainer for the given prefix."""
|
||||
return ConfigContainer(
|
||||
return ConfigContainerInternal(
|
||||
config=self._config,
|
||||
configapi=self._configapi,
|
||||
pattern=self._pattern,
|
||||
|
|
|
|||
|
|
@ -789,12 +789,12 @@ class ConfigAPI:
|
|||
self.errors += e.errors
|
||||
|
||||
@contextlib.contextmanager
|
||||
def pattern(self, pattern: str) -> Iterator[config.ConfigContainer]:
|
||||
def pattern(self, pattern: str) -> Iterator[config.ConfigContainerInternal]:
|
||||
"""Get a ConfigContainer for the given pattern."""
|
||||
# We need to propagate the exception so we don't need to return
|
||||
# something.
|
||||
urlpattern = urlmatch.UrlPattern(pattern)
|
||||
container = config.ConfigContainer(config=self._config, configapi=self,
|
||||
container = config.ConfigContainerInternal(config=self._config, configapi=self,
|
||||
pattern=urlpattern)
|
||||
yield container
|
||||
|
||||
|
|
@ -955,7 +955,7 @@ def read_config_py(
|
|||
warn_autoconfig=warn_autoconfig,
|
||||
)
|
||||
|
||||
container = config.ConfigContainer(config.instance, configapi=api)
|
||||
container = config.ConfigContainerInternal(config.instance, configapi=api)
|
||||
basename = os.path.basename(filename)
|
||||
|
||||
# used for `from qutebrowser.api.configpy import c, config`
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ def early_init(args: argparse.Namespace) -> None:
|
|||
yaml_config = configfiles.YamlConfig()
|
||||
|
||||
config.instance = config.Config(yaml_config=yaml_config)
|
||||
config.val = config.ConfigContainer(config.instance)
|
||||
configapi.val = config.ConfigContainer(config.instance)
|
||||
config.val = config.ConfigContainerInternal(config.instance)
|
||||
configapi.val = config.ConfigContainerInternal(config.instance)
|
||||
config.key_instance = config.KeyConfig(config.instance)
|
||||
config.cache = configcache.ConfigCache()
|
||||
yaml_config.setParent(config.instance)
|
||||
|
|
|
|||
|
|
@ -363,7 +363,7 @@ def change_console_formatter(level: int) -> None:
|
|||
assert isinstance(old_formatter, JSONFormatter), old_formatter
|
||||
|
||||
|
||||
def init_from_config(conf: 'configmodule.ConfigContainer') -> None:
|
||||
def init_from_config(conf: 'configmodule.ConfigContainerInternal') -> None:
|
||||
"""Initialize logging settings from the config.
|
||||
|
||||
init_log is called before the config module is initialized, so config-based
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ def config_stub(stubs, monkeypatch, configdata_init, yaml_config_stub, qapp):
|
|||
conf = config.Config(yaml_config=yaml_config_stub)
|
||||
monkeypatch.setattr(config, 'instance', conf)
|
||||
|
||||
container = config.ConfigContainer(conf)
|
||||
container = config.ConfigContainerInternal(conf)
|
||||
monkeypatch.setattr(config, 'val', container)
|
||||
monkeypatch.setattr(configapi, 'val', container)
|
||||
|
||||
|
|
|
|||
|
|
@ -751,7 +751,7 @@ class TestContainer:
|
|||
|
||||
@pytest.fixture
|
||||
def container(self, config_stub):
|
||||
return config.ConfigContainer(config_stub)
|
||||
return config.ConfigContainerInternal(config_stub)
|
||||
|
||||
def test_getattr_invalid_private(self, container):
|
||||
"""Make sure an invalid _attribute doesn't try getting a container."""
|
||||
|
|
@ -813,4 +813,4 @@ class TestContainer:
|
|||
pattern = urlmatch.UrlPattern('https://example.com/')
|
||||
with pytest.raises(TypeError,
|
||||
match="Can't use pattern without configapi!"):
|
||||
config.ConfigContainer(config_stub, pattern=pattern)
|
||||
config.ConfigContainerInternal(config_stub, pattern=pattern)
|
||||
|
|
|
|||
Loading…
Reference in New Issue