Skip to content

Project architecture¤

For contributors and maintainers

This page explains the repository layout and Griffe's implementation. To use the public API, see the user guide and API reference.

This page covers repository tooling, source code, tests, and the relationship between the public and internal APIs.

Repository layout¤

.git/
.github/ # (1)!
.venv/ # (2)!
.venvs/ # (3)!
.vscode/ # (4)!
.zed/ # (5)!
config/ # (6)!
docs/ # (7)!
htmlcov/ # (8)!
packages/ # (9)!
scripts/ # (10)!
site/ # (11)!
.copier-answers.yml # (12)!
.envrc # (13)!
.gitignore
AI_POLICY.md
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
Makefile # (14)!
README.md
duties.py # (15)!
logo.svg
pyproject.toml # (16)!
uv.lock
zensical.toml # (17)!
  1. GitHub workflows, issue templates and other configuration.

    ISSUE_TEMPLATE/ # (1)!
    workflows/ # (2)!
    FUNDING.yml
    pull_request_template.md
    
    1. 1-bug.md
      2-feature.md
      3-docs.md
      4-change.md
      config.yml
      
    2. ci.yml
      release.yml
      security.yml
      sponsors.yml
      
  2. The default virtual environment (git-ignored). See make setup command.

  3. The virtual environments for all supported Python versions (git-ignored). See make setup command.

  4. The configuration for VSCode (git-ignored). See make vscode command.

    configurationCache.log
    dryrun.log
    launch.json
    settings.json
    targets.log
    tasks.json
    
  5. debug.json
    settings.json
    tasks.json
    
  6. Contains our tooling configuration. See Scripts, configuration.

    vscode/ # (1)!
    zed/ # (2)!
    coverage.ini
    git-changelog.toml
    pytest.ini
    ruff.toml
    ty.toml
    
    1. launch.json
      settings.json
      tasks.json
      
    2. debug.json
      settings.json
      tasks.json
      
  7. Documentation sources (Markdown pages). See make docs task.

    .overrides/ # (1)!
    community/ # (2)!
    css/ # (3)!
    extensions/ # (4)!
    getting-started/ # (5)!
    guide/ # (6)!
    img/ # (7)!
    js/ # (8)!
    reference/ # (9)!
    alternatives.md
    changelog.md
    code-of-conduct.md
    contributing.md
    credits.md
    downstream-projects.md
    getting-help.md
    griffe.json
    index.md
    installation.md
    introduction.md
    license.md
    logo.svg
    playground.md
    schema-docstrings-options.json
    schema.json
    
    1. Customization of Zensical templates.

      partials/ # (1)!
      main.html
      
      1. comments.html
        
    2. index.md
      
    3. ansi.css
      apidocs.css
      custom.css
      pyodide.css
      
    4. built-in/ # (1)!
      official/ # (2)!
      third-party/ # (3)!
      index.md
      
      1. dataclasses.md
        index.md
        unpack-typeddict.md
        
      2. autodocstringstyle.md
        index.md
        inherited-docstrings.md
        public-redundant-aliases.md
        public-wildcard-imports.md
        pydantic.md
        runtime-objects.md
        sphinx.md
        typingdoc.md
        warnings-deprecated.md
        
      3. docstring-inheritance.md
        fastapi.md
        fieldz.md
        generics.md
        index.md
        inherited-method-crossrefs.md
        modernized-annotations.md
        
    5. index.md
      
    6. contributors/ # (1)!
      users/ # (2)!
      index.md
      
      1. architecture.md
        commands.md
        index.md
        setup.md
        workflow.md
        
      2. how-to/ # (1)!
        recommendations/ # (2)!
        checking.md
        extending.md
        index.md
        loading.md
        navigating.md
        serializing.md
        
        1. parse-docstrings.md
          selectively-inspect.md
          set-docstring-styles.md
          set-git-info.md
          support-decorators.md
          
        2. docstrings.md
          public-apis.md
          python-code.md
          
    7. favicon.ico
      gha_annotations_1.png
      gha_annotations_2.png
      
    8. feedback.js
      pyodide.js
      
    9. api/ # (1)!
      cli.md
      docstrings.md
      index.md
      
      1. Python API reference, injected with mkdocstrings.

        docstrings/ # (1)!
        models/ # (2)!
        agents.md
        checks.md
        cli.md
        exceptions.md
        expressions.md
        extensions.md
        finder.md
        helpers.md
        index.md
        loaders.md
        loggers.md
        serializers.md
        
        1. index.md
          models.md
          parsers.md
          
        2. alias.md
          attribute.md
          class.md
          function.md
          index.md
          module.md
          type_alias.md
          
  8. HTML report for Python code coverage (git-ignored). See make coverage task.

  9. The library and CLI workspace packages. See Sources and Program structure.

    griffecli/ # (1)!
    griffelib/ # (2)!
    
    1. The command-line interface package, including its sources and tests.

      src/ # (1)!
      tests/ # (2)!
      pyproject.toml
      
      1. griffecli/ # (1)!
        
        1. _internal/ # (1)!
          __init__.py
          __main__.py
          py.typed
          
          1. __init__.py
            cli.py
            
      2. Our test suite. See Tests.

        __init__.py
        test_cli.py
        
    2. The library package, including its sources and tests.

      src/ # (1)!
      tests/ # (2)!
      pyproject.toml
      
      1. griffe/ # (1)!
        
        1. Our public library API. See Program structure.

          _internal/ # (1)!
          __init__.py
          __main__.py
          py.typed
          
          1. Our internal API, hidden from users. See Program structure.

            agents/ # (1)!
            docstrings/ # (2)!
            extensions/ # (3)!
            __init__.py
            c3linear.py
            collections.py
            debug.py
            diff.py
            encoders.py
            enumerations.py
            exceptions.py
            expressions.py
            finder.py
            git.py
            helpers.py
            importer.py
            loader.py
            logger.py
            merger.py
            mixins.py
            models.py
            stats.py
            
            1. nodes/ # (1)!
              __init__.py
              inspector.py
              parser.py
              visitor.py
              
              1. __init__.py
                assignments.py
                ast.py
                docstrings.py
                exports.py
                imports.py
                parameters.py
                runtime.py
                values.py
                
            2. __init__.py
              auto.py
              google.py
              models.py
              numpy.py
              parsers.py
              sphinx.py
              utils.py
              
            3. __init__.py
              base.py
              dataclasses.py
              unpack_typeddict.py
              
      2. Our test suite. See Tests.

        fixtures/
        test_docstrings/ # (1)!
        test_extensions/ # (2)!
        __init__.py
        conftest.py
        helpers.py
        test_api.py
        test_diff.py
        test_encoders.py
        test_expressions.py
        test_finder.py
        test_functions.py
        test_git.py
        test_inheritance.py
        test_inspector.py
        test_loader.py
        test_merger.py
        test_mixins.py
        test_models.py
        test_nodes.py
        test_parser.py
        test_public_api.py
        test_stdlib.py
        test_visitor.py
        
        1. __init__.py
          conftest.py
          helpers.py
          test_auto.py
          test_google.py
          test_numpy.py
          test_sphinx.py
          test_warnings.py
          
        2. __init__.py
          test_base.py
          test_dataclasses.py
          test_unpack_typeddict.py
          
  10. Our different scripts. See Scripts, configuration.

    gen_credits.py
    gen_griffe_json.py
    gen_structure_docs.py
    get_version.py
    griffe_exts.py
    make
    make.py
    
  11. Documentation site, built with make check-docs (git-ignored).

  12. The answers file generated by Copier. See Boilerplate.

  13. The environment configuration, automatically sourced by direnv. See Management commands.

  14. A dummy makefile, only there for auto-completion. See Management commands.

  15. Our project tasks, written with duty. See Tasks.

  16. Project metadata, dependencies, development dependency groups, and workspace configuration.

  17. The build configuration for our docs. See make docs task.

Boilerplate¤

This project's skeleton (the file-tree shown above) is actually generated from a Copier template called copier-uv. When generating the project, Copier asks a series of questions (configured by the template itself), and the answers are used to render the file and directory names, as well as the file contents. Copier also records answers in the .copier-answers.yml file, allowing to update the project with latest changes from the template while reusing previous answers.

To update the project (in order to apply latest changes from the template), we use the following command:

copier update --trust --skip-answered

Scripts, configuration¤

We have a few scripts that let us manage the various maintenance aspects for this project. The entry-point is the make script located in the scripts folder. It doesn't need any dependency to be installed to run. See Management commands for more information.

The make script also invokes tasks defined in duties.py using the duty task runner. Tasks require development dependencies, listed in the dependency groups in pyproject.toml.

The tools used in tasks have their configuration files stored in the config folder, to unclutter the root of the repository. The tasks take care of calling the tools with the right options to locate their respective configuration files.

Sources¤

Sources are located in the packages/ subfolders, following the src-layout. We use Hatch to build source and wheel distributions, and configure it in pyproject.toml.

Tests¤

Tests are located in packages/griffelib/tests and packages/griffecli/tests, outside the source directories. They are included in source distributions, alongside metadata and configuration files. Each package's pyproject.toml lists the included files.

