Skip to content

Project architectureΒ€

This document describes how the project is architectured, both regarding boilerplate and actual code. We start by giving an overview of the project's contents:

πŸ“ .git/
πŸ“ .github/ # (1)!
πŸ“ .venv/ # (2)!
πŸ“ .venvs/ # (3)!
πŸ“ .vscode/ # (4)!
πŸ“ config/ # (5)!
πŸ“ docs/ # (6)!
πŸ“ htmlcov/ # (7)!
πŸ“ packages/ # (8)!
πŸ“ scripts/ # (9)!
πŸ“ site/ # (10)!
πŸ“ tests/ # (11)!
 .copier-answers.yml # (12)!
 .envrc # (13)!
 .gitignore
 CHANGELOG.md
 CODE_OF_CONDUCT.md
 CONTRIBUTING.md
 LICENSE
 Makefile # (14)!
 README.md
 duties.py # (15)!
 logo.svg
 mkdocs.yml # (16)!
 pyproject.toml # (17)!
 uv.lock
  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
       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. Contains our tooling configuration. See Scripts, configuration.

    πŸ“ vscode/ # (1)!
     coverage.ini
     git-changelog.toml
     pytest.ini
     ruff.toml
     ty.toml
    
    1.  launch.json
       settings.json
       tasks.json
      
  6. Documentation sources (Markdown pages). See make docs task.

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

      πŸ“ partials/ # (1)!
       main.html
      
      1.  comments.html
         path-item.html
        
    2.  custom.css
       material.css
       mkdocstrings.css
      
    3. πŸ“ built-in/ # (1)!
      πŸ“ official/ # (2)!
      πŸ“ third-party/ # (3)!
       built-in.md
       official.md
       third-party.md
      
      1.  dataclasses.md
         unpack-typeddict.md
        
      2.  autodocstringstyle.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
         inherited-method-crossrefs.md
         modernized-annotations.md
        
    4. πŸ“ contributors/ # (1)!
      πŸ“ users/ # (2)!
       contributors.md
       users.md
      
      1.  architecture.md
         commands.md
         setup.md
         workflow.md
        
      2. πŸ“ how-to/ # (1)!
        πŸ“ recommendations/ # (2)!
         checking.md
         extending.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
          
    5.  favicon.ico
       gha_annotations_1.png
       gha_annotations_2.png
      
    6.  feedback.js
      
    7. πŸ“ api/ # (1)!
       api.md
       cli.md
       docstrings.md
      
      1. Python API reference, injected with mkdocstrings.

        πŸ“ docstrings/ # (1)!
        πŸ“ models/ # (2)!
         agents.md
         checks.md
         cli.md
         docstrings.md
         exceptions.md
         expressions.md
         extensions.md
         finder.md
         helpers.md
         loaders.md
         loggers.md
         models.md
         serializers.md
        
        1.  models.md
           parsers.md
          
        2.  alias.md
           attribute.md
           class.md
           function.md
           module.md
           type_alias.md
          
  7. HTML report for Python code coverage (git-ignored), integrated in the Coverage report page. See make coverage task.

  8. πŸ“ griffecli/ # (1)!
    πŸ“ griffelib/ # (2)!
    
    1. πŸ“ src/ # (1)!
       pyproject.toml
      
      1. πŸ“ griffecli/ # (1)!
        
        1. πŸ“ _internal/ # (1)!
           __init__.py
           __main__.py
          
          1.  __init__.py
             cli.py
            
    2. πŸ“ src/ # (1)!
       pyproject.toml
      
      1. πŸ“ griffe/ # (1)!
        
        1. πŸ“ _internal/ # (1)!
           __init__.py
           __main__.py
          
          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
             importer.py
             loader.py
             logger.py
             merger.py
             mixins.py
             models.py
             py.typed
             stats.py
             tests.py
            
            1. πŸ“ nodes/ # (1)!
               __init__.py
               inspector.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
              
  9. Our different scripts. See Scripts, configuration.

     gen_credits.py
     gen_griffe_json.py
     gen_structure_docs.py
     get_version.py
     make
     make.py
    
  10. Documentation site, built with make run mkdocs build (git-ignored).

  11. Our test suite. See Tests.

    πŸ“ fixtures/
    πŸ“ test_docstrings/ # (1)!
    πŸ“ test_extensions/ # (2)!
     __init__.py
     conftest.py
     helpers.py
     test_api.py
     test_cli.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_public_api.py
     test_stdlib.py
     test_visitor.py
    
    1.  __init__.py
       conftest.py
       helpers.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
      
  12. The answers file generated by Copier. See Boilerplate.

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

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

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

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

  17. The project metadata and production dependencies.

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 can also invoke what we call "tasks". Tasks need our development dependencies to be installed to run. These tasks are written in the duties.py file, and the development dependencies are listed in devdeps.txt.

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Β€

