Registry / serialization / griffelib

griffelib

JSON →
library2.2.0pypypi✓ verified 24d ago

Griffelib, pronounced "grif" (/ɡʁif/), is a Python library that provides core components for extracting signatures (structure, frame, skeleton) of entire Python programs. It is a fundamental part of the larger 'Griffe' project, which is used for generating API documentation (e.g., by mkdocstrings) and detecting breaking changes in an API. The library is currently at version 2.0.2 and follows a regular release cadence as part of the Griffe ecosystem.

pip install griffelib
INSTALL
IMPORT
SIG · GRIFFELIB
G
griffelib
serializationpythonv2.2.0
Install
1.6s avg
Import
Disk
17MB
Pass rate
8/ 10
Env Coverage8 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 1.5s
py 3.11
✓ —
✓ 1.7s
py 3.12
✓ —
✓ 1.5s
py 3.13
✓ —
✓ 1.6s
py 3.9
✕ build_error
✕ build_error
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GriffeLoader
from griffe.loader import GriffeLoader
from griffe.loader import GriffeLoader

This quickstart demonstrates how to use `griffelib` (specifically, components from the `griffe` package) to load a Python module from a file path, access its members, and extract signature and docstring information. It involves creating a dummy module, loading it with `GriffeLoader`, and then navigating the resulting `Module` object to inspect its contents.

import os from griffe.loader import GriffeLoader from griffe.dataclasses import Module, Class, Function from pathlib import Path # Create a dummy Python module for demonstration dummy_module_code = """ def my_function(param1: str, param2: int) -> bool: """A sample function.""" return len(param1) == param2 class MyClass: """A sample class.""" def __init__(self, name: str): self.name = name def get_name(self) -> str: """Returns the name.""" return self.name """ # Create a temporary directory and file for the dummy module # In a real scenario, you would load an existing module tmp_dir = Path("./_griffelib_temp_module") tmp_dir.mkdir(exist_ok=True) dummy_file = tmp_dir / "dummy_example.py" dummy_file.write_text(dummy_module_code) # Initialize the Griffe loader and load the module loader = GriffeLoader() loaded_module: Module = loader.load_module("dummy_example", search_paths=[tmp_dir]) print(f"Module name: {loaded_module.name}") # Iterate through members (functions, classes) for member in loaded_module.members.values(): if isinstance(member, Function): print(f" Function: {member.name}") print(f" Signature: {member.signature}") print(f" Docstring: {member.docstring.value if member.docstring else 'N/A'}") elif isinstance(member, Class): print(f" Class: {member.name}") print(f" Docstring: {member.docstring.value if member.docstring else 'N/A'}") for method in member.members.values(): if isinstance(method, Function): print(f" Method: {method.name}") print(f" Signature: {method.signature}") # Clean up temporary directory (optional) import shutil shutil.rmtree(tmp_dir)
Debug
Known issues
breakingGriffe 2.0.0 (and thus griffelib components) introduced significant breaking changes. Key changes include refactoring of internal APIs, changes in data structures for representing code objects, and modifications to the loading and inspection processes. Direct usage of internal APIs from Griffe 1.x will likely fail.
fix
Refer to the official Griffe documentation's changelog for version 2.0.0 and above. Update code to use the new `griffe.loader` module for loading and `griffe.dataclasses` for accessing code object representations.
affects: >=2.0.0
gotchaUsers might confuse `griffelib` with the main `griffe` package. `griffelib` specifically refers to the library components, meaning programmatic access to the core functionalities, while `griffe` might include command-line tools and higher-level integrations. Import paths might differ slightly, as `griffelib`'s core is often exposed through `griffe.*` imports.
fix
Always check the specific import paths in the official 'Griffe' documentation (https://mkdocstrings.github.io/griffe/) for the functionality you intend to use. For core data structures and loading, generally use `from griffe.dataclasses import ...` and `from griffe.loader import ...`.
affects: All versions
breakingThe separation into `griffe`, `griffecli`, and `griffelib` as an 'uv workspace' means that some functionalities previously bundled might now be in different packages or accessed differently. Tools depending on `griffe` directly might need to explicitly depend on `griffelib` for certain library-only features.
fix
If you were previously using `griffe` as a dependency for library features, explicitly install `griffelib` and update your imports. Check the `griffe` GitHub repository for the exact commit that split the workspace to understand the implications for your specific use case.
affects: >=2.0.0
breakingVersions of `griffelib` 2.0.0 and above require Python 3.10 or newer. Attempting to install these versions on older Python interpreters (e.g., Python 3.9) will result in a 'No matching distribution found' error.
fix
Ensure your Python environment is version 3.10 or higher when installing `griffelib` versions 2.0.0 and above. If your project must remain on an older Python version, you will need to find a compatible older version of `griffelib` or `griffe` that supports your Python version, if one exists.
affects: >=2.0.0
gotchaThe test failed with `SyntaxError: invalid syntax` pointing to the start of a function's docstring. This error indicates a fundamental issue with the Python test script's syntax, likely an incomplete or malformed statement on a preceding line, rather than a problem with the `griffelib` library's API, package structure, or version compatibility. This error is highly unusual for a standard Python docstring in a Python 3.13 environment.
fix
Inspect the `script.py` file, particularly the lines immediately preceding the docstring on line 9, for any missing colons, parentheses, or other syntax errors that would cause the interpreter to flag the subsequent docstring as invalid syntax. Ensure the test script is valid Python for the target environment. This `SyntaxError` is unlikely to be directly caused by `griffelib`.
affects: All versions
Upgrade
Version history
2.2.0latest on PyPI · released Aug 16, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
31 hits · last 30 days
node
30
Resources
griffelib — pip install griffelib · libregistry