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)!
πŸ“ scripts/ # (8)!
πŸ“ site/ # (9)!
πŸ“ src/ # (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
    
    1.  1-bug.md
       2-feature.md
       3-docs.md
       4-change.md
       config.yml
      
    2.  ci.yml
       release.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.

     launch.json
     settings.json
     tasks.json
    
  5. Contains our tooling configuration. See Scripts, configuration.

    πŸ“ vscode/ # (1)!
     coverage.ini
     git-changelog.toml
     mypy.ini
     pytest.ini
     ruff.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)!
    πŸ“ insiders/ # (6)!
    πŸ“ js/ # (7)!
    πŸ“ reference/ # (8)!
     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
       insiders.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
        
      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.  changelog.md
       goals.yml
       index.md
       installation.md
      
    7.  feedback.js
       insiders.js
      
    8. πŸ“ 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
         git.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. Our different scripts. See Scripts, configuration.

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

  10. The source of our Python package(s). See Sources and Program structure.

    πŸ“ griffe/ # (1)!
    
    1. Our public API, exposed to users. 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
         cli.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
          
  11. Our test suite. See Tests.

    πŸ“ fixtures/
    πŸ“ test_docstrings/ # (1)!
     __init__.py
     conftest.py
     helpers.py
     test_api.py
     test_cli.py
     test_diff.py
     test_encoders.py
     test_expressions.py
     test_extensions.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
      
  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 src folder, following the src-layout. We use PDM-Backend to build source and wheel distributions, and configure it in pyproject.toml to search for packages in the src folder.

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 pyproject.toml to get the full list of files included in our source distributions.

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

The internal API is contained within the src/griffe/_internal folder. The top-level griffe/__init__.py module exposes all the public API, by importing the internal objects from various submodules of griffe._internal.

Users then import griffe directly, or import objects from it.

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.

Gcoloramacoloramagriffegriffegriffe__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_cligriffe._internal.cligriffe->griffe__internal_cligriffe__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_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_testsgriffe___main__griffe.__main__griffe___main__->griffe__internalgriffe___main__->griffe__internal_cligriffe__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_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_cli->coloramagriffe__internal_debuggriffe._internal.debuggriffe__internal_cli->griffe__internal_debuggriffe__internal_cli->griffe__internal_diffgriffe__internal_cli->griffe__internal_docstringsgriffe__internal_cli->griffe__internal_docstrings_parsersgriffe__internal_cli->griffe__internal_encodersgriffe__internal_cli->griffe__internal_enumerationsgriffe__internal_cli->griffe__internal_exceptionsgriffe__internal_cli->griffe__internal_extensionsgriffe__internal_cli->griffe__internal_extensions_basegriffe__internal_cli->griffe__internal_gitgriffe__internal_cli->griffe__internal_loadergriffe__internal_cli->griffe__internal_loggergriffe__internal_collections->griffe__internal_mixinsgriffe__internal_diff->coloramagriffe__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_extensions_base->griffe__internal_agentsgriffe__internal_extensions_base->griffe__internal_agents_inspectorgriffe__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_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_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_models->griffe__internal_c3lineargriffe__internal_models->griffe__internal_collectionsgriffe__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_expressionsgriffe__internal_models->griffe__internal_gitgriffe__internal_models->griffe__internal_loggergriffe__internal_models->griffe__internal_mixinsgriffe__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__Β€

Entry-point module, in case you use python -m griffe.

Why does this file exist, and why __main__? For more info, read:

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_8901c2a1 File: inspector cluster_7099affb Class: Inspector node_89cb252b 123: __init__() node_89cb252b->node_89cb252b node_93146dee 175: _get_docstring() node_0e896323 197: _get_linenos() node_c88723e9 263: generic_inspect() node_c88723e9->node_89cb252b node_942b9819 255: inspect() node_c88723e9->node_942b9819 node_8126850e 300: inspect_module() node_c88723e9->node_8126850e node_0bfa14d3 207: get_module() node_0bfa14d3->node_942b9819 node_45960148 544: handle_attribute() node_45960148->node_93146dee node_4e69a1c1 445: handle_function() node_4e69a1c1->node_93146dee node_4e69a1c1->node_0e896323 node_d47c7d64 625: _convert_object_to_annotation() node_4e69a1c1->node_d47c7d64 node_a21d36ea 602: _convert_parameter() node_4e69a1c1->node_a21d36ea node_46b23ff3 661: _convert_type_parameters() node_4e69a1c1->node_46b23ff3 node_6433649c 536: inspect_attribute() node_6433649c->node_45960148 node_cc5361a1 405: inspect_builtin_function() node_cc5361a1->node_4e69a1c1 node_157af6d1 381: inspect_builtin_method() node_157af6d1->node_4e69a1c1 node_5badd69b 421: inspect_cached_property() node_5badd69b->node_4e69a1c1 node_0310909c 323: inspect_class() node_0310909c->node_93146dee node_0310909c->node_0e896323 node_0310909c->node_c88723e9 node_0310909c->node_46b23ff3 node_9c69b6d4 365: inspect_classmethod() node_9c69b6d4->node_4e69a1c1 node_8e5298f6 397: inspect_coroutine() node_8e5298f6->node_4e69a1c1 node_8c5e622e 413: inspect_function() node_8c5e622e->node_4e69a1c1 node_ed73a925 437: inspect_getset_descriptor() node_ed73a925->node_4e69a1c1 node_5cf1edd5 389: inspect_method() node_5cf1edd5->node_4e69a1c1 node_cc64aa43 373: inspect_method_descriptor() node_cc64aa43->node_4e69a1c1 node_8126850e->node_93146dee node_a1d04fa4 429: inspect_property() node_a1d04fa4->node_4e69a1c1 node_e7ca9fdb 357: inspect_staticmethod() node_e7ca9fdb->node_4e69a1c1 node_e287b470 511: inspect_type_alias() node_e287b470->node_93146dee node_e287b470->node_0e896323 node_e287b470->node_46b23ff3 node_bc3ffa85 704: _convert_type_to_annotation() node_e287b470->node_bc3ffa85 node_a21d36ea->node_d47c7d64 node_46b23ff3->node_bc3ffa85 node_bc3ffa85->node_d47c7d64 node_bc3ffa85->node_bc3ffa85 node_2b4bcfbf 55: inspect() node_2b4bcfbf->node_89cb252b node_2b4bcfbf->node_0bfa14d3
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_5502f25b File: assignments node_221815eb 40: _get_annassign_names() node_b90183e7 23: get_name() node_221815eb->node_b90183e7 node_7234f6ee 35: _get_assign_names() node_7234f6ee->node_b90183e7 node_4bb9b57c 9: _get_attribute_name() node_4bb9b57c->node_b90183e7 node_b00e7281 63: get_instance_names() node_93ce87d3 51: get_names() node_b00e7281->node_93ce87d3
ast.pyΒ€