Our test suite is located in the tests folder. It is located outside of the sources as to not pollute distributions (it would be very wrong to publish a tests package as part of our distributions, since this name is extremely common), or worse, the public API. The tests folder is however included in our source distributions (.tar.gz), alongside most of our metadata and configuration files. Check out our pyproject.toml files to get the full list of files included in our source distributions for every individual package within the packages/ folder.

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_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_statsgriffe__internal_testsgriffe._internal.testsgriffe->griffe__internal_testsgriffecligriffecligriffe->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_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_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_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_modelsgriffe__internal_tests->griffe__internal_agentsgriffe__internal_tests->griffe__internal_agents_inspectorgriffe__internal_tests->griffe__internal_agents_visitorgriffe__internal_tests->griffe__internal_collectionsgriffe__internal_tests->griffe__internal_docstringsgriffe__internal_tests->griffe__internal_docstrings_parsersgriffe__internal_tests->griffe__internal_enumerationsgriffe__internal_tests->griffe__internal_extensionsgriffe__internal_tests->griffe__internal_extensions_basegriffe__internal_tests->griffe__internal_loadergriffe__internal_tests->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Β€

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_3e846097 File: inspector cluster_ba1045ad Class: Inspector node_0c3dd609 122: __init__() node_0c3dd609->node_0c3dd609 node_81f322c0 174: _get_docstring() node_bb7ccf38 196: _get_linenos() node_4a70efa7 262: generic_inspect() node_4a70efa7->node_0c3dd609 node_fb4c6935 254: inspect() node_4a70efa7->node_fb4c6935 node_dbc6cd29 299: inspect_module() node_4a70efa7->node_dbc6cd29 node_4a43bc15 206: get_module() node_4a43bc15->node_fb4c6935 node_8d1196cd 543: handle_attribute() node_8d1196cd->node_81f322c0 node_5d9cd6eb 444: handle_function() node_5d9cd6eb->node_81f322c0 node_5d9cd6eb->node_bb7ccf38 node_10a4885f 624: _convert_object_to_annotation() node_5d9cd6eb->node_10a4885f node_396223fc 601: _convert_parameter() node_5d9cd6eb->node_396223fc node_f46464a5 660: _convert_type_parameters() node_5d9cd6eb->node_f46464a5 node_a2c04b39 535: inspect_attribute() node_a2c04b39->node_8d1196cd node_cd59f5c7 404: inspect_builtin_function() node_cd59f5c7->node_5d9cd6eb node_4e360b5d 380: inspect_builtin_method() node_4e360b5d->node_5d9cd6eb node_816057b2 420: inspect_cached_property() node_816057b2->node_5d9cd6eb node_32db0548 322: inspect_class() node_32db0548->node_81f322c0 node_32db0548->node_bb7ccf38 node_32db0548->node_4a70efa7 node_32db0548->node_f46464a5 node_b9881bc0 364: inspect_classmethod() node_b9881bc0->node_5d9cd6eb node_52e0d358 396: inspect_coroutine() node_52e0d358->node_5d9cd6eb node_1d6465e5 412: inspect_function() node_1d6465e5->node_5d9cd6eb node_6bff5f8b 436: inspect_getset_descriptor() node_6bff5f8b->node_5d9cd6eb node_2c8f6782 388: inspect_method() node_2c8f6782->node_5d9cd6eb node_0139a778 372: inspect_method_descriptor() node_0139a778->node_5d9cd6eb node_dbc6cd29->node_81f322c0 node_323b62b6 428: inspect_property() node_323b62b6->node_5d9cd6eb node_33a33f8f 356: inspect_staticmethod() node_33a33f8f->node_5d9cd6eb node_2260f0cf 510: inspect_type_alias() node_2260f0cf->node_81f322c0 node_2260f0cf->node_bb7ccf38 node_2260f0cf->node_f46464a5 node_f09eb83d 703: _convert_type_to_annotation() node_2260f0cf->node_f09eb83d node_396223fc->node_10a4885f node_f46464a5->node_f09eb83d node_f09eb83d->node_10a4885f node_f09eb83d->node_f09eb83d node_c6ff4e0c 54: inspect() node_c6ff4e0c->node_0c3dd609 node_c6ff4e0c->node_4a43bc15
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_a46440a0 File: assignments node_7e9acbd6 43: _get_annassign_names() node_8e00cca4 26: get_name() node_7e9acbd6->node_8e00cca4 node_2cac7929 38: _get_assign_names() node_2cac7929->node_8e00cca4 node_e7af6c85 12: _get_attribute_name() node_e7af6c85->node_8e00cca4 node_72f3eedf 66: get_instance_names() node_9a4a995a 54: get_names() node_72f3eedf->node_9a4a995a
ast.pyΒ€

This module contains utilities for navigating AST nodes.

G cluster_f1cc8b19 File: ast node_f4afdd2d 26: ast_children() node_ca5b3e71 137: ast_first_child() node_ca5b3e71->node_f4afdd2d node_395eb0ed 155: ast_last_child() node_395eb0ed->node_f4afdd2d node_7337777c 119: ast_next() node_ce156c8a 66: ast_next_siblings() node_7337777c->node_ce156c8a node_ce156c8a->node_f4afdd2d node_c59abc21 100: ast_previous() node_f0acc7e9 50: ast_previous_siblings() node_c59abc21->node_f0acc7e9 node_f0acc7e9->node_f4afdd2d node_a4a9a75e 82: ast_siblings() node_a4a9a75e->node_f4afdd2d
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_da87b109 File: exports node_bedabaf0 61: _extract() node_4ccead1c 20: _extract_attribute() node_4ccead1c->node_bedabaf0 node_38e6c0e9 24: _extract_binop() node_38e6c0e9->node_bedabaf0 node_c368c07d 38: _extract_sequence() node_c368c07d->node_bedabaf0 node_feb25826 45: _extract_starred() node_feb25826->node_bedabaf0 node_9899e874 65: get__all__() node_9899e874->node_bedabaf0 node_11dc7035 80: safe_get__all__() node_11dc7035->node_9899e874
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_2ef16f0c File: runtime cluster_f8409926 Class: ObjectNode node_3766df11 52: __init__() node_0ed78efa 285: _pick_member() node_abb2d983 295: alias_target_path() node_6291af42 36: _same_components() node_abb2d983->node_6291af42 node_d87a3bec 175: children() node_d87a3bec->node_3766df11 node_d87a3bec->node_0ed78efa
values.pyΒ€

This module contains utilities for extracting attribute values.

G cluster_09b7ae11 File: values node_dcc5152b 15: get_value() node_aa4845ce 29: safe_get_value() node_aa4845ce->node_dcc5152b
visitor.pyΒ€

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