The test suite is based on pytest. Test modules reflect our internal API structure, and except for a few test modules that test specific aspects of our API, each test module tests the logic from the corresponding module in the internal API. For example, test_finder.py tests code of the griffe._internal.finder internal module, while test_functions tests our ability to extract correct information from function signatures, statically. The general rule of thumb when writing new tests is to mirror the internal API. If a test touches to many aspects of the loading process, it can be added to the test_loader test module.

Program structure¤

Griffe is split into two pieces: the library and the CLI.

Each of them has an internal API contained within an _internal folder:

  • packages/griffelib/src/griffe/_internal for the library,
  • packages/griffecli/src/griffecli/_internal for the CLI.

Griffe can be installed in library-only mode, which means that the CLI package from packages/griffecli is not present. Library-only mode can be preferred if the user does not utilize the CLI functionality of Griffe and does not want to incorporate its dependencies.

The top-level packages/griffelib/src/griffe/__init__.py module exposes all the public API available: it always re-exports internal objects from various submodules of griffe._internal and, if the CLI is installed, it re-exports the public API of griffecli as well.

Users then import griffe directly, or import objects from it. If they don't have griffecli installed, they cannot import the CLI-related functionality, such as griffecli.check.

We'll be honest: our code organization is not the most elegant, but it works 🤷 Have a look at the following module dependency graph, which will basically tell you nothing except that we have a lot of inter-module dependencies. Arrows read as "imports from". The code base is generally pleasant to work with though.

Ggriffegriffegriffe__internalgriffe._internalgriffe->griffe__internalgriffe__internal_agentsgriffe._internal.agentsgriffe->griffe__internal_agentsgriffe__internal_agents_inspectorgriffe._internal.agents.inspectorgriffe->griffe__internal_agents_inspectorgriffe__internal_agents_nodesgriffe._internal.agents.nodesgriffe->griffe__internal_agents_nodesgriffe__internal_agents_nodes_assignmentsgriffe._internal.agents.nodes.assignmentsgriffe->griffe__internal_agents_nodes_assignmentsgriffe__internal_agents_nodes_astgriffe._internal.agents.nodes.astgriffe->griffe__internal_agents_nodes_astgriffe__internal_agents_nodes_docstringsgriffe._internal.agents.nodes.docstringsgriffe->griffe__internal_agents_nodes_docstringsgriffe__internal_agents_nodes_exportsgriffe._internal.agents.nodes.exportsgriffe->griffe__internal_agents_nodes_exportsgriffe__internal_agents_nodes_importsgriffe._internal.agents.nodes.importsgriffe->griffe__internal_agents_nodes_importsgriffe__internal_agents_nodes_parametersgriffe._internal.agents.nodes.parametersgriffe->griffe__internal_agents_nodes_parametersgriffe__internal_agents_nodes_runtimegriffe._internal.agents.nodes.runtimegriffe->griffe__internal_agents_nodes_runtimegriffe__internal_agents_nodes_valuesgriffe._internal.agents.nodes.valuesgriffe->griffe__internal_agents_nodes_valuesgriffe__internal_agents_visitorgriffe._internal.agents.visitorgriffe->griffe__internal_agents_visitorgriffe__internal_c3lineargriffe._internal.c3lineargriffe->griffe__internal_c3lineargriffe__internal_collectionsgriffe._internal.collectionsgriffe->griffe__internal_collectionsgriffe__internal_diffgriffe._internal.diffgriffe->griffe__internal_diffgriffe__internal_docstringsgriffe._internal.docstringsgriffe->griffe__internal_docstringsgriffe__internal_docstrings_autogriffe._internal.docstrings.autogriffe->griffe__internal_docstrings_autogriffe__internal_docstrings_googlegriffe._internal.docstrings.googlegriffe->griffe__internal_docstrings_googlegriffe__internal_docstrings_modelsgriffe._internal.docstrings.modelsgriffe->griffe__internal_docstrings_modelsgriffe__internal_docstrings_numpygriffe._internal.docstrings.numpygriffe->griffe__internal_docstrings_numpygriffe__internal_docstrings_parsersgriffe._internal.docstrings.parsersgriffe->griffe__internal_docstrings_parsersgriffe__internal_docstrings_sphinxgriffe._internal.docstrings.sphinxgriffe->griffe__internal_docstrings_sphinxgriffe__internal_docstrings_utilsgriffe._internal.docstrings.utilsgriffe->griffe__internal_docstrings_utilsgriffe__internal_encodersgriffe._internal.encodersgriffe->griffe__internal_encodersgriffe__internal_enumerationsgriffe._internal.enumerationsgriffe->griffe__internal_enumerationsgriffe__internal_exceptionsgriffe._internal.exceptionsgriffe->griffe__internal_exceptionsgriffe__internal_expressionsgriffe._internal.expressionsgriffe->griffe__internal_expressionsgriffe__internal_extensionsgriffe._internal.extensionsgriffe->griffe__internal_extensionsgriffe__internal_extensions_basegriffe._internal.extensions.basegriffe->griffe__internal_extensions_basegriffe__internal_extensions_dataclassesgriffe._internal.extensions.dataclassesgriffe->griffe__internal_extensions_dataclassesgriffe__internal_extensions_unpack_typeddictgriffe._internal.extensions.unpack_typeddictgriffe->griffe__internal_extensions_unpack_typeddictgriffe__internal_findergriffe._internal.findergriffe->griffe__internal_findergriffe__internal_gitgriffe._internal.gitgriffe->griffe__internal_gitgriffe__internal_helpersgriffe._internal.helpersgriffe->griffe__internal_helpersgriffe__internal_importergriffe._internal.importergriffe->griffe__internal_importergriffe__internal_loadergriffe._internal.loadergriffe->griffe__internal_loadergriffe__internal_loggergriffe._internal.loggergriffe->griffe__internal_loggergriffe__internal_mergergriffe._internal.mergergriffe->griffe__internal_mergergriffe__internal_mixinsgriffe._internal.mixinsgriffe->griffe__internal_mixinsgriffe__internal_modelsgriffe._internal.modelsgriffe->griffe__internal_modelsgriffe__internal_statsgriffe._internal.statsgriffe->griffe__internal_statsgriffecligriffecligriffe->griffecligriffe___main__griffe.__main__griffe___main__->griffecligriffe__internal_agents_inspector->griffe__internal_agents_nodesgriffe__internal_agents_inspector->griffe__internal_agents_nodes_runtimegriffe__internal_agents_inspector->griffe__internal_collectionsgriffe__internal_agents_inspector->griffe__internal_docstringsgriffe__internal_agents_inspector->griffe__internal_docstrings_parsersgriffe__internal_agents_inspector->griffe__internal_enumerationsgriffe__internal_agents_inspector->griffe__internal_expressionsgriffe__internal_agents_inspector->griffe__internal_extensionsgriffe__internal_agents_inspector->griffe__internal_extensions_basegriffe__internal_agents_inspector->griffe__internal_importergriffe__internal_agents_inspector->griffe__internal_loggergriffe__internal_agents_inspector->griffe__internal_modelstyping_extensionstyping_extensionsgriffe__internal_agents_inspector->typing_extensionsgriffe__internal_agents_nodes_ast->griffe__internal_exceptionsgriffe__internal_agents_nodes_exports->griffe__internal_agents_nodes_valuesgriffe__internal_agents_nodes_exports->griffe__internal_enumerationsgriffe__internal_agents_nodes_exports->griffe__internal_expressionsgriffe__internal_agents_nodes_exports->griffe__internal_loggergriffe__internal_agents_nodes_exports->griffe__internal_modelsgriffe__internal_agents_nodes_imports->griffe__internal_modelsgriffe__internal_agents_nodes_parameters->griffe__internal_enumerationsgriffe__internal_agents_nodes_runtime->griffe__internal_enumerationsgriffe__internal_agents_nodes_runtime->griffe__internal_loggergriffe__internal_agents_nodes_runtime->typing_extensionsgriffe__internal_agents_nodes_values->griffe__internal_loggergriffe__internal_agents_parsergriffe._internal.agents.parsergriffe__internal_agents_parser->griffe__internal_extensionsgriffe__internal_agents_parser->griffe__internal_extensions_baseprune_sourceprune_sourcegriffe__internal_agents_parser->prune_sourcegriffe__internal_agents_visitor->griffe__internal_agents_nodesgriffe__internal_agents_visitor->griffe__internal_agents_nodes_assignmentsgriffe__internal_agents_visitor->griffe__internal_agents_nodes_astgriffe__internal_agents_visitor->griffe__internal_agents_nodes_docstringsgriffe__internal_agents_visitor->griffe__internal_agents_nodes_exportsgriffe__internal_agents_visitor->griffe__internal_agents_nodes_importsgriffe__internal_agents_visitor->griffe__internal_agents_nodes_parametersgriffe__internal_agents_visitor->griffe__internal_agents_parsergriffe__internal_agents_visitor->griffe__internal_collectionsgriffe__internal_agents_visitor->griffe__internal_docstringsgriffe__internal_agents_visitor->griffe__internal_docstrings_parsersgriffe__internal_agents_visitor->griffe__internal_enumerationsgriffe__internal_agents_visitor->griffe__internal_exceptionsgriffe__internal_agents_visitor->griffe__internal_expressionsgriffe__internal_agents_visitor->griffe__internal_extensionsgriffe__internal_agents_visitor->griffe__internal_modelsgriffe__internal_collections->griffe__internal_mixinsgriffe__internal_collections->griffe__internal_modelsgriffe__internal_diff->griffe__internal_enumerationsgriffe__internal_diff->griffe__internal_exceptionsgriffe__internal_diff->griffe__internal_gitgriffe__internal_diff->griffe__internal_loggergriffe__internal_diff->griffe__internal_modelsgriffe__internal_docstrings_auto->griffe__internal_docstrings_googlegriffe__internal_docstrings_auto->griffe__internal_docstrings_modelsgriffe__internal_docstrings_auto->griffe__internal_docstrings_numpygriffe__internal_docstrings_auto->griffe__internal_docstrings_sphinxgriffe__internal_docstrings_auto->griffe__internal_enumerationsgriffe__internal_docstrings_auto->griffe__internal_modelsgriffe__internal_docstrings_google->griffe__internal_docstrings_modelsgriffe__internal_docstrings_google->griffe__internal_docstrings_utilsgriffe__internal_docstrings_google->griffe__internal_enumerationsgriffe__internal_docstrings_google->griffe__internal_expressionsgriffe__internal_docstrings_google->griffe__internal_modelsgriffe__internal_docstrings_models->griffe__internal_enumerationsgriffe__internal_docstrings_models->griffe__internal_expressionsgriffe__internal_docstrings_numpy->griffe__internal_docstrings_modelsgriffe__internal_docstrings_numpy->griffe__internal_docstrings_utilsgriffe__internal_docstrings_numpy->griffe__internal_enumerationsgriffe__internal_docstrings_numpy->griffe__internal_expressionsgriffe__internal_docstrings_numpy->griffe__internal_modelsgriffe__internal_docstrings_parsers->griffe__internal_docstrings_autogriffe__internal_docstrings_parsers->griffe__internal_docstrings_googlegriffe__internal_docstrings_parsers->griffe__internal_docstrings_modelsgriffe__internal_docstrings_parsers->griffe__internal_docstrings_numpygriffe__internal_docstrings_parsers->griffe__internal_docstrings_sphinxgriffe__internal_docstrings_parsers->griffe__internal_enumerationsgriffe__internal_docstrings_sphinx->griffe__internal_docstrings_modelsgriffe__internal_docstrings_sphinx->griffe__internal_docstrings_utilsgriffe__internal_docstrings_sphinx->griffe__internal_expressionsgriffe__internal_docstrings_sphinx->griffe__internal_modelsgriffe__internal_docstrings_utils->griffe__internal_enumerationsgriffe__internal_docstrings_utils->griffe__internal_exceptionsgriffe__internal_docstrings_utils->griffe__internal_expressionsgriffe__internal_docstrings_utils->griffe__internal_loggergriffe__internal_docstrings_utils->griffe__internal_modelsgriffe__internal_encoders->griffe__internal_enumerationsgriffe__internal_encoders->griffe__internal_expressionsgriffe__internal_encoders->griffe__internal_gitgriffe__internal_encoders->griffe__internal_modelsgriffe__internal_exceptions->griffe__internal_modelsgriffe__internal_expressions->griffe__internal_agentsgriffe__internal_expressions->griffe__internal_agents_nodesgriffe__internal_expressions->griffe__internal_agents_nodes_parametersgriffe__internal_expressions->griffe__internal_enumerationsgriffe__internal_expressions->griffe__internal_exceptionsgriffe__internal_expressions->griffe__internal_loggergriffe__internal_expressions->griffe__internal_modelsgriffe__internal_extensions_base->griffe__internal_agentsgriffe__internal_extensions_base->griffe__internal_agents_nodesgriffe__internal_extensions_base->griffe__internal_agents_nodes_astgriffe__internal_extensions_base->griffe__internal_agents_nodes_runtimegriffe__internal_extensions_base->griffe__internal_agents_visitorgriffe__internal_extensions_base->griffe__internal_exceptionsgriffe__internal_extensions_base->griffe__internal_extensions_dataclassesgriffe__internal_extensions_base->griffe__internal_importergriffe__internal_extensions_base->griffe__internal_loadergriffe__internal_extensions_base->griffe__internal_modelsgriffe__internal_extensions_dataclasses->griffe__internal_enumerationsgriffe__internal_extensions_dataclasses->griffe__internal_expressionsgriffe__internal_extensions_dataclasses->griffe__internal_loggergriffe__internal_extensions_dataclasses->griffe__internal_modelsgriffe__internal_extensions_unpack_typeddict->griffe__internal_docstringsgriffe__internal_extensions_unpack_typeddict->griffe__internal_docstrings_modelsgriffe__internal_extensions_unpack_typeddict->griffe__internal_enumerationsgriffe__internal_extensions_unpack_typeddict->griffe__internal_expressionsgriffe__internal_extensions_unpack_typeddict->griffe__internal_extensions_basegriffe__internal_extensions_unpack_typeddict->griffe__internal_modelsgriffe__internal_finder->griffe__internal_exceptionsgriffe__internal_finder->griffe__internal_loggergriffe__internal_finder->griffe__internal_modelsgriffe__internal_git->griffe__internal_exceptionsgriffe__internal_helpers->griffe__internal_agentsgriffe__internal_helpers->griffe__internal_agents_inspectorgriffe__internal_helpers->griffe__internal_agents_visitorgriffe__internal_helpers->griffe__internal_collectionsgriffe__internal_helpers->griffe__internal_docstringsgriffe__internal_helpers->griffe__internal_docstrings_parsersgriffe__internal_helpers->griffe__internal_enumerationsgriffe__internal_helpers->griffe__internal_extensionsgriffe__internal_helpers->griffe__internal_extensions_basegriffe__internal_helpers->griffe__internal_loadergriffe__internal_helpers->griffe__internal_modelsgriffe__internal_loader->griffe__internal_agentsgriffe__internal_loader->griffe__internal_agents_inspectorgriffe__internal_loader->griffe__internal_agents_visitorgriffe__internal_loader->griffe__internal_collectionsgriffe__internal_loader->griffe__internal_docstringsgriffe__internal_loader->griffe__internal_docstrings_parsersgriffe__internal_loader->griffe__internal_enumerationsgriffe__internal_loader->griffe__internal_exceptionsgriffe__internal_loader->griffe__internal_expressionsgriffe__internal_loader->griffe__internal_extensionsgriffe__internal_loader->griffe__internal_findergriffe__internal_loader->griffe__internal_gitgriffe__internal_loader->griffe__internal_importergriffe__internal_loader->griffe__internal_loggergriffe__internal_loader->griffe__internal_mergergriffe__internal_loader->griffe__internal_modelsgriffe__internal_loader->griffe__internal_statsplatformdirsplatformdirsgriffe__internal_loader->platformdirsgriffe__internal_merger->griffe__internal_exceptionsgriffe__internal_merger->griffe__internal_expressionsgriffe__internal_merger->griffe__internal_loggergriffe__internal_merger->griffe__internal_modelsgriffe__internal_mixins->griffe__internal_encodersgriffe__internal_mixins->griffe__internal_enumerationsgriffe__internal_mixins->griffe__internal_exceptionsgriffe__internal_mixins->griffe__internal_mergergriffe__internal_mixins->griffe__internal_modelsgriffe__internal_models->griffe__internal_c3lineargriffe__internal_models->griffe__internal_docstringsgriffe__internal_models->griffe__internal_docstrings_modelsgriffe__internal_models->griffe__internal_docstrings_parsersgriffe__internal_models->griffe__internal_enumerationsgriffe__internal_models->griffe__internal_gitgriffe__internal_models->griffe__internal_loggergriffe__internal_stats->griffe__internal_enumerationsgriffe__internal_stats->griffe__internal_models

