Skip to content
Open
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
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ module = [
]
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = ["sphinx_needs.data"]
disable_error_code = ["attr-defined", "no-any-return"]

[tool.tox]
# To use tox, see https://tox.readthedocs.io
# $ pipx install tox
Expand Down
26 changes: 25 additions & 1 deletion sphinx_needs/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Literal,
NewType,
TypedDict,
cast,
)

from sphinx.util.logging import getLogger
Expand All @@ -37,6 +38,29 @@
from sphinx_needs.schema.config import SchemasRootType
from sphinx_needs.services.manager import ServiceManager

class _NeedsApp(Sphinx):
"""Sphinx application, annotated with the private attributes sphinx-needs stores on it."""

_needs_services: ServiceManager

class _NeedsEnv(BuildEnvironment):
"""Build environment, annotated with the private attributes sphinx-needs stores on it.

These are accessed lazily via :class:`SphinxNeedsData`; declaring them here
keeps that access type-checked, instead of suppressing ``attr-defined``.
"""

app: _NeedsApp
_needs_schema: FieldsSchema
_needs_resolved_schemas: list[SchemasRootType]
_needs_all_needs: dict[str, NeedItem]
_needs_view: NeedsView
_needs_all_docs: dict[str, list[str]]
_needs_is_post_processed: bool
_need_all_needextend: dict[str, NeedsExtendType]
_needs_all_needumls: dict[str, NeedsUmlType]
_needs_all_nodes: dict[str, Need]


LOGGER = getLogger(__name__)

Expand Down Expand Up @@ -772,7 +796,7 @@ class SphinxNeedsData:
"""Centralised access to sphinx-needs data, stored within the Sphinx environment."""

def __init__(self, env: BuildEnvironment) -> None:
self.env = env
self.env = cast("_NeedsEnv", env)

def get_schema(self) -> FieldsSchema:
"""Get the schema for all fields.
Expand Down
Loading