G cluster_3ebb3359 File: visitor cluster_2d39feed Class: Visitor node_a5cf27f9 137: __init__() node_a5cf27f9->node_a5cf27f9 node_224ffc6f 197: _get_docstring() node_a6dcc36a 217: _get_type_parameters() node_fc0d4bb7 353: decorators_to_labels() node_4caea19e 268: generic_visit() node_658cdd53 260: visit() node_4caea19e->node_658cdd53 node_cc2a9fd8 371: get_base_property() node_0d8d1fd2 246: get_module() node_0d8d1fd2->node_658cdd53 node_7559d0e2 613: handle_attribute() node_7559d0e2->node_224ffc6f node_4cebc1c4 395: handle_function() node_4cebc1c4->node_224ffc6f node_4cebc1c4->node_a6dcc36a node_4cebc1c4->node_fc0d4bb7 node_4cebc1c4->node_4caea19e node_4cebc1c4->node_cc2a9fd8 node_96252dcd 728: visit_annassign() node_96252dcd->node_7559d0e2 node_feca7300 720: visit_assign() node_feca7300->node_7559d0e2 node_0ee996a4 509: visit_asyncfunctiondef() node_0ee996a4->node_4cebc1c4 node_861caebc 300: visit_classdef() node_861caebc->node_224ffc6f node_861caebc->node_a6dcc36a node_861caebc->node_fc0d4bb7 node_861caebc->node_4caea19e node_a406c342 501: visit_functiondef() node_a406c342->node_4cebc1c4 node_3bdf7eb0 757: visit_if() node_3bdf7eb0->node_4caea19e node_a49c634e 277: visit_module() node_a49c634e->node_224ffc6f node_a49c634e->node_4caea19e node_b060e996 520: visit_typealias() node_b060e996->node_224ffc6f node_b060e996->node_a6dcc36a node_b2b93a23 80: visit() node_b2b93a23->node_a5cf27f9 node_b2b93a23->node_0d8d1fd2

c3linear.pyΒ€

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

G cluster_f97006c3 File: c3linear cluster_43a2cfd7 Class: _Dependency cluster_a30c844a Class: _DependencyList node_70fc1b25 29: tail() node_e7f0d636 60: __len__() node_70fc1b25->node_e7f0d636 node_e4de94ba 48: __init__() node_45107e72 64: __repr__() node_45107e72->node_45107e72 node_453c2918 82: remove() node_06ef15b5 93: c3linear_merge() node_06ef15b5->node_e4de94ba node_06ef15b5->node_453c2918

collections.pyΒ€

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

G cluster_103947fd File: collections cluster_3a7dbc7d Class: LinesCollection node_ba358696 56: items() node_ba358696->node_ba358696 node_1fa399b0 40: keys() node_1fa399b0->node_1fa399b0 node_8fb5cca5 48: values() node_8fb5cca5->node_8fb5cca5

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_857d3496 File: debug node_1174e4ba 80: _get_debug_info() node_a8f3c707 65: _get_version() node_1174e4ba->node_a8f3c707 node_1afa0433 54: _interpreter_name_version() node_1174e4ba->node_1afa0433 node_4f7d6f66 99: _print_debug_info() node_4f7d6f66->node_1174e4ba

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_832fcc5b File: diff cluster_1c313afe Class: Breakage node_54a3f114 261: _explain_github() node_9b3fb357 204: _format_new_value() node_54a3f114->node_9b3fb357 node_cc7b67a0 201: _format_old_value() node_54a3f114->node_cc7b67a0 node_88e0edaf 193: _format_title() node_54a3f114->node_88e0edaf node_7a6726dd 241: _explain_markdown() node_7a6726dd->node_9b3fb357 node_7a6726dd->node_cc7b67a0 node_04829a00 207: _explain_oneline() node_e016f16f 196: _format_kind() node_04829a00->node_e016f16f node_f3e17c6f 188: _format_location() node_04829a00->node_f3e17c6f node_04829a00->node_9b3fb357 node_04829a00->node_cc7b67a0 node_04829a00->node_88e0edaf node_7c9ab958 223: _explain_verbose() node_7c9ab958->node_e016f16f node_7c9ab958->node_f3e17c6f node_7c9ab958->node_9b3fb357 node_7c9ab958->node_cc7b67a0 node_7c9ab958->node_88e0edaf node_212062b3 562: _alias_incompatibilities() node_e78b67c9 599: _type_based_yield() node_212062b3->node_e78b67c9 node_275a5e60 553: _attribute_incompatibilities() node_e5e909b7 465: _class_incompatibilities() node_8354a07f 578: _member_incompatibilities() node_e5e909b7->node_8354a07f node_7dbe9cdb 478: _function_incompatibilities() node_236fb832 636: _returns_are_compatible() node_7dbe9cdb->node_236fb832 node_8354a07f->node_e78b67c9 node_e78b67c9->node_275a5e60 node_e78b67c9->node_e5e909b7 node_e78b67c9->node_7dbe9cdb node_7b25f0cd 660: find_breaking_changes() node_7b25f0cd->node_8354a07f

docstringsΒ€

These submodules define models and parsers for docstrings.

auto.pyΒ€

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

G cluster_4b3c58e5 File: auto node_8090f719 116: infer_docstring_style() node_2ea54ea7 188: parse_auto() node_2ea54ea7->node_8090f719
google.pyΒ€

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

