{"library":"griffelib","title":"Griffelib","description":"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.","status":"active","version":"2.0.2","language":"en","source_language":"en","source_url":"https://github.com/mkdocstrings/griffe","tags":["documentation","api-generation","code-analysis","static-analysis","signatures"],"install":[{"cmd":"pip install griffelib","lang":"bash","label":"Pip installation"}],"dependencies":[],"imports":[{"note":"While 'griffe.load' is a common pattern in the main 'griffe' package, the core loading mechanism is typically accessed via `GriffeLoader` within 'griffelib' (which is part of the `griffe` package structure).","wrong":"import griffelib.load","symbol":"load","correct":"from griffe.loader import GriffeLoader; loader = GriffeLoader(); module = loader.load_module(\"your_module\")"},{"note":"Data structures like Module, Class, Function, etc., are found in `griffe.dataclasses`.","symbol":"Module","correct":"from griffe.dataclasses import Module"}],"quickstart":{"code":"import os\nfrom griffe.loader import GriffeLoader\nfrom griffe.dataclasses import Module, Class, Function\nfrom pathlib import Path\n\n# Create a dummy Python module for demonstration\ndummy_module_code = \"\"\"\ndef my_function(param1: str, param2: int) -> bool:\n    \"\"\"A sample function.\"\"\"\n    return len(param1) == param2\n\nclass MyClass:\n    \"\"\"A sample class.\"\"\"\n    def __init__(self, name: str):\n        self.name = name\n\n    def get_name(self) -> str:\n        \"\"\"Returns the name.\"\"\"\n        return self.name\n\"\"\"\n\n# Create a temporary directory and file for the dummy module\n# In a real scenario, you would load an existing module\ntmp_dir = Path(\"./_griffelib_temp_module\")\ntmp_dir.mkdir(exist_ok=True)\ndummy_file = tmp_dir / \"dummy_example.py\"\ndummy_file.write_text(dummy_module_code)\n\n# Initialize the Griffe loader and load the module\nloader = GriffeLoader()\nloaded_module: Module = loader.load_module(\"dummy_example\", search_paths=[tmp_dir])\n\nprint(f\"Module name: {loaded_module.name}\")\n\n# Iterate through members (functions, classes)\nfor member in loaded_module.members.values():\n    if isinstance(member, Function):\n        print(f\"  Function: {member.name}\")\n        print(f\"    Signature: {member.signature}\")\n        print(f\"    Docstring: {member.docstring.value if member.docstring else 'N/A'}\")\n    elif isinstance(member, Class):\n        print(f\"  Class: {member.name}\")\n        print(f\"    Docstring: {member.docstring.value if member.docstring else 'N/A'}\")\n        for method in member.members.values():\n            if isinstance(method, Function):\n                print(f\"      Method: {method.name}\")\n                print(f\"        Signature: {method.signature}\")\n\n# Clean up temporary directory (optional)\nimport shutil\nshutil.rmtree(tmp_dir)\n","lang":"python","description":"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."},"warnings":[{"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.","message":"Griffe 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.","severity":"breaking","affected_versions":">=2.0.0"},{"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 ...`.","message":"Users 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"The 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.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-05T00:00:00.000Z","next_check":"2026-07-04T00:00:00.000Z"}