Skip to content

Commit

Permalink
feat: add the sghi.registry module (#12)
Browse files Browse the repository at this point in the history
Add the `sghi.registry` module which defines the `Registry` interface, implementing classes and helpers.

A `Registry` allows for storage and retrieval of values using unique keys. It supports basic dictionary-like operations and provides an interface for interacting with registered items.
  • Loading branch information
kennedykori committed Oct 16, 2023
1 parent b617c57 commit f2d51bf
Show file tree
Hide file tree
Showing 7 changed files with 989 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
("py:class", "_P"), # type annotation only available when type checking
("py:class", "_RT"), # type annotation only available when type checking
("py:class", "Chain[Any]"), # Used as type annotation. Only available when type checking
("py:class", "Signal"), # Used as type annotation. Only available when type checking
("py:class", "TracebackType"), # Used as type annotation. Only available when type checking
("py:class", "concurrent.futures._base.Executor"), # sphinx can't find it
("py:class", "concurrent.futures._base.Future"), # sphinx can't find it
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ API Reference
sghi.dispatch
sghi.disposable
sghi.exceptions
sghi.registry
sghi.task
sghi.typing
sghi.utils
Expand Down
15 changes: 15 additions & 0 deletions src/sghi/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from .config import Config, SettingInitializer
from .dispatch import Dispatcher
from .registry import Registry

# =============================================================================
# GLOBAL APPLICATION/TOOL CONSTANTS
Expand All @@ -37,6 +38,20 @@
"""


registry: Final[Registry] = Registry.of_proxy()
"""The main application :class:`registry<sghi.registry.Registry>`.
.. admonition:: Note: To application authors
:class: note
This value is set to an instance of :class:`sghi.registry.RegistryProxy`-
enabling the default wrapped instance to be replaced with a more
appropriate value during application setup.
"""


conf: Final[Config] = Config.of_proxy()
"""The application configurations.
Expand Down
4 changes: 2 additions & 2 deletions src/sghi/dispatch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def of_proxy(
Create a :class:`DispatcherProxy` instance that wraps the given
``Dispatcher`` instance.
If `source_dispatcher` is not given, it defaults to a value with
If ``source_dispatcher`` is not given, it defaults to a value with
similar semantics to those returned by the :meth:`Dispatcher.of`
factory method.
Expand Down Expand Up @@ -269,7 +269,7 @@ def __init__(self, source_dispatcher: Dispatcher) -> None:
given source ``Dispatcher`` instance.
:param source_dispatcher: The ``Dispatcher`` instance to wrap. This
MUST be an instance ``Dispatcher``.
MUST be an instance of ``Dispatcher``.
:raise TypeError: If ``source_dispatcher`` is not an instance of
``Dispatcher``.
Expand Down
Loading

0 comments on commit f2d51bf

Please sign in to comment.