G cluster_adfce502 File: google node_0a33911c 618: _annotation_from_parent() node_9496c459 587: _get_name_annotation_description() node_d5569494 834: _is_empty_line() node_706d04f2 346: _read_attributes_section() node_a55ad7a5 92: _read_block_items() node_706d04f2->node_a55ad7a5 node_913c62d3 156: _read_block() node_913c62d3->node_d5569494 node_a55ad7a5->node_d5569494 node_4464d319 574: _read_block_items_maybe() node_4464d319->node_913c62d3 node_4464d319->node_a55ad7a5 node_da698223 425: _read_classes_section() node_da698223->node_a55ad7a5 node_b2d48111 775: _read_examples_section() node_b2d48111->node_d5569494 node_b2d48111->node_913c62d3 node_9f717e4c 388: _read_functions_section() node_9f717e4c->node_a55ad7a5 node_72b18fbc 487: _read_modules_section() node_72b18fbc->node_a55ad7a5 node_49c7f0bf 266: _read_other_parameters_section() node_69262e8d 187: _read_parameters() node_49c7f0bf->node_69262e8d node_69262e8d->node_a55ad7a5 node_3a02d608 256: _read_parameters_section() node_3a02d608->node_69262e8d node_0a09966a 515: _read_raises_section() node_0a09966a->node_a55ad7a5 node_6a13e388 729: _read_receives_section() node_6a13e388->node_0a33911c node_6a13e388->node_9496c459 node_6a13e388->node_4464d319 node_8e8a3063 637: _read_returns_section() node_8e8a3063->node_0a33911c node_8e8a3063->node_9496c459 node_8e8a3063->node_4464d319 node_ce0a5bc2 462: _read_type_aliases_section() node_ce0a5bc2->node_a55ad7a5 node_e996e3be 277: _read_type_parameters_section() node_e996e3be->node_a55ad7a5 node_a9271c57 546: _read_warns_section() node_a9271c57->node_a55ad7a5 node_d45938d3 683: _read_yields_section() node_d45938d3->node_0a33911c node_d45938d3->node_9496c459 node_d45938d3->node_4464d319 node_5c2023c4 881: parse_google() node_5c2023c4->node_d5569494 node_5c2023c4->node_913c62d3
models.pyΒ€

This module contains the models for storing docstrings structured data.

G cluster_21b6f31a File: models cluster_a490c0fa Class: DocstringSection node_b6c57e55 246: as_dict() node_b6c57e55->node_b6c57e55
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_507ebe64 File: numpy node_7668a9e6 857: _append_section() node_a38a51e8 95: _is_dash_line() node_1fe05534 91: _is_empty_line() node_a38a51e8->node_1fe05534 node_c68d95dc 637: _read_attributes_section() node_3e363dc4 99: _read_block_items() node_c68d95dc->node_3e363dc4 node_ad205563 161: _read_block() node_ad205563->node_a38a51e8 node_ad205563->node_1fe05534 node_3e363dc4->node_a38a51e8 node_3e363dc4->node_1fe05534 node_e09b14f7 708: _read_classes_section() node_e09b14f7->node_3e363dc4 node_dc0387f0 404: _read_deprecated_section() node_dc0387f0->node_3e363dc4 node_e67ad867 792: _read_examples_section() node_e67ad867->node_1fe05534 node_e67ad867->node_ad205563 node_bd739349 676: _read_functions_section() node_bd739349->node_3e363dc4 node_1af0819a 760: _read_modules_section() node_1af0819a->node_3e363dc4 node_dc8c8f34 312: _read_other_parameters_section() node_5a3cc15d 223: _read_parameters() node_dc8c8f34->node_5a3cc15d node_5a3cc15d->node_3e363dc4 node_3a985a0e 297: _read_parameters_section() node_3a985a0e->node_5a3cc15d node_1b323f8c 587: _read_raises_section() node_1b323f8c->node_3e363dc4 node_4474eb02 540: _read_receives_section() node_4474eb02->node_3e363dc4 node_e8f0d7e2 430: _read_returns_section() node_e8f0d7e2->node_3e363dc4 node_3d3e1818 740: _read_type_aliases_section() node_3d3e1818->node_3e363dc4 node_bad693f8 334: _read_type_parameters_section() node_bad693f8->node_3e363dc4 node_3e58ca3a 612: _read_warns_section() node_3e58ca3a->node_3e363dc4 node_9ac1cd6a 489: _read_yields_section() node_9ac1cd6a->node_3e363dc4 node_8db7d47b 910: parse_numpy() node_8db7d47b->node_7668a9e6 node_8db7d47b->node_a38a51e8 node_8db7d47b->node_1fe05534
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_596184d9 File: sphinx cluster_8bfc60a4 Class: _FieldType node_ebe36942 52: matches() node_e13b70f7 457: _consolidate_continuation_lines() node_43dbe6d3 470: _consolidate_descriptive_type() node_180cc02e 209: _determine_param_annotation() node_fb6afa6b 202: _determine_param_default() node_a4194a4d 444: _parse_directive() node_a4194a4d->node_e13b70f7 node_b94f8cf8 428: _parsed_values_to_sections() node_5a6e8936 474: _strip_blank_lines() node_b94f8cf8->node_5a6e8936 node_f474bfa6 275: _read_attribute() node_f474bfa6->node_a4194a4d node_65ad45c2 322: _read_attribute_type() node_65ad45c2->node_43dbe6d3 node_65ad45c2->node_a4194a4d node_38dfddbb 352: _read_exception() node_38dfddbb->node_a4194a4d node_ab1d912d 139: _read_parameter() node_ab1d912d->node_180cc02e node_ab1d912d->node_fb6afa6b node_ab1d912d->node_a4194a4d node_d70d1cc5 244: _read_parameter_type() node_d70d1cc5->node_43dbe6d3 node_d70d1cc5->node_a4194a4d node_fd0e1543 373: _read_return() node_fd0e1543->node_a4194a4d node_74854e5a 407: _read_return_type() node_74854e5a->node_43dbe6d3 node_74854e5a->node_a4194a4d node_ee5b3102 98: parse_sphinx() node_ee5b3102->node_ebe36942 node_ee5b3102->node_b94f8cf8
utils.pyΒ€