You can zoom and pan all diagrams on this page with mouse inputs.

The following sections are generated automatically by iterating on the modules of our public and internal APIs respectively, and extracting the comment blocks at the top of each module. The comment blocks are addressed to readers of the code (maintainers, contributors), while module docstrings are addressed to users of the API. Module docstrings in our internal API are never written, because our module layout is hidden, and therefore modules aren't part of the public API, so it doesn't make much sense to write "user documentation" in them.

CLI entrypoint¤

griffe.__main__¤

Public API¤

griffe¤

This top-level module imports all public names from the package, and exposes them as public objects. We have tests to make sure no object is forgotten in this list.

Internal API¤

For contributors and maintainers

These implementation details explain how Griffe works. Use objects exported by griffe when integrating with the library.

The internal API layout doesn't follow any particular paradigm: we simply organize code in different modules, depending on what the code is used for.

agents¤

These modules contain the different agents that are able to extract data.

inspector.py¤

This module contains our dynamic analysis agent, capable of inspecting modules and objects in memory, at runtime.

G cluster_8eef1891 File: inspector cluster_68722726 Class: Inspector node_9dda6d03 138: __init__() node_9dda6d03->node_9dda6d03 node_e7eab4e5 190: _get_docstring() node_bbe9bea8 212: _get_linenos() node_2400f3d6 278: generic_inspect() node_2400f3d6->node_9dda6d03 node_7d4813b3 270: inspect() node_2400f3d6->node_7d4813b3 node_259960b6 315: inspect_module() node_2400f3d6->node_259960b6 node_1d13f790 222: get_module() node_1d13f790->node_7d4813b3 node_e2d074e8 559: handle_attribute() node_e2d074e8->node_e7eab4e5 node_c9810d5e 460: handle_function() node_c9810d5e->node_e7eab4e5 node_c9810d5e->node_bbe9bea8 node_7ac4dc4e 640: _convert_object_to_annotation() node_c9810d5e->node_7ac4dc4e node_89c61b23 617: _convert_parameter() node_c9810d5e->node_89c61b23 node_7fb40632 676: _convert_type_parameters() node_c9810d5e->node_7fb40632 node_e3d5d800 551: inspect_attribute() node_e3d5d800->node_e2d074e8 node_80a34202 420: inspect_builtin_function() node_80a34202->node_c9810d5e node_68d667d5 396: inspect_builtin_method() node_68d667d5->node_c9810d5e node_29397eda 436: inspect_cached_property() node_29397eda->node_c9810d5e node_ba42fd29 338: inspect_class() node_ba42fd29->node_e7eab4e5 node_ba42fd29->node_bbe9bea8 node_ba42fd29->node_2400f3d6 node_ba42fd29->node_7fb40632 node_3ad1abfd 380: inspect_classmethod() node_3ad1abfd->node_c9810d5e node_970365f3 412: inspect_coroutine() node_970365f3->node_c9810d5e node_6e432855 428: inspect_function() node_6e432855->node_c9810d5e node_20dc5380 452: inspect_getset_descriptor() node_20dc5380->node_c9810d5e node_d79ced6e 404: inspect_method() node_d79ced6e->node_c9810d5e node_29dda1f3 388: inspect_method_descriptor() node_29dda1f3->node_c9810d5e node_259960b6->node_e7eab4e5 node_c2983162 444: inspect_property() node_c2983162->node_c9810d5e node_ce986655 372: inspect_staticmethod() node_ce986655->node_c9810d5e node_b68c7946 526: inspect_type_alias() node_b68c7946->node_e7eab4e5 node_b68c7946->node_bbe9bea8 node_b68c7946->node_7fb40632 node_f72c1d59 719: _convert_type_to_annotation() node_b68c7946->node_f72c1d59 node_89c61b23->node_7ac4dc4e node_7fb40632->node_f72c1d59 node_f72c1d59->node_7ac4dc4e node_f72c1d59->node_f72c1d59 node_0e2d923e 70: inspect() node_0e2d923e->node_9dda6d03 node_0e2d923e->node_1d13f790
nodes¤