This module contains utilities for navigating AST nodes.

G cluster_5a6c77e0 File: ast node_df38cce8 26: ast_children() node_99220e7d 137: ast_first_child() node_99220e7d->node_df38cce8 node_83a2c352 155: ast_last_child() node_83a2c352->node_df38cce8 node_916cbb1a 119: ast_next() node_c40b65cb 66: ast_next_siblings() node_916cbb1a->node_c40b65cb node_c40b65cb->node_df38cce8 node_2ae026fe 100: ast_previous() node_c1ebc772 50: ast_previous_siblings() node_2ae026fe->node_c1ebc772 node_c1ebc772->node_df38cce8 node_dd4c681e 82: ast_siblings() node_dd4c681e->node_df38cce8
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_3cca06a5 File: exports node_a01c3fd5 74: _extract() node_4a9a13e1 33: _extract_attribute() node_4a9a13e1->node_a01c3fd5 node_4d8ad8ef 37: _extract_binop() node_4d8ad8ef->node_a01c3fd5 node_9a41b136 51: _extract_sequence() node_9a41b136->node_a01c3fd5 node_6ad49be4 58: _extract_starred() node_6ad49be4->node_a01c3fd5 node_5e20ceb6 78: get__all__() node_5e20ceb6->node_a01c3fd5 node_e4be7ac3 93: safe_get__all__() node_e4be7ac3->node_5e20ceb6
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_c9f99c0a File: runtime cluster_19f242c5 Class: ObjectNode node_00d27843 52: __init__() node_15785b30 264: _pick_member() node_5e021ee5 274: alias_target_path() node_2452c62b 36: _same_components() node_5e021ee5->node_2452c62b node_a6e24523 154: children() node_a6e24523->node_00d27843 node_a6e24523->node_15785b30
values.pyΒ€

This module contains utilities for extracting attribute values.

G cluster_690988fc File: values node_e0366d90 15: get_value() node_88029934 29: safe_get_value() node_88029934->node_e0366d90
visitor.pyΒ€

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

G cluster_d29a1ea9 File: visitor cluster_84349a03 Class: Visitor node_eec9c493 136: __init__() node_eec9c493->node_eec9c493 node_9dead57b 196: _get_docstring() node_8d95295b 216: _get_type_parameters() node_99261e2c 348: decorators_to_labels() node_aaec721a 267: generic_visit() node_f0467d8d 259: visit() node_aaec721a->node_f0467d8d node_f6897753 366: get_base_property() node_ef935879 245: get_module() node_ef935879->node_f0467d8d node_2a12ca93 608: handle_attribute() node_2a12ca93->node_9dead57b node_694c0b07 390: handle_function() node_694c0b07->node_9dead57b node_694c0b07->node_8d95295b node_694c0b07->node_99261e2c node_694c0b07->node_aaec721a node_694c0b07->node_f6897753 node_9bf0b40b 723: visit_annassign() node_9bf0b40b->node_2a12ca93 node_91a4a4ce 715: visit_assign() node_91a4a4ce->node_2a12ca93 node_dd3a0b79 504: visit_asyncfunctiondef() node_dd3a0b79->node_694c0b07 node_7b6a453e 299: visit_classdef() node_7b6a453e->node_9dead57b node_7b6a453e->node_8d95295b node_7b6a453e->node_99261e2c node_7b6a453e->node_aaec721a node_7836a8a1 496: visit_functiondef() node_7836a8a1->node_694c0b07 node_6e3d58c4 752: visit_if() node_6e3d58c4->node_aaec721a node_4f657920 276: visit_module() node_4f657920->node_9dead57b node_4f657920->node_aaec721a node_0aa74ca5 515: visit_typealias() node_0aa74ca5->node_9dead57b node_0aa74ca5->node_8d95295b node_7414e8e6 79: visit() node_7414e8e6->node_eec9c493 node_7414e8e6->node_ef935879

c3linear.pyΒ€

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