This module contains utilities for docstrings parsers.

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_9d243967 File: encoders cluster_9bbf7527 Class: JSONEncoder node_719809e4 55: __init__() node_719809e4->node_719809e4 node_1eaae235 150: _attach_parent_to_expr() node_a47f314b 160: _attach_parent_to_exprs() node_a47f314b->node_1eaae235 node_34a6399a 274: _load_attribute() node_75cf9379 92: _load_docstring() node_34a6399a->node_75cf9379 node_4fb8fcf4 141: _load_git_info() node_34a6399a->node_4fb8fcf4 node_ac15a68b 224: _load_class() node_ac15a68b->node_a47f314b node_7452b029 98: _load_decorators() node_ac15a68b->node_7452b029 node_ac15a68b->node_75cf9379 node_ac15a68b->node_4fb8fcf4 node_5c374899 102: _load_expression() node_639e0998 252: _load_function() node_639e0998->node_7452b029 node_639e0998->node_75cf9379 node_639e0998->node_4fb8fcf4 node_4a9af869 197: _load_module() node_4a9af869->node_a47f314b node_4a9af869->node_75cf9379 node_4a9af869->node_4fb8fcf4 node_34a650a3 122: _load_parameter() node_34a650a3->node_75cf9379 node_03ac3083 309: _load_type_alias() node_03ac3083->node_75cf9379 node_03ac3083->node_4fb8fcf4 node_65593049 132: _load_type_parameter() node_3256416a 339: json_decoder() node_3256416a->node_5c374899 node_3256416a->node_34a650a3 node_3256416a->node_65593049

enumerations.pyΒ€

This module contains all the enumerations of the package.

exceptions.pyΒ€

This module contains all the exceptions specific to Griffe.

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_2c7f7314 File: expressions cluster_422c6714 Class: Expr cluster_17200427 Class: ExprAttribute cluster_76799cd1 Class: ExprBinOp cluster_66f3047d Class: ExprBoolOp cluster_4c6a04e3 Class: ExprCall cluster_40c9c125 Class: ExprCompare cluster_1fa8a982 Class: ExprComprehension cluster_de7c499d Class: ExprDict cluster_49c49fb0 Class: ExprDictComp cluster_818b8529 Class: ExprExtSlice cluster_09512d8f Class: ExprFormatted cluster_9d4fc6fa Class: ExprGeneratorExp cluster_adc3fa6f Class: ExprIfExp cluster_bda96a24 Class: ExprInterpolation cluster_ce1fa9f0 Class: ExprJoinedStr cluster_281884d5 Class: ExprKeyword cluster_334879d1 Class: ExprVarPositional cluster_27b23d0b Class: ExprVarKeyword cluster_fe60b03e Class: ExprLambda cluster_b4671c56 Class: ExprList cluster_9139d200 Class: ExprListComp cluster_4e7b87a5 Class: ExprNamedExpr cluster_9e5a106c Class: ExprSet cluster_bbece773 Class: ExprSetComp cluster_8bebab93 Class: ExprSlice cluster_c51b5d80 Class: ExprSubscript cluster_61292601 Class: ExprTemplateStr cluster_6eb5bc2c Class: ExprTuple cluster_61d8b51d Class: ExprUnaryOp cluster_6d57702e Class: ExprYield cluster_14382b03 Class: ExprYieldFrom node_026b6e19 168: __iter__() node_0a727d5e 172: iterate() node_026b6e19->node_0a727d5e node_9667f48e 165: __str__() node_9667f48e->node_0a727d5e node_d0620de0 255: _to_binop() node_d0620de0->node_d0620de0 node_cebaa717 201: as_dict() node_c99192a4 143: _expr_as_dict() node_cebaa717->node_c99192a4 node_7822d965 290: append() node_7822d965->node_7822d965 node_90f7fcfe 278: iterate() node_8e753062 1110: _get_precedence() node_90f7fcfe->node_8e753062 node_03dca6a5 66: _yield() node_90f7fcfe->node_03dca6a5 node_be0079b6 334: iterate() node_be0079b6->node_8e753062 node_be0079b6->node_03dca6a5 node_086f6670 354: iterate() node_086f6670->node_8e753062 node_086f6670->node_03dca6a5 node_a2047345 377: iterate() node_a2047345->node_8e753062 node_6531989b 109: _join() node_a2047345->node_6531989b node_a2047345->node_03dca6a5 node_e89fc145 395: iterate() node_e89fc145->node_8e753062 node_e89fc145->node_03dca6a5 node_281fa17b 416: iterate() node_281fa17b->node_6531989b node_281fa17b->node_03dca6a5 node_1e77b6a5 452: iterate() node_1e77b6a5->node_6531989b node_be03be35 473: iterate() node_be03be35->node_6531989b node_be03be35->node_03dca6a5 node_a3fb874a 490: iterate() node_a3fb874a->node_6531989b node_2c49bc76 501: iterate() node_2c49bc76->node_03dca6a5 node_41c2506e 517: iterate() node_41c2506e->node_6531989b node_41c2506e->node_03dca6a5 node_7948c641 534: iterate() node_7948c641->node_7948c641 node_7948c641->node_8e753062 node_7948c641->node_03dca6a5 node_c1c1f82e 559: iterate() node_c1c1f82e->node_03dca6a5 node_1fea2fc0 573: iterate() node_1fea2fc0->node_6531989b node_f988408f 613: iterate() node_f988408f->node_03dca6a5 node_0a5f7f36 652: iterate() node_0a5f7f36->node_03dca6a5 node_853b7847 693: iterate() node_853b7847->node_6531989b node_92e28488 708: iterate() node_92e28488->node_6531989b node_92e28488->node_03dca6a5 node_3db403c4 819: iterate() node_3db403c4->node_03dca6a5 node_862cfa32 846: iterate() node_862cfa32->node_6531989b node_bbe4ec8c 861: iterate() node_bbe4ec8c->node_6531989b node_bbe4ec8c->node_03dca6a5 node_3c0ff25a 880: iterate() node_3c0ff25a->node_03dca6a5 node_b6a0585a 900: iterate() node_b6a0585a->node_8e753062 node_b6a0585a->node_03dca6a5 node_6e22fdd6 907: modernize() node_6e22fdd6->node_d0620de0 node_6e22fdd6->node_6e22fdd6 node_923c372b 940: iterate() node_923c372b->node_6531989b node_26a8b539 955: iterate() node_26a8b539->node_6531989b node_3a2c2fba 980: iterate() node_3a2c2fba->node_8e753062 node_3a2c2fba->node_03dca6a5 node_55b811f7 638: iterate() node_55b811f7->node_03dca6a5 node_ed70c91a 626: iterate() node_ed70c91a->node_03dca6a5 node_6abe2ffe 994: iterate() node_6abe2ffe->node_03dca6a5 node_a64e45f1 1008: iterate() node_a64e45f1->node_03dca6a5 node_ecdb8334 1420: _build() node_406cb0f0 1114: _build_attribute() node_406cb0f0->node_7822d965 node_406cb0f0->node_ecdb8334 node_3da4c11b 1126: _build_binop() node_3da4c11b->node_ecdb8334 node_982d1900 1134: _build_boolop() node_982d1900->node_ecdb8334 node_470feb9a 1141: _build_call() node_470feb9a->node_ecdb8334 node_c26360a2 1148: _build_compare() node_c26360a2->node_ecdb8334 node_0d71f0e7 1156: _build_comprehension() node_0d71f0e7->node_ecdb8334 node_aa1cccb8 1165: _build_constant() node_aa1cccb8->node_ecdb8334 node_9e9f8662 1204: _build_dict() node_9e9f8662->node_ecdb8334 node_192eea85 1211: _build_dictcomp() node_192eea85->node_ecdb8334 node_64ee12e6 1219: _build_formatted() node_64ee12e6->node_ecdb8334 node_99423c19 1229: _build_generatorexp() node_99423c19->node_ecdb8334 node_3c83c66e 1236: _build_ifexp() node_3c83c66e->node_ecdb8334 node_ed08541b 1402: _build_interpolation() node_ed08541b->node_ecdb8334 node_148fd7b6 1244: _build_joinedstr() node_148fd7b6->node_ecdb8334 node_5b0d1882 1254: _build_keyword() node_5b0d1882->node_ecdb8334 node_aa18f123 1260: _build_lambda() node_aa18f123->node_ecdb8334 node_a5f6272d 1454: safe_get_expression() node_aa18f123->node_a5f6272d node_03b6e0f2 1277: _build_list() node_03b6e0f2->node_ecdb8334 node_36639057 1281: _build_listcomp() node_36639057->node_ecdb8334 node_234feaa3 1289: _build_named_expr() node_234feaa3->node_ecdb8334 node_b3aa6d2c 1293: _build_set() node_b3aa6d2c->node_ecdb8334 node_d7afea42 1297: _build_setcomp() node_d7afea42->node_ecdb8334 node_1611280e 1301: _build_slice() node_1611280e->node_ecdb8334 node_998dc33c 1309: _build_starred() node_998dc33c->node_ecdb8334 node_c4668200 1313: _build_subscript() node_c4668200->node_ecdb8334 node_cba8f824 1405: _build_templatestr() node_cba8f824->node_ecdb8334 node_0c05ba73 1342: _build_tuple() node_0c05ba73->node_ecdb8334 node_bd37aa6f 1353: _build_unaryop() node_bd37aa6f->node_ecdb8334 node_cc72aac3 1357: _build_yield() node_cc72aac3->node_ecdb8334 node_82aca951 1361: _build_yield_from() node_82aca951->node_ecdb8334 node_d7d364b8 132: _field_as_dict() node_c99192a4->node_d7d364b8 node_d7d364b8->node_d7d364b8 node_6531989b->node_03dca6a5 node_03dca6a5->node_8e753062 node_03dca6a5->node_03dca6a5 node_ba3d6786 1424: get_expression() node_ba3d6786->node_ecdb8334 node_a5f6272d->node_ba3d6786

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_f23416fc File: base cluster_b4691da3 Class: Extension cluster_d4e9c519 Class: Extensions node_91c56e13 56: generic_inspect() node_b9137810 48: inspect() node_91c56e13->node_b9137810 node_3420e96c 39: generic_visit() node_7f74efff 31: visit() node_3420e96c->node_7f74efff node_f131a72e 411: on_alias() node_c877c4ab 387: on_alias_instance() node_c877c4ab->node_f131a72e node_51fc3b82 445: __init__() node_bde89ac6 454: add() node_51fc3b82->node_bde89ac6 node_2b299f26 495: _load_extension() node_0ac19630 484: _load_extension_path() node_2b299f26->node_0ac19630 node_a11ab1b4 586: load_extensions() node_a11ab1b4->node_51fc3b82 node_a11ab1b4->node_bde89ac6 node_a11ab1b4->node_2b299f26
dataclasses.pyΒ€