These submodules contain utilities for working with AST and object nodes.

assignments.py¤

This module contains utilities for extracting information from assignment nodes.

G cluster_a368ef8c File: assignments node_dd6485c2 59: _get_annassign_names() node_e49990f4 42: get_name() node_dd6485c2->node_e49990f4 node_43ee73d3 54: _get_assign_names() node_43ee73d3->node_e49990f4 node_d2ae1ce8 28: _get_attribute_name() node_d2ae1ce8->node_e49990f4 node_65649fdd 82: get_instance_names() node_33ce1e47 70: get_names() node_65649fdd->node_33ce1e47
ast.py¤

This module contains utilities for navigating AST nodes.

G cluster_a5589308 File: ast node_817d5c53 48: ast_children() node_27f1e35b 165: ast_first_child() node_27f1e35b->node_817d5c53 node_440f5210 183: ast_last_child() node_440f5210->node_817d5c53 node_2d5045d2 147: ast_next() node_9f3c0ac8 94: ast_next_siblings() node_2d5045d2->node_9f3c0ac8 node_9f3c0ac8->node_817d5c53 node_52203a5a 128: ast_previous() node_5620ba7d 78: ast_previous_siblings() node_52203a5a->node_5620ba7d node_5620ba7d->node_817d5c53 node_77c7868f 110: ast_siblings() node_77c7868f->node_817d5c53
docstrings.py¤

This module contains utilities for extracting docstrings from nodes.

exports.py¤

This module contains utilities for extracting exports from __all__ assignments.

G cluster_e44dd90e File: exports node_ed9f03ff 77: _extract() node_b8476ccd 36: _extract_attribute() node_b8476ccd->node_ed9f03ff node_fb88c064 40: _extract_binop() node_fb88c064->node_ed9f03ff node_8263823d 54: _extract_sequence() node_8263823d->node_ed9f03ff node_5206a6fa 61: _extract_starred() node_5206a6fa->node_ed9f03ff node_abacf680 81: get__all__() node_abacf680->node_ed9f03ff node_513d05c6 96: safe_get__all__() node_513d05c6->node_abacf680
imports.py¤

This module contains utilities for working with imports and relative imports.

parameters.py¤

This module contains utilities for extracting information from parameter nodes.

runtime.py¤

This module contains utilities for extracting information from runtime objects.

G cluster_d8964b42 File: runtime cluster_85df446e Class: ObjectNode node_b87f5fc7 68: __init__() node_fdfac3ad 301: _pick_member() node_3b0b0d84 312: alias_target_path() node_926bbb7e 52: _same_components() node_3b0b0d84->node_926bbb7e node_73472613 191: children() node_73472613->node_b87f5fc7 node_73472613->node_fdfac3ad
values.py¤

This module contains utilities for extracting attribute values.

G cluster_b855bab8 File: values node_65c5fb33 31: get_value() node_5566136f 45: safe_get_value() node_5566136f->node_65c5fb33
parser.py¤
visitor.py¤

This module contains our static analysis agent, capable of parsing and visiting sources, statically.

G cluster_5ede1bcc File: visitor cluster_628aed59 Class: Visitor node_3e32e274 151: __init__() node_3e32e274->node_3e32e274 node_21121842 213: _get_docstring() node_c024051e 233: _get_type_parameters() node_81df272f 383: decorators_to_labels() node_52b02452 297: generic_visit() node_75d7db32 288: visit() node_52b02452->node_75d7db32 node_5dd47de0 401: get_base_property() node_a7f44a04 262: get_module() node_a7f44a04->node_75d7db32 node_bf108327 646: handle_attribute() node_bf108327->node_21121842 node_08bda32c 425: handle_function() node_08bda32c->node_21121842 node_08bda32c->node_c024051e node_08bda32c->node_81df272f node_08bda32c->node_52b02452 node_08bda32c->node_5dd47de0 node_eb3750bb 761: visit_annassign() node_eb3750bb->node_bf108327 node_aa1f7ded 753: visit_assign() node_aa1f7ded->node_bf108327 node_7050d7b9 542: visit_asyncfunctiondef() node_7050d7b9->node_08bda32c node_16143b93 329: visit_classdef() node_16143b93->node_21121842 node_16143b93->node_c024051e node_16143b93->node_81df272f node_16143b93->node_52b02452 node_f81d4e5b 534: visit_functiondef() node_f81d4e5b->node_08bda32c node_1b47698e 790: visit_if() node_1b47698e->node_52b02452 node_919ffb85 306: visit_module() node_919ffb85->node_21121842 node_919ffb85->node_52b02452 node_b8c33bfb 553: visit_typealias() node_b8c33bfb->node_21121842 node_b8c33bfb->node_c024051e node_c1fabca7 94: visit() node_c1fabca7->node_3e32e274 node_c1fabca7->node_a7f44a04

c3linear.py¤

This module contains a single function, c3linear_merge. The function is generic enough to be in its own module.

  • Copyright (c) 2019 Vitaly R. Samigullin
  • Adapted from https://github.com/pilosus/c3linear
  • Adapted from https://github.com/tristanlatr/pydocspec
G cluster_76f5d537 File: c3linear cluster_68ae21a8 Class: _Dependency cluster_8c8a3391 Class: _DependencyList node_94150568 29: tail() node_5c91c421 60: __len__() node_94150568->node_5c91c421 node_9d873873 48: __init__() node_9818cdff 64: __repr__() node_9818cdff->node_9818cdff node_97b04cee 82: remove() node_6f741b37 93: c3linear_merge() node_6f741b37->node_9d873873 node_6f741b37->node_97b04cee

collections.py¤

This module contains collection-related classes, which are used throughout the API.

G cluster_4bca457b File: collections cluster_c61dc513 Class: LinesCollection node_129e3927 72: items() node_129e3927->node_129e3927 node_b448a4d8 56: keys() node_b448a4d8->node_b448a4d8 node_1e17755e 64: values() node_1e17755e->node_1e17755e

debug.py¤

This module is here to help users report bugs. It provides a function to print environment information, which is called from the public griffe.debug module (when called with python -m griffe.debug) or thanks to the --debug-info CLI flag.

G cluster_82c984c1 File: debug node_8c5357eb 96: _get_debug_info() node_6e5ed81b 81: _get_version() node_8c5357eb->node_6e5ed81b node_032cd916 70: _interpreter_name_version() node_8c5357eb->node_032cd916 node_f744cc7d 115: _print_debug_info() node_f744cc7d->node_8c5357eb

diff.py¤

This module exports "breaking changes" related utilities. The logic here is to iterate on objects and their members recursively, to yield found breaking changes.

The breakage class definitions might sound a bit verbose, but declaring them this way helps with (de)serialization, which we don't use yet, but could use in the future.