G cluster_bd52cf4a File: c3linear cluster_21575a74 Class: _Dependency cluster_767f4607 Class: _DependencyList node_e8ac1afe 29: tail() node_7d8e4a09 60: __len__() node_e8ac1afe->node_7d8e4a09 node_42e566de 48: __init__() node_3ec08b39 64: __repr__() node_3ec08b39->node_3ec08b39 node_283b66c0 82: remove() node_9bd080e4 93: c3linear_merge() node_9bd080e4->node_42e566de node_9bd080e4->node_283b66c0

cli.pyΒ€

This module contains all CLI-related things. Why does this file exist, and why not put this in __main__?

We might be tempted to import things from __main__ later, but that will cause problems; the code will get executed twice:

  • When we run python -m griffe, Python will execute __main__.py as a script. That means there won't be any griffe.__main__ in sys.modules.
  • When you import __main__ it will get executed again (as a module) because there's no griffe.__main__ in sys.modules.
G cluster_f420fbdc File: cli cluster_78c7a239 Class: _DebugInfo node_84421a80 52: __init__() node_84421a80->node_84421a80 node_a9d4fa65 70: _load_packages() node_8441a7cd 60: _print_data() node_99b9eabf 332: dump() node_99b9eabf->node_a9d4fa65 node_99b9eabf->node_8441a7cd node_e3df4209 131: get_parser() node_322198c6 577: main() node_322198c6->node_e3df4209

collections.pyΒ€

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

G cluster_edeba50e File: collections cluster_8dd2414c Class: LinesCollection node_5e9efc68 56: items() node_5e9efc68->node_5e9efc68 node_6125b24b 40: keys() node_6125b24b->node_6125b24b node_673d8715 48: values() node_673d8715->node_673d8715

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_7320d925 File: debug node_d423229c 80: _get_debug_info() node_323ae982 65: _get_version() node_d423229c->node_323ae982 node_b1178863 54: _interpreter_name_version() node_d423229c->node_b1178863 node_bce4bf6b 99: _print_debug_info() node_bce4bf6b->node_d423229c

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_2ccc4934 File: diff cluster_c90ab14f Class: Breakage node_63a594af 221: _explain_github() node_28d1370a 164: _format_new_value() node_63a594af->node_28d1370a node_8c10da57 161: _format_old_value() node_63a594af->node_8c10da57 node_8e130fec 153: _format_title() node_63a594af->node_8e130fec node_af9c6947 201: _explain_markdown() node_af9c6947->node_28d1370a node_af9c6947->node_8c10da57 node_00b5b177 167: _explain_oneline() node_8d06457c 156: _format_kind() node_00b5b177->node_8d06457c node_e2a5b163 148: _format_location() node_00b5b177->node_e2a5b163 node_00b5b177->node_28d1370a node_00b5b177->node_8c10da57 node_00b5b177->node_8e130fec node_04196f0d 183: _explain_verbose() node_04196f0d->node_8d06457c node_04196f0d->node_e2a5b163 node_04196f0d->node_28d1370a node_04196f0d->node_8c10da57 node_04196f0d->node_8e130fec node_af08d6c4 522: _alias_incompatibilities() node_1bae9d75 559: _type_based_yield() node_af08d6c4->node_1bae9d75 node_182cd138 513: _attribute_incompatibilities() node_fe11a2e9 425: _class_incompatibilities() node_eed2e5d5 538: _member_incompatibilities() node_fe11a2e9->node_eed2e5d5 node_6a1e7ee2 438: _function_incompatibilities() node_9afd8590 596: _returns_are_compatible() node_6a1e7ee2->node_9afd8590 node_eed2e5d5->node_1bae9d75 node_1bae9d75->node_182cd138 node_1bae9d75->node_fe11a2e9 node_1bae9d75->node_6a1e7ee2 node_7b383255 620: find_breaking_changes() node_7b383255->node_eed2e5d5

docstringsΒ€

These submodules define models and parsers for docstrings.

auto.pyΒ€

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

G cluster_5e291386 File: auto node_b0f8205e 117: infer_docstring_style() node_bafe12bd 206: parse_auto() node_bafe12bd->node_b0f8205e
google.pyΒ€

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

G cluster_fbb28231 File: google node_462c9e2d 619: _annotation_from_parent() node_482e82da 588: _get_name_annotation_description() node_8be58605 835: _is_empty_line() node_1ca40f1d 347: _read_attributes_section() node_3166ec40 93: _read_block_items() node_1ca40f1d->node_3166ec40 node_df448740 157: _read_block() node_df448740->node_8be58605 node_3166ec40->node_8be58605 node_56dbfc8b 575: _read_block_items_maybe() node_56dbfc8b->node_df448740 node_56dbfc8b->node_3166ec40 node_a160b504 426: _read_classes_section() node_a160b504->node_3166ec40 node_b8abd8d1 776: _read_examples_section() node_b8abd8d1->node_8be58605 node_b8abd8d1->node_df448740 node_048c6a1d 389: _read_functions_section() node_048c6a1d->node_3166ec40 node_e7e40cba 488: _read_modules_section() node_e7e40cba->node_3166ec40 node_2039de98 267: _read_other_parameters_section() node_038b8fd5 188: _read_parameters() node_2039de98->node_038b8fd5 node_038b8fd5->node_3166ec40 node_4a64c3d9 257: _read_parameters_section() node_4a64c3d9->node_038b8fd5 node_da17b934 516: _read_raises_section() node_da17b934->node_3166ec40 node_e5639fd2 730: _read_receives_section() node_e5639fd2->node_462c9e2d node_e5639fd2->node_482e82da node_e5639fd2->node_56dbfc8b node_aa6da5a3 638: _read_returns_section() node_aa6da5a3->node_462c9e2d node_aa6da5a3->node_482e82da node_aa6da5a3->node_56dbfc8b node_f8d79a40 463: _read_type_aliases_section() node_f8d79a40->node_3166ec40 node_2324edbf 278: _read_type_parameters_section() node_2324edbf->node_3166ec40 node_4752af36 547: _read_warns_section() node_4752af36->node_3166ec40 node_3ddecc41 684: _read_yields_section() node_3ddecc41->node_462c9e2d node_3ddecc41->node_482e82da node_3ddecc41->node_56dbfc8b node_e8affa51 882: parse_google() node_e8affa51->node_8be58605 node_e8affa51->node_df448740
models.pyΒ€