Built-in extension adding support for dataclasses.

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

G cluster_3191eaaa File: dataclasses cluster_8e426a5b Class: DataclassesExtension node_b8464813 227: on_package() node_c4d566f1 203: _apply_recursively() node_b8464813->node_c4d566f1 node_c4d566f1->node_c4d566f1 node_3d125997 195: _del_members_annotated_as_initvar() node_c4d566f1->node_3d125997 node_fca04690 157: _set_dataclass_init() node_c4d566f1->node_fca04690 node_418a177e 49: _dataclass_arguments() node_c0fb050f 25: _dataclass_decorator() node_418a177e->node_c0fb050f node_bf59f38c 32: _expr_args() node_418a177e->node_bf59f38c node_02ef238d 66: _dataclass_parameters() node_02ef238d->node_418a177e node_1bc932a3 55: _field_arguments() node_02ef238d->node_1bc932a3 node_bf59f38c->node_bf59f38c node_1bc932a3->node_bf59f38c node_a299dd03 139: _reorder_parameters() node_fca04690->node_c0fb050f node_fca04690->node_02ef238d node_fca04690->node_a299dd03
unpack_typeddict.pyΒ€

Todo

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

G cluster_e7992d1e File: unpack_typeddict cluster_955bc249 Class: UnpackTypedDictExtension node_4068c0dd 191: on_class() node_a75956ef 65: _get_or_set_attrs() node_4068c0dd->node_a75956ef node_0a1d3633 170: _params_from_attrs() node_4068c0dd->node_0a1d3633 node_dd61c198 109: _update_docstring() node_4068c0dd->node_dd61c198 node_6300a310 218: on_function() node_6300a310->node_a75956ef node_6300a310->node_0a1d3633 node_6300a310->node_dd61c198 node_ad70b7ef 29: _unwrap_annotation() node_a75956ef->node_ad70b7ef

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_413d56d6 File: finder cluster_e091929c Class: ModuleFinder node_b5c51a02 102: __init__() node_4af6ae5a 384: _extend_from_pth_files() node_b5c51a02->node_4af6ae5a node_3a4167fa 119: append_search_path() node_b5c51a02->node_3a4167fa node_77b2a48a 130: _append_search_path() node_df38ede6 376: _contents() node_4af6ae5a->node_df38ede6 node_4af6ae5a->node_3a4167fa node_91d85c52 440: _handle_pth_file() node_4af6ae5a->node_91d85c52 node_fec70e19 393: _filter_py_modules() node_c2dd561a 361: _module_name_path() node_6e5e79c8 401: _top_module_name() node_d5d6ffd2 134: insert_search_path() node_6e5e79c8->node_d5d6ffd2 node_3a4167fa->node_77b2a48a node_acca632c 231: find_package() node_acca632c->node_df38ede6 node_9ca512f1 425: _is_pkg_style_namespace() node_acca632c->node_9ca512f1 node_2f73e17a 148: find_spec() node_2f73e17a->node_c2dd561a node_2f73e17a->node_6e5e79c8 node_2f73e17a->node_acca632c node_5e16de80 278: iter_submodules() node_5e16de80->node_fec70e19 node_5e16de80->node_5e16de80 node_a378e7ba 344: submodules() node_a378e7ba->node_5e16de80 node_8bf15493 470: _handle_editable_module() node_7c58d57a 51: _match_pattern() node_8bf15493->node_7c58d57a node_91d85c52->node_8bf15493

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_ffb571ce File: git cluster_1b22b79e Class: GitInfo node_5fcdc53c 241: from_package() node_dd46f0f2 217: _get_git_commit_hash() node_5fcdc53c->node_dd46f0f2 node_a4759050 163: _get_git_known_service() node_5fcdc53c->node_a4759050 node_c181f083 137: _get_git_remote_url() node_5fcdc53c->node_c181f083 node_7d775887 87: _get_repo_root() node_5fcdc53c->node_7d775887 node_c222c7de 223: _is_tracked() node_5fcdc53c->node_c222c7de node_cb924039 265: get_source_link() node_43cf00ee 204: _get_source_link() node_cb924039->node_43cf00ee node_4786f069 50: _assert_git_repo() node_9e45e0ac 36: _git() node_4786f069->node_9e45e0ac node_dd46f0f2->node_9e45e0ac node_c181f083->node_9e45e0ac node_e635e6ae 67: _get_latest_tag() node_e635e6ae->node_9e45e0ac node_7d775887->node_9e45e0ac node_c222c7de->node_9e45e0ac node_8eaacff8 30: _normalize() node_2a6ff856 104: _tmp_worktree() node_2a6ff856->node_4786f069 node_2a6ff856->node_9e45e0ac node_2a6ff856->node_8eaacff8

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_f6ca0656 File: importer node_e784de8d 17: _error_details() node_92e9758d 43: dynamic_import() node_92e9758d->node_e784de8d node_6946d917 22: sys_path() node_92e9758d->node_6946d917