G cluster_3744b223 File: diff cluster_e6143d4d Class: Breakage node_c350cb02 300: _explain_azdo() node_51622c99 221: _format_new_value() node_c350cb02->node_51622c99 node_430d7dcc 218: _format_old_value() node_c350cb02->node_430d7dcc node_d37fcfa0 210: _format_title() node_c350cb02->node_d37fcfa0 node_83b690c6 278: _explain_github() node_83b690c6->node_51622c99 node_83b690c6->node_430d7dcc node_83b690c6->node_d37fcfa0 node_d50fe7fc 258: _explain_markdown() node_d50fe7fc->node_51622c99 node_d50fe7fc->node_430d7dcc node_cd7ed4e5 224: _explain_oneline() node_6462b1fc 213: _format_kind() node_cd7ed4e5->node_6462b1fc node_d813fea9 205: _format_location() node_cd7ed4e5->node_d813fea9 node_cd7ed4e5->node_51622c99 node_cd7ed4e5->node_430d7dcc node_cd7ed4e5->node_d37fcfa0 node_9cca8867 240: _explain_verbose() node_9cca8867->node_6462b1fc node_9cca8867->node_d813fea9 node_9cca8867->node_51622c99 node_9cca8867->node_430d7dcc node_9cca8867->node_d37fcfa0 node_65b48f8b 601: _alias_incompatibilities() node_efaefe42 642: _type_based_yield() node_65b48f8b->node_efaefe42 node_e5026030 596: _attribute_incompatibilities() node_91323628 505: _class_incompatibilities() node_fab57e99 617: _member_incompatibilities() node_91323628->node_fab57e99 node_5ad0442e 518: _function_incompatibilities() node_94338a9f 679: _returns_are_compatible() node_5ad0442e->node_94338a9f node_fab57e99->node_efaefe42 node_efaefe42->node_e5026030 node_efaefe42->node_91323628 node_efaefe42->node_5ad0442e node_2c7aac20 703: find_breaking_changes() node_2c7aac20->node_fab57e99

docstrings¤

These submodules define models and parsers for docstrings.

auto.py¤

This module defines functions to parse docstrings by guessing their style.

G cluster_fea095f2 File: auto node_0a889fab 145: infer_docstring_style() node_d2fa95bc 216: parse_auto() node_d2fa95bc->node_0a889fab
google.py¤

This module defines functions to parse Google-style docstrings into structured data.

G cluster_0be88b0c File: google node_4e9b2ade 660: _annotation_from_parent() node_0ff3561c 629: _get_name_annotation_description() node_db45b995 889: _is_empty_line() node_4ccbfac4 377: _read_attributes_section() node_003b9044 108: _read_block_items() node_4ccbfac4->node_003b9044 node_6fec3f58 177: _read_block() node_6fec3f58->node_db45b995 node_003b9044->node_db45b995 node_128e2616 614: _read_block_items_maybe() node_128e2616->node_6fec3f58 node_128e2616->node_003b9044 node_9d975ce5 458: _read_classes_section() node_9d975ce5->node_003b9044 node_0037c398 829: _read_examples_section() node_0037c398->node_db45b995 node_0037c398->node_6fec3f58 node_5207537e 420: _read_functions_section() node_5207537e->node_003b9044 node_6fe4ef57 524: _read_modules_section() node_6fe4ef57->node_003b9044 node_8a84daf9 293: _read_other_parameters_section() node_fc733552 212: _read_parameters() node_8a84daf9->node_fc733552 node_fc733552->node_003b9044 node_e897c7ee 282: _read_parameters_section() node_e897c7ee->node_fc733552 node_6d79c93d 553: _read_raises_section() node_6d79c93d->node_003b9044 node_310d4c96 779: _read_receives_section() node_310d4c96->node_4e9b2ade node_310d4c96->node_0ff3561c node_310d4c96->node_128e2616 node_44093fb5 679: _read_returns_section() node_44093fb5->node_4e9b2ade node_44093fb5->node_0ff3561c node_44093fb5->node_128e2616 node_b83def1b 496: _read_type_aliases_section() node_b83def1b->node_003b9044 node_2fa03d1f 305: _read_type_parameters_section() node_2fa03d1f->node_003b9044 node_02184b87 585: _read_warns_section() node_02184b87->node_003b9044 node_914deaef 729: _read_yields_section() node_914deaef->node_4e9b2ade node_914deaef->node_0ff3561c node_914deaef->node_128e2616 node_9564e6f9 936: parse_google() node_9564e6f9->node_db45b995 node_9564e6f9->node_6fec3f58
models.py¤

This module contains the models for storing docstrings structured data.

G cluster_0550d6f6 File: models cluster_ab4263f0 Class: DocstringSection node_b2b73010 262: as_dict() node_b2b73010->node_b2b73010
numpy.py¤

This module defines functions to parse Numpy-style docstrings into structured data.

Based on https://numpydoc.readthedocs.io/en/latest/format.html, it seems Numpydoc is a superset of RST. Since fully parsing RST is a non-goal of this project, some things are stripped from the Numpydoc specification.

Rejected as non particularly Pythonic or useful as sections:

  • See also: this section feels too subjective (specially crafted as a standard for Numpy itself), and there are may ways to reference related items in a docstring, depending on the chosen markup.

Rejected as naturally handled by the user-chosen markup:

  • Warnings: this is just markup.
  • Notes: again, just markup.
  • References: again, just markup.
G cluster_8f0f838b File: numpy node_26e1e904 899: _append_section() node_117572a0 111: _is_dash_line() node_3a6ba22c 107: _is_empty_line() node_117572a0->node_3a6ba22c node_fe40a425 671: _read_attributes_section() node_0d1c4524 115: _read_block_items() node_fe40a425->node_0d1c4524 node_0c6a0e3c 177: _read_block() node_0c6a0e3c->node_117572a0 node_0c6a0e3c->node_3a6ba22c node_0d1c4524->node_117572a0 node_0d1c4524->node_3a6ba22c node_3005f733 744: _read_classes_section() node_3005f733->node_0d1c4524 node_eadc28a7 432: _read_deprecated_section() node_eadc28a7->node_0d1c4524 node_056ad869 833: _read_examples_section() node_056ad869->node_3a6ba22c node_056ad869->node_0c6a0e3c node_a10e384b 711: _read_functions_section() node_a10e384b->node_0d1c4524 node_cc8d1b35 800: _read_modules_section() node_cc8d1b35->node_0d1c4524 node_002a1061 334: _read_other_parameters_section() node_ba0b3a71 243: _read_parameters() node_002a1061->node_ba0b3a71 node_ba0b3a71->node_0d1c4524 node_3110f2f9 318: _read_parameters_section() node_3110f2f9->node_ba0b3a71 node_80f0c1d9 619: _read_raises_section() node_80f0c1d9->node_0d1c4524 node_cd2adcbf 571: _read_receives_section() node_cd2adcbf->node_0d1c4524 node_c111ac91 459: _read_returns_section() node_c111ac91->node_0d1c4524 node_84734993 777: _read_type_aliases_section() node_84734993->node_0d1c4524 node_1f60ccdf 358: _read_type_parameters_section() node_1f60ccdf->node_0d1c4524 node_dd251fb1 645: _read_warns_section() node_dd251fb1->node_0d1c4524 node_b967f20e 519: _read_yields_section() node_b967f20e->node_0d1c4524 node_bda5d308 952: parse_numpy() node_bda5d308->node_26e1e904 node_bda5d308->node_117572a0 node_bda5d308->node_3a6ba22c
parsers.py¤

This module imports all the defined parsers and provides a generic function to parse docstrings.

sphinx.py¤

This module defines functions to parse Sphinx docstrings into structured data.

G cluster_42b98516 File: sphinx cluster_9e0f18b2 Class: _FieldType node_c93fec82 72: matches() node_91002b59 500: _consolidate_continuation_lines() node_510b0fce 513: _consolidate_descriptive_type() node_5797c6f8 240: _determine_param_annotation() node_0ea7a703 233: _determine_param_default() node_9c656774 481: _parse_directive() node_9c656774->node_91002b59 node_1a4af0f6 465: _parsed_values_to_sections() node_1fcd7bfc 517: _strip_blank_lines() node_1a4af0f6->node_1fcd7bfc node_c3ba9b46 307: _read_attribute() node_c3ba9b46->node_9c656774 node_dd0186f6 355: _read_attribute_type() node_dd0186f6->node_510b0fce node_dd0186f6->node_9c656774 node_871be77b 386: _read_exception() node_871be77b->node_9c656774 node_1eeb2ba4 169: _read_parameter() node_1eeb2ba4->node_5797c6f8 node_1eeb2ba4->node_0ea7a703 node_1eeb2ba4->node_9c656774 node_5136628d 275: _read_parameter_type() node_5136628d->node_510b0fce node_5136628d->node_9c656774 node_e4e6d49c 408: _read_return() node_e4e6d49c->node_9c656774 node_7bd73b09 443: _read_return_type() node_7bd73b09->node_510b0fce node_7bd73b09->node_9c656774 node_f6d14f0b 120: parse_sphinx() node_f6d14f0b->node_c93fec82 node_f6d14f0b->node_1a4af0f6
utils.py¤

This module contains utilities for docstrings parsers.

G cluster_36eb5af6 File: utils node_d20c0937 69: _compile_docstring_annotation() node_338de801 76: parse_docstring_annotation() node_338de801->node_d20c0937

encoders.py¤

This module contains data encoders/serializers and decoders/deserializers. We only support JSON for now, but might want to add more formats in the future.