This module contains the models for storing docstrings structured data.

G cluster_dc7f3af7 File: models cluster_245c9188 Class: DocstringSection node_0e9c8645 246: as_dict() node_0e9c8645->node_0e9c8645
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_091cd2f6 File: numpy node_38d402a9 858: _append_section() node_25ef3eb1 96: _is_dash_line() node_feb3479b 92: _is_empty_line() node_25ef3eb1->node_feb3479b node_1d509a29 638: _read_attributes_section() node_efe95772 100: _read_block_items() node_1d509a29->node_efe95772 node_4e51d637 162: _read_block() node_4e51d637->node_25ef3eb1 node_4e51d637->node_feb3479b node_efe95772->node_25ef3eb1 node_efe95772->node_feb3479b node_e0f91efb 709: _read_classes_section() node_e0f91efb->node_efe95772 node_e49e0622 405: _read_deprecated_section() node_e49e0622->node_efe95772 node_9790a969 793: _read_examples_section() node_9790a969->node_feb3479b node_9790a969->node_4e51d637 node_4db53184 677: _read_functions_section() node_4db53184->node_efe95772 node_f1bab444 761: _read_modules_section() node_f1bab444->node_efe95772 node_78a130d4 313: _read_other_parameters_section() node_2be6410a 224: _read_parameters() node_78a130d4->node_2be6410a node_2be6410a->node_efe95772 node_9b52c1a4 298: _read_parameters_section() node_9b52c1a4->node_2be6410a node_ee6002f1 588: _read_raises_section() node_ee6002f1->node_efe95772 node_d6297e22 541: _read_receives_section() node_d6297e22->node_efe95772 node_1aee7605 431: _read_returns_section() node_1aee7605->node_efe95772 node_004faebc 741: _read_type_aliases_section() node_004faebc->node_efe95772 node_6689ea92 335: _read_type_parameters_section() node_6689ea92->node_efe95772 node_f0d42084 613: _read_warns_section() node_f0d42084->node_efe95772 node_e1d06d03 490: _read_yields_section() node_e1d06d03->node_efe95772 node_004ded1d 911: parse_numpy() node_004ded1d->node_38d402a9 node_004ded1d->node_25ef3eb1 node_004ded1d->node_feb3479b
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_74fc3e34 File: sphinx cluster_b785785d Class: _FieldType node_1bdd818d 50: matches() node_b3fe707d 462: _consolidate_continuation_lines() node_05c11df8 475: _consolidate_descriptive_type() node_e9a1d0c4 214: _determine_param_annotation() node_c9f2f3ec 207: _determine_param_default() node_d1e0767f 449: _parse_directive() node_d1e0767f->node_b3fe707d node_e6d8edfe 433: _parsed_values_to_sections() node_4c89e0b3 479: _strip_blank_lines() node_e6d8edfe->node_4c89e0b3 node_782c9205 280: _read_attribute() node_782c9205->node_d1e0767f node_492a44bf 327: _read_attribute_type() node_492a44bf->node_05c11df8 node_492a44bf->node_d1e0767f node_e8ba104b 357: _read_exception() node_e8ba104b->node_d1e0767f node_0ca0d568 144: _read_parameter() node_0ca0d568->node_e9a1d0c4 node_0ca0d568->node_c9f2f3ec node_0ca0d568->node_d1e0767f node_cba68a81 249: _read_parameter_type() node_cba68a81->node_05c11df8 node_cba68a81->node_d1e0767f node_58da4786 378: _read_return() node_58da4786->node_d1e0767f node_6e10fd79 412: _read_return_type() node_6e10fd79->node_05c11df8 node_6e10fd79->node_d1e0767f node_22d616c5 96: parse_sphinx() node_22d616c5->node_1bdd818d node_22d616c5->node_e6d8edfe
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_6d859648 File: encoders cluster_163fd91f Class: JSONEncoder node_07aa73f1 52: __init__() node_07aa73f1->node_07aa73f1 node_2adb4cdf 147: _attach_parent_to_expr() node_929c8b2c 157: _attach_parent_to_exprs() node_929c8b2c->node_2adb4cdf node_7ba80cbd 276: _load_attribute() node_5e645442 89: _load_docstring() node_7ba80cbd->node_5e645442 node_513e451e 138: _load_git_info() node_7ba80cbd->node_513e451e node_544bebb2 222: _load_class() node_544bebb2->node_929c8b2c node_959aefc9 95: _load_decorators() node_544bebb2->node_959aefc9 node_544bebb2->node_5e645442 node_544bebb2->node_513e451e node_00e12674 99: _load_expression() node_4ff620ed 254: _load_function() node_4ff620ed->node_959aefc9 node_4ff620ed->node_5e645442 node_4ff620ed->node_513e451e node_6a4f058a 194: _load_module() node_6a4f058a->node_929c8b2c node_6a4f058a->node_5e645442 node_6a4f058a->node_513e451e node_6df61534 119: _load_parameter() node_6df61534->node_5e645442 node_a628b8eb 311: _load_type_alias() node_a628b8eb->node_5e645442 node_a628b8eb->node_513e451e node_350a3a3e 129: _load_type_parameter() node_72d8e79f 341: json_decoder() node_72d8e79f->node_00e12674 node_72d8e79f->node_6df61534 node_72d8e79f->node_350a3a3e

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_96893d30 File: expressions cluster_9913dbe4 Class: Expr cluster_6520ab92 Class: ExprAttribute cluster_6993f458 Class: ExprBinOp cluster_35477d9f Class: ExprBoolOp cluster_8892ffe6 Class: ExprCall cluster_c9697fe0 Class: ExprCompare cluster_0cc67154 Class: ExprComprehension cluster_fc147fb9 Class: ExprDict cluster_f2275ba1 Class: ExprDictComp cluster_06633c25 Class: ExprExtSlice cluster_545e5e20 Class: ExprFormatted cluster_13bdea3c Class: ExprGeneratorExp cluster_3b4f9f74 Class: ExprIfExp cluster_1fff5155 Class: ExprJoinedStr cluster_7064039d Class: ExprKeyword cluster_542922c8 Class: ExprVarPositional cluster_67b94069 Class: ExprVarKeyword cluster_c7819f43 Class: ExprLambda cluster_816ac356 Class: ExprList cluster_7ccbc311 Class: ExprListComp cluster_5709a6b7 Class: ExprNamedExpr cluster_0e5ce525 Class: ExprSet cluster_ddecffc0 Class: ExprSetComp cluster_d5f68926 Class: ExprSlice cluster_792b05bd Class: ExprSubscript cluster_abcb4f21 Class: ExprTuple cluster_ca4b0f67 Class: ExprUnaryOp cluster_48076b2f Class: ExprYield cluster_fc4df2c5 Class: ExprYieldFrom node_854b1371 173: __iter__() node_6469c25e 177: iterate() node_854b1371->node_6469c25e node_f06282aa 170: __str__() node_f06282aa->node_6469c25e node_94562e56 206: as_dict() node_ca4ede64 143: _expr_as_dict() node_94562e56->node_ca4ede64 node_b180fa33 280: append() node_b180fa33->node_b180fa33 node_91ccd5aa 268: iterate() node_4f1637bc 1118: _get_precedence() node_91ccd5aa->node_4f1637bc node_546644b1 66: _yield() node_91ccd5aa->node_546644b1 node_8cc24c1f 325: iterate() node_8cc24c1f->node_4f1637bc node_8cc24c1f->node_546644b1 node_8054a314 346: iterate() node_8054a314->node_4f1637bc node_8054a314->node_546644b1 node_9fd6bff9 370: iterate() node_9fd6bff9->node_4f1637bc node_035c59d0 109: _join() node_9fd6bff9->node_035c59d0 node_9fd6bff9->node_546644b1 node_7c611dc0 389: iterate() node_7c611dc0->node_4f1637bc node_7c611dc0->node_546644b1 node_33cc4e6d 411: iterate() node_33cc4e6d->node_035c59d0 node_33cc4e6d->node_546644b1 node_6c7c0491 449: iterate() node_6c7c0491->node_035c59d0 node_59622933 471: iterate() node_59622933->node_035c59d0 node_59622933->node_546644b1 node_87ba7938 488: iterate() node_87ba7938->node_035c59d0 node_79300537 500: iterate() node_79300537->node_546644b1 node_c8462209 517: iterate() node_c8462209->node_035c59d0 node_c8462209->node_546644b1 node_90c9f528 535: iterate() node_90c9f528->node_90c9f528 node_90c9f528->node_4f1637bc node_90c9f528->node_546644b1 node_344759ff 561: iterate() node_344759ff->node_035c59d0 node_1b05c258 602: iterate() node_1b05c258->node_546644b1 node_4b929712 644: iterate() node_4b929712->node_546644b1 node_2955abe2 686: iterate() node_2955abe2->node_035c59d0 node_eea59328 702: iterate() node_eea59328->node_035c59d0 node_eea59328->node_546644b1 node_748749bd 815: iterate() node_748749bd->node_546644b1 node_4cb9b408 844: iterate() node_4cb9b408->node_035c59d0 node_a45e538e 860: iterate() node_a45e538e->node_035c59d0 node_a45e538e->node_546644b1 node_70832341 880: iterate() node_70832341->node_546644b1 node_b35dade0 909: _to_binop() node_b35dade0->node_b35dade0 node_78138e83 901: iterate() node_78138e83->node_4f1637bc node_78138e83->node_546644b1 node_705468d4 924: modernize() node_705468d4->node_b35dade0 node_705468d4->node_705468d4 node_ffb60666 960: iterate() node_ffb60666->node_035c59d0 node_2fa1c5da 986: iterate() node_2fa1c5da->node_4f1637bc node_2fa1c5da->node_546644b1 node_1cd75a2b 629: iterate() node_1cd75a2b->node_546644b1 node_7548deae 616: iterate() node_7548deae->node_546644b1 node_f7244470 1001: iterate() node_f7244470->node_546644b1 node_1312e417 1016: iterate() node_1312e417->node_546644b1 node_24e351d0 1408: _build() node_4e1e36c1 1122: _build_attribute() node_4e1e36c1->node_b180fa33 node_4e1e36c1->node_24e351d0 node_fc8073af 1134: _build_binop() node_fc8073af->node_24e351d0 node_d8864afe 1142: _build_boolop() node_d8864afe->node_24e351d0 node_976f968d 1149: _build_call() node_976f968d->node_24e351d0 node_d890f2d1 1156: _build_compare() node_d890f2d1->node_24e351d0 node_2dcdf67e 1164: _build_comprehension() node_2dcdf67e->node_24e351d0 node_362e7c34 1173: _build_constant() node_362e7c34->node_24e351d0 node_3a6ff26e 1212: _build_dict() node_3a6ff26e->node_24e351d0 node_b9eb8b68 1219: _build_dictcomp() node_b9eb8b68->node_24e351d0 node_277cbb41 1227: _build_formatted() node_277cbb41->node_24e351d0 node_64547d38 1237: _build_generatorexp() node_64547d38->node_24e351d0 node_082ee86e 1244: _build_ifexp() node_082ee86e->node_24e351d0 node_3859d9fb 1252: _build_joinedstr() node_3859d9fb->node_24e351d0 node_15098e90 1262: _build_keyword() node_15098e90->node_24e351d0 node_0bde89cb 1268: _build_lambda() node_0bde89cb->node_24e351d0 node_5664e5e7 1442: safe_get_expression() node_0bde89cb->node_5664e5e7 node_c5bdc241 1285: _build_list() node_c5bdc241->node_24e351d0 node_a64da636 1289: _build_listcomp() node_a64da636->node_24e351d0 node_ba91b86d 1297: _build_named_expr() node_ba91b86d->node_24e351d0 node_9bb41931 1301: _build_set() node_9bb41931->node_24e351d0 node_0f7d067d 1305: _build_setcomp() node_0f7d067d->node_24e351d0 node_35ec87ac 1309: _build_slice() node_35ec87ac->node_24e351d0 node_38d8bdd5 1317: _build_starred() node_38d8bdd5->node_24e351d0 node_4dbd25f0 1321: _build_subscript() node_4dbd25f0->node_24e351d0 node_a7de2a1b 1350: _build_tuple() node_a7de2a1b->node_24e351d0 node_46286487 1360: _build_unaryop() node_46286487->node_24e351d0 node_3cd4482b 1364: _build_yield() node_3cd4482b->node_24e351d0 node_b5118d5c 1368: _build_yield_from() node_b5118d5c->node_24e351d0 node_3348e5c2 132: _field_as_dict() node_ca4ede64->node_3348e5c2 node_3348e5c2->node_3348e5c2 node_035c59d0->node_546644b1 node_546644b1->node_4f1637bc node_546644b1->node_546644b1 node_f5672396 1412: get_expression() node_f5672396->node_24e351d0 node_5664e5e7->node_f5672396

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_3d2d9201 File: base cluster_8fa2c762 Class: _ExtensionMetaclass cluster_1d8cb636 Class: Extension cluster_414544de Class: Extensions node_93933084 92: generic_inspect() node_7ccde3c6 84: inspect() node_93933084->node_7ccde3c6 node_541449f3 75: generic_visit() node_7d682c91 67: visit() node_541449f3->node_7d682c91 node_7631efff 447: on_alias() node_e0806ee6 423: on_alias_instance() node_e0806ee6->node_7631efff node_dbde6fbe 484: __init__() node_29faefb6 493: add() node_dbde6fbe->node_29faefb6 node_1d750d30 35: __new__() node_1d750d30->node_1d750d30 node_7d0e9bde 538: _load_extension() node_19e2b0bd 527: _load_extension_path() node_7d0e9bde->node_19e2b0bd node_3054227a 629: load_extensions() node_3054227a->node_dbde6fbe node_3054227a->node_29faefb6 node_3054227a->node_7d0e9bde
dataclasses.pyΒ€

