Links
AI / Agents
gdtest-namespace-src
Tests namespace package discovery with src/ layout and dotted module name.
Namespace package using src/ layout with dotted module name (nspkg.core). Code lives at src/nspkg/core/init.py and the great-docs.yml sets module: nspkg.core. Tests discovery of namespace packages in src/ layout via griffe search_paths and dotted path resolution in _find_package_init.
Source files
src/
nspkg/
core/
__init__.py
"""Core sub-package of the nspkg namespace."""
__version__ = "0.1.0"
__all__ = ["Config", "connect", "disconnect"]
class Config:
"""
Configuration holder for connections.
Parameters
----------
host
Server hostname.
port
Port number.
Examples
--------
>>> cfg = Config("localhost", 5432)
>>> cfg.host
'localhost'
"""
def __init__(self, host: str, port: int = 5432):
self.host = host
self.port = port
def as_dict(self) -> dict:
"""
Return configuration as a dictionary.
Returns
-------
dict
Keys are ``host`` and ``port``.
"""
return {"host": self.host, "port": self.port}
def validate(self) -> bool:
"""
Validate the configuration.
Returns
-------
bool
True if the configuration is valid.
Raises
------
ValueError
If the host is empty or port is out of range.
"""
if not self.host:
raise ValueError("Host cannot be empty")
if not (1 <= self.port <= 65535):
raise ValueError("Port must be between 1 and 65535")
return True
def connect(config: Config) -> str:
"""
Establish a connection using the given config.
Parameters
----------
config
The connection configuration.
Returns
-------
str
Connection URI string.
"""
return f"{config.host}:{config.port}"
def disconnect(connection: str) -> bool:
"""
Close an active connection.
Parameters
----------
connection
The connection string to close.
Returns
-------
bool
True if disconnection succeeded.
"""
return True__init__.py
"""Namespace top-level package."""
README.md
# gdtest-namespace-src Tests namespace package discovery with src/ layout and dotted module name.
great-docs.yml
module: nspkg.core