loader.pyΒ€

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

G cluster_8d534fd8 File: loader cluster_62e86d4f Class: GriffeLoader node_22f5e7df 53: __init__() node_d8a806d1 653: _create_module() node_aec8177f 738: _expand_wildcard() node_969098c8 197: _fire_load_events() node_969098c8->node_969098c8 node_fe0fb632 708: _get_or_create_parent_module() node_fe0fb632->node_d8a806d1 node_20af02bd 681: _inspect_module() node_f8f707f2 554: _load_module() node_11f10c38 573: _load_module_path() node_f8f707f2->node_11f10c38 node_11f10c38->node_d8a806d1 node_11f10c38->node_20af02bd node_813597c1 598: _load_submodules() node_11f10c38->node_813597c1 node_5a0ae4df 661: _visit_module() node_11f10c38->node_5a0ae4df node_c3789dd9 539: _load_package() node_c3789dd9->node_f8f707f2 node_7ec468af 334: expand_wildcards() node_c3789dd9->node_7ec468af node_638bc240 602: _load_submodule() node_638bc240->node_fe0fb632 node_638bc240->node_f8f707f2 node_813597c1->node_638bc240 node_4d60bd53 216: _post_load() node_4d60bd53->node_969098c8 node_7ab217c2 293: expand_exports() node_4d60bd53->node_7ab217c2 node_4d60bd53->node_7ec468af node_7ab217c2->node_7ab217c2 node_7ec468af->node_aec8177f node_7ec468af->node_7ec468af node_0c092474 105: load() node_7ec468af->node_0c092474 node_0c092474->node_20af02bd node_0c092474->node_c3789dd9 node_0c092474->node_4d60bd53 node_cfaac9fe 237: resolve_aliases() node_cfaac9fe->node_7ec468af node_81f2a84f 450: resolve_module_aliases() node_cfaac9fe->node_81f2a84f node_81f2a84f->node_0c092474 node_81f2a84f->node_81f2a84f node_9c64fe9c 747: load() node_9c64fe9c->node_22f5e7df node_9c64fe9c->node_0c092474 node_9c64fe9c->node_cfaac9fe node_61a09a2c 852: load_git() node_61a09a2c->node_9c64fe9c node_1afcfc5e 937: load_pypi() node_1afcfc5e->node_9c64fe9c

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_ae6f9be6 File: logger cluster_1b32f80a Class: Logger node_9bc2f416 0: (global)() node_d4886ff6 43: _get() node_9bc2f416->node_d4886ff6 node_19d945a6 49: _patch_loggers() node_c01bdf6d 93: get_logger() node_c01bdf6d->node_d4886ff6 node_4fc8e4cd 105: patch_loggers() node_4fc8e4cd->node_19d945a6