Built-in extension adding support for dataclasses.

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

G cluster_0b496523 File: dataclasses cluster_1590730d Class: DataclassesExtension node_0aa2ef42 227: on_package() node_9a0afb35 203: _apply_recursively() node_0aa2ef42->node_9a0afb35 node_9a0afb35->node_9a0afb35 node_41ff1d29 195: _del_members_annotated_as_initvar() node_9a0afb35->node_41ff1d29 node_06f41c05 157: _set_dataclass_init() node_9a0afb35->node_06f41c05 node_0ce61e3a 49: _dataclass_arguments() node_27efb7f7 25: _dataclass_decorator() node_0ce61e3a->node_27efb7f7 node_2b4cae1f 32: _expr_args() node_0ce61e3a->node_2b4cae1f node_b03df971 66: _dataclass_parameters() node_b03df971->node_0ce61e3a node_cc2c70ab 55: _field_arguments() node_b03df971->node_cc2c70ab node_2b4cae1f->node_2b4cae1f node_cc2c70ab->node_2b4cae1f node_f9b5532a 139: _reorder_parameters() node_06f41c05->node_27efb7f7 node_06f41c05->node_b03df971 node_06f41c05->node_f9b5532a

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/griffe/src/griffe/agents/__init__.py',
    submodule_search_locations=['/media/data/dev/griffe/src/griffe/agents'],
)
G cluster_24e8b90e File: finder cluster_facfb552 Class: ModuleFinder node_7818a1bb 102: __init__() node_41cc6c43 386: _extend_from_pth_files() node_7818a1bb->node_41cc6c43 node_620e12b0 119: append_search_path() node_7818a1bb->node_620e12b0 node_630ffb8a 374: _contents() node_41cc6c43->node_630ffb8a node_41cc6c43->node_620e12b0 node_37cd91b3 442: _handle_pth_file() node_41cc6c43->node_37cd91b3 node_9ab46dbd 395: _filter_py_modules() node_3c3700eb 359: _module_name_path() node_39b41157 403: _top_module_name() node_56546ef7 132: insert_search_path() node_39b41157->node_56546ef7 node_4ec6e2ea 229: find_package() node_4ec6e2ea->node_630ffb8a node_4a7b36c9 427: _is_pkg_style_namespace() node_4ec6e2ea->node_4a7b36c9 node_26adb758 146: find_spec() node_26adb758->node_3c3700eb node_26adb758->node_39b41157 node_26adb758->node_4ec6e2ea node_643a3e1d 276: iter_submodules() node_643a3e1d->node_9ab46dbd node_643a3e1d->node_643a3e1d node_e05a5af9 342: submodules() node_e05a5af9->node_643a3e1d node_c61cbbb5 472: _handle_editable_module() node_62091d58 51: _match_pattern() node_c61cbbb5->node_62091d58 node_37cd91b3->node_c61cbbb5

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_b3121feb File: git cluster_3793f682 Class: GitInfo node_1ab09155 234: from_package() node_6c107102 210: _get_git_commit_hash() node_1ab09155->node_6c107102 node_d1f5c5b9 156: _get_git_known_service() node_1ab09155->node_d1f5c5b9 node_554c5631 130: _get_git_remote_url() node_1ab09155->node_554c5631 node_b9a3ab05 80: _get_repo_root() node_1ab09155->node_b9a3ab05 node_b71a3ac3 216: _is_tracked() node_1ab09155->node_b71a3ac3 node_44800725 258: get_source_link() node_515d5ac6 197: _get_source_link() node_44800725->node_515d5ac6 node_3b5b4d9d 43: _assert_git_repo() node_cb779852 36: _git() node_3b5b4d9d->node_cb779852 node_6c107102->node_cb779852 node_554c5631->node_cb779852 node_9eb447ff 60: _get_latest_tag() node_9eb447ff->node_cb779852 node_b9a3ab05->node_cb779852 node_b71a3ac3->node_cb779852 node_9679e1cd 30: _normalize() node_47f41d6a 97: _tmp_worktree() node_47f41d6a->node_3b5b4d9d node_47f41d6a->node_cb779852 node_47f41d6a->node_9679e1cd

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_09383a29 File: importer node_4679fad3 17: _error_details() node_397f4c1d 43: dynamic_import() node_397f4c1d->node_4679fad3 node_54e78c7a 22: sys_path() node_397f4c1d->node_54e78c7a