G cluster_d0da9ada File: encoders cluster_14a35867 Class: JSONEncoder node_ec880442 79: __init__() node_ec880442->node_ec880442 node_0fa1925c 174: _attach_parent_to_expr() node_4995a388 184: _attach_parent_to_exprs() node_4995a388->node_0fa1925c node_fc82bca5 303: _load_attribute() node_c352d0dc 116: _load_docstring() node_fc82bca5->node_c352d0dc node_1b3dfa00 165: _load_git_info() node_fc82bca5->node_1b3dfa00 node_3aa39793 250: _load_class() node_3aa39793->node_4995a388 node_aafd8e99 122: _load_decorators() node_3aa39793->node_aafd8e99 node_3aa39793->node_c352d0dc node_3aa39793->node_1b3dfa00 node_cd1d91dd 126: _load_expression() node_2ecf0381 280: _load_function() node_2ecf0381->node_aafd8e99 node_2ecf0381->node_c352d0dc node_2ecf0381->node_1b3dfa00 node_bf46046d 221: _load_module() node_bf46046d->node_4995a388 node_bf46046d->node_c352d0dc node_bf46046d->node_1b3dfa00 node_276180e8 146: _load_parameter() node_276180e8->node_c352d0dc node_a50e1265 339: _load_type_alias() node_a50e1265->node_c352d0dc node_a50e1265->node_1b3dfa00 node_b0a1de71 156: _load_type_parameter() node_db4d4cd6 370: json_decoder() node_db4d4cd6->node_cd1d91dd node_db4d4cd6->node_276180e8 node_db4d4cd6->node_b0a1de71

enumerations.py¤

This module contains all the enumerations of the package.

exceptions.py¤

This module contains all the exceptions specific to Griffe.

G cluster_ab42dac1 File: exceptions cluster_21fede93 Class: AliasResolutionError node_1263c424 70: __str__() node_35997f56 62: _format_message() node_1263c424->node_35997f56

expressions.py¤

This module contains the data classes that represent resolvable names and expressions. First we declare data classes for each kind of expression, mostly corresponding to Python's AST nodes. Then we declare builder methods, that iterate AST nodes and build the corresponding data classes, and two utilities _yield and _join to help iterate on expressions. Finally we declare a few public helpers to safely get expressions from AST nodes in different scenarios.

G cluster_83eedf68 File: expressions cluster_b4054d02 Class: Expr cluster_8c57abf6 Class: ExprAttribute cluster_ec525ce4 Class: ExprBinOp cluster_2dad610d Class: ExprBoolOp cluster_3f705332 Class: ExprCall cluster_0b32c800 Class: ExprCompare cluster_60a32040 Class: ExprComprehension cluster_1f21ac03 Class: ExprDict cluster_86e305fa Class: ExprDictComp cluster_4b591724 Class: ExprExtSlice cluster_79c96929 Class: ExprFormatted cluster_f29d0426 Class: ExprGeneratorExp cluster_61920bfc Class: ExprIfExp cluster_4223fd83 Class: ExprInterpolation cluster_0955611a Class: ExprJoinedStr cluster_bcd91799 Class: ExprKeyword cluster_af7fab88 Class: ExprVarPositional cluster_b69791fe Class: ExprVarKeyword cluster_ea5304b0 Class: ExprLambda cluster_d8a69e34 Class: ExprList cluster_f1a8ed80 Class: ExprListComp cluster_0c6c8a12 Class: ExprNamedExpr cluster_b766c8de Class: ExprSet cluster_5aa63cf2 Class: ExprSetComp cluster_3c291e71 Class: ExprSlice cluster_25a92352 Class: ExprSubscript cluster_cda73405 Class: ExprTemplateStr cluster_d0b8d16d Class: ExprTuple cluster_abf74725 Class: ExprUnaryOp cluster_5ba81fcc Class: ExprAwait cluster_a01edeb1 Class: ExprYield cluster_940d2243 Class: ExprYieldFrom node_5ae47b7d 356: __iter__() node_d6c0859c 360: iterate() node_5ae47b7d->node_d6c0859c node_74de7c4e 353: __str__() node_74de7c4e->node_d6c0859c node_deac0e3a 453: _to_binop() node_deac0e3a->node_deac0e3a node_3213875a 389: as_dict() node_cdeb3b26 332: _expr_as_dict() node_3213875a->node_cdeb3b26 node_0b86ea42 493: append() node_0b86ea42->node_0b86ea42 node_5e222ab2 476: iterate() node_ae55e6bf 1493: _get_precedence() node_5e222ab2->node_ae55e6bf node_ef1b5993 245: _yield() node_5e222ab2->node_ef1b5993 node_5b2c5015 1363: iterate() node_5b2c5015->node_ef1b5993 node_f94756fb 542: iterate() node_f94756fb->node_ae55e6bf node_f94756fb->node_ef1b5993 node_f48af14d 562: iterate() node_f48af14d->node_ae55e6bf node_f48af14d->node_ef1b5993 node_01f4beb5 590: iterate() node_01f4beb5->node_ae55e6bf node_7295599d 288: _join() node_01f4beb5->node_7295599d node_01f4beb5->node_ef1b5993 node_9f85d7a1 608: iterate() node_9f85d7a1->node_ae55e6bf node_9f85d7a1->node_ef1b5993 node_76900a8a 629: iterate() node_76900a8a->node_ef1b5993 node_605596cc 667: iterate() node_605596cc->node_7295599d node_41a54408 694: iterate() node_41a54408->node_7295599d node_41a54408->node_ef1b5993 node_d2063d5e 715: iterate() node_d2063d5e->node_7295599d node_3b85e7d4 769: iterate() node_afe17edf 719: _iterate_format_parts() node_3b85e7d4->node_afe17edf node_ef6f6011 784: iterate() node_ef6f6011->node_7295599d node_ef6f6011->node_ef1b5993 node_0bde2eea 807: iterate() node_0bde2eea->node_0bde2eea node_0bde2eea->node_ae55e6bf node_0bde2eea->node_ef1b5993 node_a0bf90f2 836: iterate() node_a0bf90f2->node_afe17edf node_93d793a6 884: iterate() node_779bd744 844: _fstring_choose_quote() node_93d793a6->node_779bd744 node_93d793a6->node_ef1b5993 node_81426399 937: iterate() node_81426399->node_ef1b5993 node_a372a0d3 977: iterate() node_a372a0d3->node_ef1b5993 node_a2d12774 1020: iterate() node_a2d12774->node_7295599d node_c93e3c82 1035: iterate() node_c93e3c82->node_7295599d node_c93e3c82->node_ef1b5993 node_be9d52f4 1166: iterate() node_be9d52f4->node_ef1b5993 node_bfc8f840 1196: iterate() node_bfc8f840->node_7295599d node_b831c008 1211: iterate() node_b831c008->node_7295599d node_b831c008->node_ef1b5993 node_5e233205 1230: iterate() node_5e233205->node_ef1b5993 node_7a145504 1251: iterate() node_7a145504->node_ae55e6bf node_7a145504->node_ef1b5993 node_dfe84837 1258: modernize() node_dfe84837->node_deac0e3a node_dfe84837->node_dfe84837 node_c9d1ba25 1298: iterate() node_c9d1ba25->node_779bd744 node_c9d1ba25->node_ef1b5993 node_3fd97872 1318: iterate() node_3fd97872->node_7295599d node_fec00bfb 1349: iterate() node_fec00bfb->node_ae55e6bf node_fec00bfb->node_ef1b5993 node_85a80c7c 963: iterate() node_85a80c7c->node_ef1b5993 node_259f6226 951: iterate() node_259f6226->node_ef1b5993 node_db2c34c9 1375: iterate() node_db2c34c9->node_ef1b5993 node_fb5d5e0f 1389: iterate() node_fb5d5e0f->node_ef1b5993 node_86a0ed17 1845: _build() node_3189a1a2 1497: _build_attribute() node_3189a1a2->node_0b86ea42 node_3189a1a2->node_86a0ed17 node_71f0b4d8 1509: _build_await() node_71f0b4d8->node_86a0ed17 node_75286edb 1513: _build_binop() node_75286edb->node_86a0ed17 node_3f9c7f9b 1521: _build_boolop() node_3f9c7f9b->node_86a0ed17 node_8147f988 1528: _build_call() node_8147f988->node_86a0ed17 node_9638ba03 1539: _build_compare() node_9638ba03->node_86a0ed17 node_e80fc5db 1555: _build_comprehension() node_e80fc5db->node_86a0ed17 node_54a20fac 1547: _build_implicit_tuple() node_e80fc5db->node_54a20fac node_e19a4667 1564: _build_constant() node_e19a4667->node_86a0ed17 node_de829c68 1603: _build_dict() node_de829c68->node_86a0ed17 node_361f545f 1610: _build_dictcomp() node_361f545f->node_86a0ed17 node_d15fd5c9 1621: _build_format_spec() node_d15fd5c9->node_86a0ed17 node_ed5d60f7 1629: _build_formatted() node_ed5d60f7->node_86a0ed17 node_ed5d60f7->node_d15fd5c9 node_5d38a9c6 1644: _build_generatorexp() node_5d38a9c6->node_86a0ed17 node_17fe82ae 1658: _build_ifexp() node_17fe82ae->node_86a0ed17 node_54a20fac->node_86a0ed17 node_cd335b47 1816: _build_interpolation() node_cd335b47->node_86a0ed17 node_cd335b47->node_d15fd5c9 node_043558c9 1666: _build_joinedstr() node_043558c9->node_86a0ed17 node_a133827d 1676: _build_keyword() node_a133827d->node_86a0ed17 node_34143bb8 1682: _build_lambda() node_34143bb8->node_86a0ed17 node_81e6e5e3 1879: safe_get_expression() node_34143bb8->node_81e6e5e3 node_92187755 1699: _build_list() node_92187755->node_86a0ed17 node_ba9f4818 1703: _build_listcomp() node_ba9f4818->node_86a0ed17 node_c9b3b761 1711: _build_named_expr() node_c9b3b761->node_86a0ed17 node_23f1d8ea 1715: _build_set() node_23f1d8ea->node_86a0ed17 node_4cff7188 1719: _build_setcomp() node_4cff7188->node_86a0ed17 node_0cfa01e9 1723: _build_slice() node_0cfa01e9->node_86a0ed17 node_2676daaa 1731: _build_starred() node_2676daaa->node_86a0ed17 node_a4f8bb39 1735: _build_subscript() node_a4f8bb39->node_86a0ed17 node_a4f8bb39->node_54a20fac node_2cf9be49 1830: _build_templatestr() node_2cf9be49->node_86a0ed17 node_9549a7c4 1762: _build_tuple() node_9549a7c4->node_86a0ed17 node_8f991e6f 1766: _build_unaryop() node_8f991e6f->node_86a0ed17 node_492f99e7 1770: _build_yield() node_492f99e7->node_86a0ed17 node_137318b7 1774: _build_yield_from() node_137318b7->node_86a0ed17 node_26c303ec 312: _field_as_dict() node_cdeb3b26->node_26c303ec node_a6598d72 324: _serializable_expression_fields() node_cdeb3b26->node_a6598d72 node_26c303ec->node_26c303ec node_779bd744->node_0b86ea42 node_afe17edf->node_afe17edf node_afe17edf->node_ef1b5993 node_7295599d->node_ef1b5993 node_ef1b5993->node_ae55e6bf node_ef1b5993->node_ef1b5993 node_6d8df534 1849: get_expression() node_6d8df534->node_86a0ed17 node_81e6e5e3->node_6d8df534