merger.pyΒ€

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

G cluster_f9e46538 File: merger node_60921bfc 70: _merge_annotations() node_c8aa26e1 40: _merge_attribute_stubs() node_5053c55c 52: _merge_stubs_docstring() node_c8aa26e1->node_5053c55c node_67028fe7 24: _merge_class_stubs() node_67028fe7->node_5053c55c node_d0ee800a 103: _merge_stubs_members() node_67028fe7->node_d0ee800a node_6faea694 62: _merge_stubs_overloads() node_67028fe7->node_6faea694 node_7375ad97 57: _merge_stubs_type_parameters() node_67028fe7->node_7375ad97 node_28baecc7 31: _merge_function_stubs() node_28baecc7->node_5053c55c node_28baecc7->node_7375ad97 node_71c910b4 18: _merge_module_stubs() node_71c910b4->node_5053c55c node_71c910b4->node_d0ee800a node_71c910b4->node_6faea694 node_20918f1a 78: _merge_overload_annotations() node_20918f1a->node_60921bfc node_d0ee800a->node_c8aa26e1 node_d0ee800a->node_28baecc7 node_feb9ae52 47: _merge_type_alias_stubs() node_d0ee800a->node_feb9ae52 node_6faea694->node_20918f1a node_feb9ae52->node_5053c55c node_feb9ae52->node_7375ad97 node_80fe6cd5 147: merge_stubs() node_80fe6cd5->node_71c910b4

mixins.pyΒ€

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

G cluster_8daeee79 File: mixins cluster_10fdd2db Class: GetMembersMixin cluster_a9731a87 Class: DelMembersMixin cluster_7c58f83b Class: SetMembersMixin node_3e03bc0d 87: __delitem__() node_a9e2f41d 22: _get_parts() node_3e03bc0d->node_a9e2f41d node_edf783ee 114: del_member() node_edf783ee->node_edf783ee node_edf783ee->node_a9e2f41d node_6822996c 37: __getitem__() node_6822996c->node_a9e2f41d node_7ebfba96 59: get_member() node_7ebfba96->node_7ebfba96 node_7ebfba96->node_a9e2f41d node_4cc72bbe 142: __setitem__() node_4cc72bbe->node_a9e2f41d node_50219504 168: set_member() node_50219504->node_50219504 node_50219504->node_a9e2f41d

models.pyΒ€

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

G cluster_a468dda5 File: models cluster_b50b4c3e Class: Docstring cluster_b9ec30af Class: Parameter cluster_0c91015e Class: Parameters cluster_e9efcc60 Class: TypeParameters cluster_293c40ce Class: Object cluster_021fc967 Class: Alias cluster_76c4d823 Class: Class cluster_58c4c1bf Class: Function node_bed12eb4 1350: __init__() node_46090f4e 2163: _update_target_aliases() node_bed12eb4->node_46090f4e node_be258dcd 2147: _resolve_target() node_aa6de2f1 2114: resolve_target() node_be258dcd->node_aa6de2f1 node_3787ee20 1541: as_json() node_3787ee20->node_3787ee20 node_4ed3c63d 1773: filter_members() node_4ed3c63d->node_4ed3c63d node_93d03a0b 1760: has_labels() node_93d03a0b->node_93d03a0b node_0972d041 1519: inherited_members() node_0972d041->node_bed12eb4 node_55ba5f4d 1673: is_kind() node_55ba5f4d->node_55ba5f4d node_72936655 1499: members() node_72936655->node_bed12eb4 node_3dfe07e3 1480: parent() node_3dfe07e3->node_46090f4e node_1c39e294 1882: resolve() node_1c39e294->node_1c39e294 node_690cc786 2065: target() node_690cc786->node_aa6de2f1 node_48282515 2447: _mro() node_48282515->node_48282515 node_b15ffb5a 2458: mro() node_b15ffb5a->node_48282515 node_03426269 2395: parameters() node_c7ab54a4 308: __init__() node_03426269->node_c7ab54a4 node_679e6c0a 165: parse() node_44fe75b8 161: parsed() node_44fe75b8->node_679e6c0a node_a94fd09e 2488: __init__() node_a94fd09e->node_c7ab54a4 node_3f7539f2 579: __init__() node_020e5bb4 488: __init__() node_3f7539f2->node_020e5bb4 node_b051c1e1 821: inherited_members() node_b051c1e1->node_bed12eb4 node_00b3e0de 1197: resolve() node_00b3e0de->node_00b3e0de node_bcd9290d 274: as_dict() node_bcd9290d->node_bcd9290d

stats.pyΒ€

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

G cluster_d8d4776e File: stats cluster_5717b378 Class: Stats node_6afdf5c7 20: __init__() node_20db8cde 74: _itercount() node_6afdf5c7->node_20db8cde node_20db8cde->node_20db8cde

tests.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_6fb040e7 File: tests node_d4546ea8 403: module_vtree() node_70547391 360: vtree() node_d4546ea8->node_70547391 node_fe4cba4d 309: temporary_inspected_module() node_82b6d316 54: temporary_pyfile() node_fe4cba4d->node_82b6d316 node_132cb2d7 189: temporary_inspected_package() node_ba44993b 72: temporary_pypackage() node_132cb2d7->node_ba44993b node_7531c3e6 263: temporary_visited_module() node_7531c3e6->node_82b6d316 node_99d2d70f 121: temporary_visited_package() node_99d2d70f->node_ba44993b