loader.pyΒ€

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

G cluster_b584aa34 File: loader cluster_03aaed70 Class: GriffeLoader node_5a75d3d2 52: __init__() node_5f1e9974 649: _create_module() node_29c5461a 734: _expand_wildcard() node_bfe383ad 192: _fire_load_events() node_bfe383ad->node_bfe383ad node_7549c7f7 704: _get_or_create_parent_module() node_7549c7f7->node_5f1e9974 node_929a5cec 677: _inspect_module() node_eceaf895 550: _load_module() node_d90ca085 569: _load_module_path() node_eceaf895->node_d90ca085 node_d90ca085->node_5f1e9974 node_d90ca085->node_929a5cec node_f1acfd9e 594: _load_submodules() node_d90ca085->node_f1acfd9e node_8b88be8a 657: _visit_module() node_d90ca085->node_8b88be8a node_1645c7f4 535: _load_package() node_1645c7f4->node_eceaf895 node_5a6f5204 328: expand_wildcards() node_1645c7f4->node_5a6f5204 node_db694fa6 598: _load_submodule() node_db694fa6->node_7549c7f7 node_db694fa6->node_eceaf895 node_f1acfd9e->node_db694fa6 node_42980995 210: _post_load() node_42980995->node_bfe383ad node_fd72663d 287: expand_exports() node_42980995->node_fd72663d node_42980995->node_5a6f5204 node_fd72663d->node_fd72663d node_5a6f5204->node_29c5461a node_5a6f5204->node_5a6f5204 node_0343e2bb 100: load() node_5a6f5204->node_0343e2bb node_0343e2bb->node_929a5cec node_0343e2bb->node_1645c7f4 node_0343e2bb->node_42980995 node_fe8bba4b 231: resolve_aliases() node_fe8bba4b->node_5a6f5204 node_2591ee47 446: resolve_module_aliases() node_fe8bba4b->node_2591ee47 node_2591ee47->node_0343e2bb node_2591ee47->node_2591ee47 node_551760fb 743: load() node_551760fb->node_5a75d3d2 node_551760fb->node_0343e2bb node_551760fb->node_fe8bba4b node_3b8ff2ac 848: load_git() node_3b8ff2ac->node_551760fb node_ce464e1f 933: load_pypi() node_ce464e1f->node_551760fb

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_b6f22a33 File: logger cluster_d02f6a29 Class: Logger node_37efe789 0: (global)() node_3aea7248 43: _get() node_37efe789->node_3aea7248 node_3b5b3959 49: _patch_loggers() node_c18f74a6 93: get_logger() node_c18f74a6->node_3aea7248 node_3bf53ea0 105: patch_loggers() node_3bf53ea0->node_3b5b3959

