Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Loader docs #3352

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog/3352.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update Loader docs - by :user:ziima
3 changes: 3 additions & 0 deletions docs/plugins_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ config
.. autoclass:: tox.config.loader.api.Loader
:members:

.. autoclass:: tox.config.loader.memory.MemoryLoader
:members:

.. autoclass:: tox.config.loader.convert.Convert
:members:

Expand Down
6 changes: 5 additions & 1 deletion src/tox/config/loader/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ def copy(self) -> ConfigLoadArgs:


class Loader(Convert[T]):
"""Loader loads a configuration value and converts it."""
"""Loader loads configuration values and converts it.

:param overrides: A list of overrides to be applied.
"""

def __init__(self, section: Section, overrides: list[Override]) -> None:
self._section = section
Expand All @@ -88,6 +91,7 @@ def __init__(self, section: Section, overrides: list[Override]) -> None:

@property
def section(self) -> Section:
"""Return the section of the configuration from where the values are extracted."""
return self._section

@abstractmethod
Expand Down
2 changes: 2 additions & 0 deletions src/tox/config/loader/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@


class MemoryLoader(Loader[Any]):
"""Loads configuration directly from data in memory."""

def __init__(self, **kwargs: Any) -> None:
super().__init__(Section(prefix="<memory>", name=str(id(self))), [])
self.raw: dict[str, Any] = {**kwargs}
Expand Down