extensions¤

These submodules contain our extension system, as well as built-in extensions.

base.py¤

This module contains the base class for extensions and the functions to load them.

G cluster_db431510 File: base cluster_cc3ebe4e Class: Extension cluster_72ebf9fd Class: Extensions node_6ccf8dd9 74: generic_inspect() node_3546f9cd 66: inspect() node_6ccf8dd9->node_3546f9cd node_17d3ec3f 57: generic_visit() node_363c3a4f 49: visit() node_17d3ec3f->node_363c3a4f node_e3a65b5d 429: on_alias() node_ebaf0d83 405: on_alias_instance() node_ebaf0d83->node_e3a65b5d node_4a8f33a3 463: __init__() node_6ef6471d 472: add() node_4a8f33a3->node_6ef6471d node_ae7781af 530: _load_extension() node_8159a65a 519: _load_extension_path() node_ae7781af->node_8159a65a node_1b4f0b43 621: load_extensions() node_1b4f0b43->node_4a8f33a3 node_1b4f0b43->node_6ef6471d node_1b4f0b43->node_ae7781af
dataclasses.py¤

Built-in extension adding support for dataclasses.

This extension re-creates __init__ methods of dataclasses during static analysis.

G cluster_988466c2 File: dataclasses cluster_5fb4d2b8 Class: DataclassesExtension node_131cc4e1 243: on_package() node_b0c8bb13 219: _apply_recursively() node_131cc4e1->node_b0c8bb13 node_b0c8bb13->node_b0c8bb13 node_b2c1c951 211: _del_members_annotated_as_initvar() node_b0c8bb13->node_b2c1c951 node_7d715f86 173: _set_dataclass_init() node_b0c8bb13->node_7d715f86 node_fc425502 65: _dataclass_arguments() node_634a2823 41: _dataclass_decorator() node_fc425502->node_634a2823 node_8d23e0b0 48: _expr_args() node_fc425502->node_8d23e0b0 node_4ee88cb8 82: _dataclass_parameters() node_4ee88cb8->node_fc425502 node_5fe16dc9 71: _field_arguments() node_4ee88cb8->node_5fe16dc9 node_8d23e0b0->node_8d23e0b0 node_5fe16dc9->node_8d23e0b0 node_7632734c 155: _reorder_parameters() node_7d715f86->node_634a2823 node_7d715f86->node_4ee88cb8 node_7d715f86->node_7632734c
unpack_typeddict.py¤

TODO: Support extra_items=type. TODO: Support closed=True/False.

G cluster_c528aea7 File: unpack_typeddict cluster_c9040ca4 Class: UnpackTypedDictExtension node_f00a142a 207: on_class() node_df7eb507 81: _get_or_set_attrs() node_f00a142a->node_df7eb507 node_c49d88a7 186: _params_from_attrs() node_f00a142a->node_c49d88a7 node_1e9ac2b1 125: _update_docstring() node_f00a142a->node_1e9ac2b1 node_21140448 234: on_function() node_21140448->node_df7eb507 node_21140448->node_c49d88a7 node_21140448->node_1e9ac2b1 node_36d432b6 45: _unwrap_annotation() node_df7eb507->node_36d432b6

finder.py¤

This module contains the code allowing to find modules.

Note: It might be possible to replace a good part of this module's logic with utilities from importlib (however the util in question is private):

>>> from importlib.util import _find_spec
>>> _find_spec("griffe.agents", _find_spec("griffe", None).submodule_search_locations)
ModuleSpec(
    name='griffe.agents',
    loader=<_frozen_importlib_external.SourceFileLoader object at 0x7fa5f34e8110>,
    origin='/media/data/dev/griffelib/packages/griffe/src/griffe/agents/__init__.py',
    submodule_search_locations=['/media/data/dev/griffelib/packages/griffe/src/griffe/agents'],
)
G cluster_4ffbaf94 File: finder cluster_fdbc7b66 Class: ModuleFinder node_3f5ae0b4 118: __init__() node_e193f84d 400: _extend_from_pth_files() node_3f5ae0b4->node_e193f84d node_25b9ee22 135: append_search_path() node_3f5ae0b4->node_25b9ee22 node_ae83338b 146: _append_search_path() node_3353e864 392: _contents() node_e193f84d->node_3353e864 node_e193f84d->node_25b9ee22 node_5817f6fc 456: _handle_pth_file() node_e193f84d->node_5817f6fc node_547f71e3 409: _filter_py_modules() node_48b6ce76 377: _module_name_path() node_1ce4fa31 417: _top_module_name() node_3996281a 150: insert_search_path() node_1ce4fa31->node_3996281a node_25b9ee22->node_ae83338b node_b720f0ea 247: find_package() node_b720f0ea->node_3353e864 node_049181bc 441: _is_pkg_style_namespace() node_b720f0ea->node_049181bc node_09084c9b 164: find_spec() node_09084c9b->node_48b6ce76 node_09084c9b->node_1ce4fa31 node_09084c9b->node_b720f0ea node_3fa2a446 294: iter_submodules() node_3fa2a446->node_547f71e3 node_3fa2a446->node_3fa2a446 node_fb7c3445 360: submodules() node_fb7c3445->node_3fa2a446 node_8fb41a70 486: _handle_editable_module() node_37b4aa93 67: _match_pattern() node_8fb41a70->node_37b4aa93 node_5817f6fc->node_8fb41a70

git.py¤

This module contains Git utilities, used by our load_git function, which in turn is used to load the API for different snapshots of a Git repository and find breaking changes between them.

G cluster_ae020b9f File: git cluster_d4a8a602 Class: GitInfo node_c705f509 258: from_package() node_2a01c598 234: _get_git_commit_hash() node_c705f509->node_2a01c598 node_4b4135fc 179: _get_git_known_service() node_c705f509->node_4b4135fc node_0a406ae1 153: _get_git_remote_url() node_c705f509->node_0a406ae1 node_0901ad6e 103: _get_repo_root() node_c705f509->node_0901ad6e node_d88ddee5 240: _is_tracked() node_c705f509->node_d88ddee5 node_c89b18ac 285: get_source_link() node_da6c6ec7 220: _get_source_link() node_c89b18ac->node_da6c6ec7 node_cda1d2e2 66: _assert_git_repo() node_37487425 52: _git() node_cda1d2e2->node_37487425 node_2a01c598->node_37487425 node_0a406ae1->node_37487425 node_a686d31d 83: _get_latest_tag() node_a686d31d->node_37487425 node_0901ad6e->node_37487425 node_d88ddee5->node_37487425 node_41b72328 46: _normalize() node_7f5b565e 120: _tmp_worktree() node_7f5b565e->node_cda1d2e2 node_7f5b565e->node_37487425 node_7f5b565e->node_41b72328

helpers.py¤

This module contains helpers. They simplify programmatic use of Griffe, for example to load data from strings or to create temporary packages. They are particularly useful for our own tests suite.