merger.pyΒ€

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

G cluster_3b0fa619 File: merger node_2d501d71 37: _merge_attribute_stubs() node_7c9a76e9 49: _merge_stubs_docstring() node_2d501d71->node_7c9a76e9 node_e308b7b0 21: _merge_class_stubs() node_e308b7b0->node_7c9a76e9 node_b064a258 67: _merge_stubs_members() node_e308b7b0->node_b064a258 node_2503fbc7 59: _merge_stubs_overloads() node_e308b7b0->node_2503fbc7 node_3846dff0 54: _merge_stubs_type_parameters() node_e308b7b0->node_3846dff0 node_e116e568 28: _merge_function_stubs() node_e116e568->node_7c9a76e9 node_e116e568->node_3846dff0 node_375cc3cd 15: _merge_module_stubs() node_375cc3cd->node_7c9a76e9 node_375cc3cd->node_b064a258 node_375cc3cd->node_2503fbc7 node_b064a258->node_2d501d71 node_b064a258->node_e116e568 node_9fae9f5c 44: _merge_type_alias_stubs() node_b064a258->node_9fae9f5c node_9fae9f5c->node_7c9a76e9 node_9fae9f5c->node_3846dff0 node_330a8875 110: merge_stubs() node_330a8875->node_375cc3cd

