Describe the bug
In griffe/__init__.py, the test-related helpers from griffe._internal.tests (such as temporary_pypackage, temporary_pyfile, etc.) are imported unconditionally at the top level:
https://github.com/mkdocstrings/griffe/blob/main/src/griffe/__init__.py (around line 361)
from griffe._internal.tests import (
TmpPackage,
htree,
module_vtree,
temporary_inspected_module,
temporary_inspected_package,
temporary_pyfile,
temporary_pypackage,
temporary_visited_module,
temporary_visited_package,
vtree,
)
While these helpers are useful for users writing test suites for their extensions, unconditionally importing them in the package's top-level entrypoint creates a hard runtime dependency on griffe._internal.tests.
When downstream developers compile or package their applications using tools like Nuitka, PyInstaller, or PyStand, they typically configure these tools to exclude test suites (e.g., using --nofollow-import-to=*.tests or excluding subpackages matching tests) to keep the bundle size small.
Because of this unconditional import, any attempt to load griffe (or frameworks that depend on it, like pydantic_ai) in the compiled environment fails immediately with:
ModuleNotFoundError: No module named 'griffe._internal.tests'
To Reproduce
Create a script app.py that imports griffe:
import griffe
print("Loaded!")
Compile it using Nuitka with tests excluded:
nuitka --standalone --nofollow-import-to=*.tests app.py
Run the compiled executable, and it crashes with ModuleNotFoundError: No module named 'griffe._internal.tests'.
Expected behavior
griffe should be importable without requiring the test utilities package to be present. The core library should not have a hard runtime import dependency on its own test helpers in init.py.
Describe the bug
In
griffe/__init__.py, the test-related helpers fromgriffe._internal.tests(such astemporary_pypackage,temporary_pyfile, etc.) are imported unconditionally at the top level:https://github.com/mkdocstrings/griffe/blob/main/src/griffe/__init__.py (around line 361)
While these helpers are useful for users writing test suites for their extensions, unconditionally importing them in the package's top-level entrypoint creates a hard runtime dependency on griffe._internal.tests.
When downstream developers compile or package their applications using tools like Nuitka, PyInstaller, or PyStand, they typically configure these tools to exclude test suites (e.g., using --nofollow-import-to=*.tests or excluding subpackages matching tests) to keep the bundle size small.
Because of this unconditional import, any attempt to load griffe (or frameworks that depend on it, like pydantic_ai) in the compiled environment fails immediately with:
ModuleNotFoundError: No module named 'griffe._internal.tests'
To Reproduce
Create a script app.py that imports griffe:
Compile it using Nuitka with tests excluded:
nuitka --standalone --nofollow-import-to=*.tests app.pyRun the compiled executable, and it crashes with ModuleNotFoundError: No module named 'griffe._internal.tests'.
Expected behavior
griffe should be importable without requiring the test utilities package to be present. The core library should not have a hard runtime import dependency on its own test helpers in init.py.