G cluster_97c1917a File: helpers node_6715ff77 429: module_vtree() node_a5b34b0e 386: vtree() node_6715ff77->node_a5b34b0e node_fc81da52 335: temporary_inspected_module() node_137c0c6a 70: temporary_pyfile() node_fc81da52->node_137c0c6a node_65bf8dfd 210: temporary_inspected_package() node_f5897071 88: temporary_pypackage() node_65bf8dfd->node_f5897071 node_29c3736f 289: temporary_visited_module() node_29c3736f->node_137c0c6a node_66bfc8e1 137: temporary_visited_package() node_66bfc8e1->node_f5897071

importer.py¤

This module contains utilities to dynamically import objects. These utilities are used by our Inspector to dynamically import objects specified as Python paths, like package.module.Class.method.

G cluster_70b0e817 File: importer node_5a398f79 33: _error_details() node_b8332873 59: dynamic_import() node_b8332873->node_5a398f79 node_8ecf71b5 38: sys_path() node_b8332873->node_8ecf71b5

loader.py¤

This module contains all the logic for loading API data from sources or compiled modules.

G cluster_0e26b704 File: loader cluster_09cc7484 Class: GriffeLoader node_7c43e2f8 79: __init__() node_faecf780 685: _create_module() node_ed7393e1 770: _expand_wildcard() node_025f4e34 228: _fire_load_events() node_025f4e34->node_025f4e34 node_2a8596cc 740: _get_or_create_parent_module() node_2a8596cc->node_faecf780 node_55f930a5 713: _inspect_module() node_f141758e 586: _load_module() node_3cc87fc8 605: _load_module_path() node_f141758e->node_3cc87fc8 node_3cc87fc8->node_faecf780 node_3cc87fc8->node_55f930a5 node_a2d3fffb 630: _load_submodules() node_3cc87fc8->node_a2d3fffb node_f6b8c106 693: _visit_module() node_3cc87fc8->node_f6b8c106 node_52c30127 571: _load_package() node_52c30127->node_f141758e node_1ca3b622 366: expand_wildcards() node_52c30127->node_1ca3b622 node_b804d710 634: _load_submodule() node_b804d710->node_2a8596cc node_b804d710->node_f141758e node_a2d3fffb->node_b804d710 node_6e72db03 247: _post_load() node_6e72db03->node_025f4e34 node_29d72386 325: expand_exports() node_6e72db03->node_29d72386 node_6e72db03->node_1ca3b622 node_29d72386->node_29d72386 node_1ca3b622->node_ed7393e1 node_1ca3b622->node_1ca3b622 node_198fd3ed 138: load() node_1ca3b622->node_198fd3ed node_198fd3ed->node_55f930a5 node_198fd3ed->node_52c30127 node_198fd3ed->node_6e72db03 node_bf81662e 269: resolve_aliases() node_bf81662e->node_1ca3b622 node_1fb2985d 482: resolve_module_aliases() node_bf81662e->node_1fb2985d node_1fb2985d->node_198fd3ed node_1fb2985d->node_1fb2985d node_118da62b 779: load() node_118da62b->node_7c43e2f8 node_118da62b->node_198fd3ed node_118da62b->node_bf81662e node_8efa23cc 889: load_git() node_8efa23cc->node_118da62b node_14b465bc 979: load_pypi() node_14b465bc->node_118da62b

logger.py¤

This module contains the logger used throughout Griffe. The logger is actually a wrapper around the standard Python logger. We wrap it so that it is easier for other downstream libraries to patch it. For example, mkdocstrings-python patches the logger to relocate it as a child of mkdocs.plugins so that it fits in the MkDocs logging configuration.

We use a single, global logger because our public API is exposed in a single module, griffe. Extensions however should use their own logger, which is why we provide the get_logger function.

G cluster_87fb0370 File: logger cluster_b97cff5d Class: Logger node_b6bbd682 0: (global)() node_021c7b43 59: _get() node_b6bbd682->node_021c7b43 node_54e4a6e1 65: _patch_loggers() node_de00dd36 109: get_logger() node_de00dd36->node_021c7b43 node_c8a6a3b9 121: patch_loggers() node_c8a6a3b9->node_54e4a6e1

merger.py¤

This module contains utilities to merge stubs data and concrete data.

G cluster_f1145e9c File: merger node_aa64933e 96: _merge_annotations() node_9d332ec2 59: _merge_attribute_stubs() node_acd35ed1 71: _merge_stubs_docstring() node_9d332ec2->node_acd35ed1 node_93b25492 40: _merge_class_stubs() node_93b25492->node_acd35ed1 node_025de7eb 135: _merge_stubs_members() node_93b25492->node_025de7eb node_9ac5bd0f 81: _merge_stubs_overloads() node_93b25492->node_9ac5bd0f node_e1ab81c3 76: _merge_stubs_type_parameters() node_93b25492->node_e1ab81c3 node_d741e2d7 47: _merge_function_stubs() node_d741e2d7->node_acd35ed1 node_d741e2d7->node_e1ab81c3 node_6385df96 34: _merge_module_stubs() node_6385df96->node_acd35ed1 node_6385df96->node_025de7eb node_6385df96->node_9ac5bd0f node_d5c0d754 104: _merge_overload_annotations() node_d5c0d754->node_aa64933e node_025de7eb->node_9d332ec2 node_025de7eb->node_d741e2d7 node_feb6ecd3 66: _merge_type_alias_stubs() node_025de7eb->node_feb6ecd3 node_9ac5bd0f->node_d5c0d754 node_feb6ecd3->node_acd35ed1 node_feb6ecd3->node_e1ab81c3 node_ace68d97 179: merge_stubs() node_ace68d97->node_6385df96

mixins.py¤

This module contains some mixins classes that hold shared methods of the different kinds of objects, and aliases.

G cluster_d7874332 File: mixins cluster_ce528e78 Class: GetMembersMixin cluster_8e548ee4 Class: DelMembersMixin cluster_f9f1907c Class: SetMembersMixin node_d35d32a6 103: __delitem__() node_3e5652ba 38: _get_parts() node_d35d32a6->node_3e5652ba node_2a94231c 130: del_member() node_2a94231c->node_2a94231c node_2a94231c->node_3e5652ba node_e6642073 53: __getitem__() node_e6642073->node_3e5652ba node_53b2b5ec 75: get_member() node_53b2b5ec->node_53b2b5ec node_53b2b5ec->node_3e5652ba node_9790cf14 158: __setitem__() node_9790cf14->node_3e5652ba node_a366146a 184: set_member() node_a366146a->node_a366146a node_a366146a->node_3e5652ba

models.py¤

This module contains our models definitions, to represent Python objects (and other aspects of Python APIs)... in Python.

G cluster_c0928b59 File: models cluster_bc7d0f00 Class: _ModuleSerializationContext cluster_3e12b396 Class: Docstring cluster_1f8ef5b0 Class: Parameter cluster_d0900d8e Class: Parameters cluster_9dcb3bdf Class: TypeParameters cluster_d6c41963 Class: Object cluster_dee0b47b Class: Alias cluster_a8a9ab29 Class: Class cluster_41d9e913 Class: Function node_1f867e48 1430: __init__() node_dd9b6f0c 2265: _update_target_aliases() node_1f867e48->node_dd9b6f0c node_eb885210 2249: _resolve_target() node_285962d4 2216: resolve_target() node_eb885210->node_285962d4 node_16d5990d 1639: as_json() node_16d5990d->node_16d5990d node_597401d4 1875: filter_members() node_597401d4->node_597401d4 node_7b7e8470 1862: has_labels() node_7b7e8470->node_7b7e8470 node_ee8b9901 1617: inherited_members() node_ee8b9901->node_1f867e48 node_64b1ee42 1775: is_kind() node_64b1ee42->node_64b1ee42 node_4217458e 1597: members() node_4217458e->node_1f867e48 node_dc9186f1 1558: parent() node_dc9186f1->node_dd9b6f0c node_f5157f36 1984: resolve() node_f5157f36->node_f5157f36 node_eab6dc28 2167: target() node_eab6dc28->node_285962d4 node_42b1343b 2549: _mro() node_42b1343b->node_42b1343b node_9514fc86 2560: mro() node_9514fc86->node_42b1343b node_6893c5b1 2497: parameters() node_a82ec239 364: __init__() node_6893c5b1->node_a82ec239 node_c43065c2 221: parse() node_cbe8341e 217: parsed() node_cbe8341e->node_c43065c2 node_b039ffd3 2590: __init__() node_b039ffd3->node_a82ec239 node_c4b1f0be 635: __init__() node_2d6103fd 544: __init__() node_c4b1f0be->node_2d6103fd node_65c6a4f3 798: _get_source_link() node_1edc1c6e 74: relative_source_filepath() node_65c6a4f3->node_1edc1c6e node_f350dd42 1308: as_dict() node_f350dd42->node_65c6a4f3 node_c1cb3b2c 63: __init__() node_f350dd42->node_c1cb3b2c node_b85820b6 889: inherited_members() node_b85820b6->node_1f867e48 node_62649f0a 1265: resolve() node_62649f0a->node_62649f0a node_7fafcd9e 794: source_link() node_7fafcd9e->node_65c6a4f3 node_cce1d904 330: as_dict() node_cce1d904->node_cce1d904

stats.py¤

This module contains utilities to compute loading statistics, like time spent visiting modules statically or dynamically.

G cluster_105f703e File: stats cluster_68256ccd Class: Stats node_6fd304fa 36: __init__() node_9ced7a76 90: _itercount() node_6fd304fa->node_9ced7a76 node_9ced7a76->node_9ced7a76