mixins.pyΒ€

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

G cluster_67e156e3 File: mixins cluster_b6c0e654 Class: GetMembersMixin cluster_6dd9faa2 Class: DelMembersMixin cluster_bc2c5d45 Class: SetMembersMixin node_019df017 87: __delitem__() node_ac2e6351 22: _get_parts() node_019df017->node_ac2e6351 node_c0ba889b 114: del_member() node_c0ba889b->node_c0ba889b node_c0ba889b->node_ac2e6351 node_89a285bb 37: __getitem__() node_89a285bb->node_ac2e6351 node_582018a0 59: get_member() node_582018a0->node_582018a0 node_582018a0->node_ac2e6351 node_a4bed56d 142: __setitem__() node_a4bed56d->node_ac2e6351 node_15ed105c 168: set_member() node_15ed105c->node_15ed105c node_15ed105c->node_ac2e6351

models.pyΒ€

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

G cluster_8e6cabed File: models cluster_bc0bb964 Class: Docstring cluster_34974373 Class: Parameter cluster_04135596 Class: Parameters cluster_b0c6b6d8 Class: TypeParameters cluster_0efd879b Class: Object cluster_079cc2b8 Class: Alias cluster_8e789270 Class: Class cluster_4d25940b Class: Function node_9971a12e 1348: __init__() node_dee83a65 2156: _update_target_aliases() node_9971a12e->node_dee83a65 node_37775d84 2140: _resolve_target() node_3bbf81a6 2107: resolve_target() node_37775d84->node_3bbf81a6 node_72a8f6b9 1539: as_json() node_72a8f6b9->node_72a8f6b9 node_98ac86cf 1771: filter_members() node_98ac86cf->node_98ac86cf node_a9d7f92d 1758: has_labels() node_a9d7f92d->node_a9d7f92d node_a599dfde 1517: inherited_members() node_a599dfde->node_9971a12e node_b1d7b88e 1671: is_kind() node_b1d7b88e->node_b1d7b88e node_fafa3fe5 1497: members() node_fafa3fe5->node_9971a12e node_2f21e44d 1478: parent() node_2f21e44d->node_dee83a65 node_1cf0b732 1880: resolve() node_1cf0b732->node_1cf0b732 node_f2d415da 2058: target() node_f2d415da->node_3bbf81a6 node_6aae1848 2435: _mro() node_6aae1848->node_6aae1848 node_2da4d420 2446: mro() node_2da4d420->node_6aae1848 node_640dab99 2383: parameters() node_654c45bc 308: __init__() node_640dab99->node_654c45bc node_264a35cb 165: parse() node_e8465fd6 161: parsed() node_e8465fd6->node_264a35cb node_77ef1318 2476: __init__() node_77ef1318->node_654c45bc node_b4147eed 579: __init__() node_da2d4999 488: __init__() node_b4147eed->node_da2d4999 node_9fc2a295 821: inherited_members() node_9fc2a295->node_9971a12e node_d6a95b3e 1197: resolve() node_d6a95b3e->node_d6a95b3e node_cddf065c 274: as_dict() node_cddf065c->node_cddf065c

stats.pyΒ€

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

G cluster_58d8d225 File: stats cluster_f7e9599e Class: Stats node_55a2aef3 20: __init__() node_ce2715ab 74: _itercount() node_55a2aef3->node_ce2715ab node_ce2715ab->node_ce2715ab

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_c08585a8 File: tests node_d84a5f61 403: module_vtree() node_c1866d6d 360: vtree() node_d84a5f61->node_c1866d6d node_64bb5ed8 309: temporary_inspected_module() node_e136e68c 54: temporary_pyfile() node_64bb5ed8->node_e136e68c node_b461c3ad 189: temporary_inspected_package() node_e6aaac82 72: temporary_pypackage() node_b461c3ad->node_e6aaac82 node_5a2485b3 263: temporary_visited_module() node_5a2485b3->node_e136e68c node_61e8efe8 121: temporary_visited_package() node_61e8efe8->node_e6aaac82