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
GitHub workflows, issue templates and other configuration.
π ISSUE_TEMPLATE/ # (1)!
π workflows/ # (2)!
FUNDING.yml
1 -bug.md
2 -feature.md
3 -docs.md
4 -change.md
config.yml
The default virtual environment (git-ignored). See make setup
command.
The virtual environments for all supported Python versions (git-ignored). See make setup
command.
The configuration for VSCode (git-ignored). See make vscode
command.
launch.json
settings.json
tasks.json
Contains our tooling configuration. See Scripts, configuration .
π vscode/ # (1)!
coverage.ini
git-changelog.toml
mypy.ini
pytest.ini
ruff.toml
launch.json
settings.json
tasks.json
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
Customization of Material for MkDocs ' templates.
π partials/ # (1)!
main.html
comments.html
path-item.html
custom.css
insiders.css
material.css
mkdocstrings.css
π built-in/ # (1)!
π official/ # (2)!
π third-party/ # (3)!
built-in.md
official.md
third-party.md
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
docstring-inheritance.md
fieldz.md
generics.md
inherited-method-crossrefs.md
modernized-annotations.md
π contributors/ # (1)!
π users/ # (2)!
contributors.md
users.md
architecture.md
commands.md
setup.md
workflow.md
π how-to/ # (1)!
π recommendations/ # (2)!
checking.md
extending.md
loading.md
navigating.md
serializing.md
parse-docstrings.md
selectively-inspect.md
set-docstring-styles.md
support-decorators.md
docstrings.md
public-apis.md
python-code.md
favicon.ico
gha_annotations_1.png
gha_annotations_2.png
changelog.md
goals.yml
index.md
installation.md
π api/ # (1)!
api.md
cli.md
docstrings.md
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
alias.md
attribute.md
class.md
function .md
module.md
type_alias.md
HTML report for Python code coverage (git-ignored), integrated in the Coverage report page. See make coverage
task.
Our different scripts. See Scripts, configuration .
gen_credits.py
gen_griffe_json.py
gen_structure_docs.py
get_version.py
insiders.py
make
make.py
Documentation site, built with make run mkdocs build
(git-ignored).
The source of our Python package(s). See Sources and Program structure .
Our public API, exposed to users. See Program structure .
π _internal/ # (1)!
__init__.py
__main__.py
py.typed
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
π nodes/ # (1)!
__init__.py
inspector.py
visitor.py
__init__.py
assignments.py
ast.py
docstrings.py
exports.py
imports.py
parameters.py
runtime.py
values.py
__init__.py
google.py
models.py
numpy.py
parsers.py
sphinx.py
utils.py
__init__.py
base.py
dataclasses.py
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
__init__.py
conftest.py
helpers.py
test_google.py
test_numpy.py
test_sphinx.py
test_warnings.py
The answers file generated by Copier . See Boilerplate .
The environment configuration, automatically sourced by direnv . See commands .
A dummy makefile, only there for auto-completion. See commands .
Our project tasks, written with duty . See Tasks .
The build configuration for our docs. See make docs
task.
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.
G colorama colorama griffe griffe griffe__internal griffe. _internal griffe->griffe__internal griffe__internal_agents griffe. _internal. agents griffe->griffe__internal_agents griffe__internal_agents_inspector griffe. _internal. agents. inspector griffe->griffe__internal_agents_inspector griffe__internal_agents_nodes griffe. _internal. agents. nodes griffe->griffe__internal_agents_nodes griffe__internal_agents_nodes_assignments griffe. _internal. agents. nodes. assignments griffe->griffe__internal_agents_nodes_assignments griffe__internal_agents_nodes_ast griffe. _internal. agents. nodes. ast griffe->griffe__internal_agents_nodes_ast griffe__internal_agents_nodes_docstrings griffe. _internal. agents. nodes. docstrings griffe->griffe__internal_agents_nodes_docstrings griffe__internal_agents_nodes_exports griffe. _internal. agents. nodes. exports griffe->griffe__internal_agents_nodes_exports griffe__internal_agents_nodes_imports griffe. _internal. agents. nodes. imports griffe->griffe__internal_agents_nodes_imports griffe__internal_agents_nodes_parameters griffe. _internal. agents. nodes. parameters griffe->griffe__internal_agents_nodes_parameters griffe__internal_agents_nodes_runtime griffe. _internal. agents. nodes. runtime griffe->griffe__internal_agents_nodes_runtime griffe__internal_agents_nodes_values griffe. _internal. agents. nodes. values griffe->griffe__internal_agents_nodes_values griffe__internal_agents_visitor griffe. _internal. agents. visitor griffe->griffe__internal_agents_visitor griffe__internal_c3linear griffe. _internal. c3linear griffe->griffe__internal_c3linear griffe__internal_cli griffe. _internal. cli griffe->griffe__internal_cli griffe__internal_collections griffe. _internal. collections griffe->griffe__internal_collections griffe__internal_diff griffe. _internal. diff griffe->griffe__internal_diff griffe__internal_docstrings griffe. _internal. docstrings griffe->griffe__internal_docstrings griffe__internal_docstrings_google griffe. _internal. docstrings. google griffe->griffe__internal_docstrings_google griffe__internal_docstrings_models griffe. _internal. docstrings. models griffe->griffe__internal_docstrings_models griffe__internal_docstrings_numpy griffe. _internal. docstrings. numpy griffe->griffe__internal_docstrings_numpy griffe__internal_docstrings_parsers griffe. _internal. docstrings. parsers griffe->griffe__internal_docstrings_parsers griffe__internal_docstrings_sphinx griffe. _internal. docstrings. sphinx griffe->griffe__internal_docstrings_sphinx griffe__internal_docstrings_utils griffe. _internal. docstrings. utils griffe->griffe__internal_docstrings_utils griffe__internal_encoders griffe. _internal. encoders griffe->griffe__internal_encoders griffe__internal_enumerations griffe. _internal. enumerations griffe->griffe__internal_enumerations griffe__internal_exceptions griffe. _internal. exceptions griffe->griffe__internal_exceptions griffe__internal_expressions griffe. _internal. expressions griffe->griffe__internal_expressions griffe__internal_extensions griffe. _internal. extensions griffe->griffe__internal_extensions griffe__internal_extensions_base griffe. _internal. extensions. base griffe->griffe__internal_extensions_base griffe__internal_extensions_dataclasses griffe. _internal. extensions. dataclasses griffe->griffe__internal_extensions_dataclasses griffe__internal_finder griffe. _internal. finder griffe->griffe__internal_finder griffe__internal_git griffe. _internal. git griffe->griffe__internal_git griffe__internal_importer griffe. _internal. importer griffe->griffe__internal_importer griffe__internal_loader griffe. _internal. loader griffe->griffe__internal_loader griffe__internal_logger griffe. _internal. logger griffe->griffe__internal_logger griffe__internal_merger griffe. _internal. merger griffe->griffe__internal_merger griffe__internal_mixins griffe. _internal. mixins griffe->griffe__internal_mixins griffe__internal_models griffe. _internal. models griffe->griffe__internal_models griffe__internal_stats griffe. _internal. stats griffe->griffe__internal_stats griffe__internal_tests griffe. _internal. tests griffe->griffe__internal_tests griffe___main__ griffe. __main__ griffe___main__->griffe__internal griffe___main__->griffe__internal_cli griffe__internal_agents_inspector->griffe__internal_agents_nodes griffe__internal_agents_inspector->griffe__internal_agents_nodes_runtime griffe__internal_agents_inspector->griffe__internal_collections griffe__internal_agents_inspector->griffe__internal_docstrings griffe__internal_agents_inspector->griffe__internal_docstrings_parsers griffe__internal_agents_inspector->griffe__internal_enumerations griffe__internal_agents_inspector->griffe__internal_expressions griffe__internal_agents_inspector->griffe__internal_extensions griffe__internal_agents_inspector->griffe__internal_importer griffe__internal_agents_inspector->griffe__internal_logger griffe__internal_agents_inspector->griffe__internal_models typing_extensions typing_extensions griffe__internal_agents_inspector->typing_extensions griffe__internal_agents_nodes_ast->griffe__internal_exceptions griffe__internal_agents_nodes_exports->griffe__internal_agents_nodes_values griffe__internal_agents_nodes_exports->griffe__internal_enumerations griffe__internal_agents_nodes_exports->griffe__internal_expressions griffe__internal_agents_nodes_exports->griffe__internal_logger griffe__internal_agents_nodes_exports->griffe__internal_models griffe__internal_agents_nodes_imports->griffe__internal_models griffe__internal_agents_nodes_parameters->griffe__internal_enumerations griffe__internal_agents_nodes_runtime->griffe__internal_enumerations griffe__internal_agents_nodes_runtime->griffe__internal_logger griffe__internal_agents_nodes_runtime->typing_extensions griffe__internal_agents_nodes_values->griffe__internal_logger griffe__internal_agents_visitor->griffe__internal_agents_nodes griffe__internal_agents_visitor->griffe__internal_agents_nodes_assignments griffe__internal_agents_visitor->griffe__internal_agents_nodes_ast griffe__internal_agents_visitor->griffe__internal_agents_nodes_docstrings griffe__internal_agents_visitor->griffe__internal_agents_nodes_exports griffe__internal_agents_visitor->griffe__internal_agents_nodes_imports griffe__internal_agents_visitor->griffe__internal_agents_nodes_parameters griffe__internal_agents_visitor->griffe__internal_collections griffe__internal_agents_visitor->griffe__internal_docstrings griffe__internal_agents_visitor->griffe__internal_docstrings_parsers griffe__internal_agents_visitor->griffe__internal_enumerations griffe__internal_agents_visitor->griffe__internal_exceptions griffe__internal_agents_visitor->griffe__internal_expressions griffe__internal_agents_visitor->griffe__internal_extensions griffe__internal_agents_visitor->griffe__internal_models griffe__internal_cli->colorama griffe__internal_debug griffe. _internal. debug griffe__internal_cli->griffe__internal_debug griffe__internal_cli->griffe__internal_diff griffe__internal_cli->griffe__internal_encoders griffe__internal_cli->griffe__internal_enumerations griffe__internal_cli->griffe__internal_exceptions griffe__internal_cli->griffe__internal_extensions griffe__internal_cli->griffe__internal_extensions_base griffe__internal_cli->griffe__internal_git griffe__internal_cli->griffe__internal_loader griffe__internal_cli->griffe__internal_logger griffe__internal_collections->griffe__internal_mixins griffe__internal_diff->colorama griffe__internal_diff->griffe__internal_enumerations griffe__internal_diff->griffe__internal_exceptions griffe__internal_diff->griffe__internal_git griffe__internal_diff->griffe__internal_logger griffe__internal_diff->griffe__internal_models griffe__internal_docstrings_google->griffe__internal_docstrings_models griffe__internal_docstrings_google->griffe__internal_docstrings_utils griffe__internal_docstrings_google->griffe__internal_enumerations griffe__internal_docstrings_google->griffe__internal_expressions griffe__internal_docstrings_google->griffe__internal_models griffe__internal_docstrings_models->griffe__internal_enumerations griffe__internal_docstrings_models->griffe__internal_expressions griffe__internal_docstrings_numpy->griffe__internal_docstrings_models griffe__internal_docstrings_numpy->griffe__internal_docstrings_utils griffe__internal_docstrings_numpy->griffe__internal_enumerations griffe__internal_docstrings_numpy->griffe__internal_expressions griffe__internal_docstrings_numpy->griffe__internal_models griffe__internal_docstrings_parsers->griffe__internal_docstrings_google griffe__internal_docstrings_parsers->griffe__internal_docstrings_models griffe__internal_docstrings_parsers->griffe__internal_docstrings_numpy griffe__internal_docstrings_parsers->griffe__internal_docstrings_sphinx griffe__internal_docstrings_parsers->griffe__internal_enumerations griffe__internal_docstrings_sphinx->griffe__internal_docstrings_models griffe__internal_docstrings_sphinx->griffe__internal_docstrings_utils griffe__internal_docstrings_sphinx->griffe__internal_expressions griffe__internal_docstrings_sphinx->griffe__internal_models griffe__internal_docstrings_utils->griffe__internal_enumerations griffe__internal_docstrings_utils->griffe__internal_exceptions griffe__internal_docstrings_utils->griffe__internal_expressions griffe__internal_docstrings_utils->griffe__internal_logger griffe__internal_docstrings_utils->griffe__internal_models griffe__internal_encoders->griffe__internal_enumerations griffe__internal_encoders->griffe__internal_expressions griffe__internal_encoders->griffe__internal_models griffe__internal_exceptions->griffe__internal_models griffe__internal_expressions->griffe__internal_agents griffe__internal_expressions->griffe__internal_agents_nodes griffe__internal_expressions->griffe__internal_agents_nodes_parameters griffe__internal_expressions->griffe__internal_enumerations griffe__internal_expressions->griffe__internal_exceptions griffe__internal_expressions->griffe__internal_logger griffe__internal_extensions_base->griffe__internal_agents griffe__internal_extensions_base->griffe__internal_agents_inspector griffe__internal_extensions_base->griffe__internal_agents_nodes griffe__internal_extensions_base->griffe__internal_agents_nodes_ast griffe__internal_extensions_base->griffe__internal_agents_nodes_runtime griffe__internal_extensions_base->griffe__internal_agents_visitor griffe__internal_extensions_base->griffe__internal_exceptions griffe__internal_extensions_base->griffe__internal_extensions_dataclasses griffe__internal_extensions_base->griffe__internal_importer griffe__internal_extensions_base->griffe__internal_loader griffe__internal_extensions_base->griffe__internal_models griffe__internal_extensions_dataclasses->griffe__internal_enumerations griffe__internal_extensions_dataclasses->griffe__internal_expressions griffe__internal_extensions_dataclasses->griffe__internal_logger griffe__internal_extensions_dataclasses->griffe__internal_models griffe__internal_finder->griffe__internal_exceptions griffe__internal_finder->griffe__internal_logger griffe__internal_finder->griffe__internal_models griffe__internal_git->griffe__internal_exceptions griffe__internal_loader->griffe__internal_agents griffe__internal_loader->griffe__internal_agents_inspector griffe__internal_loader->griffe__internal_agents_visitor griffe__internal_loader->griffe__internal_collections griffe__internal_loader->griffe__internal_docstrings griffe__internal_loader->griffe__internal_docstrings_parsers griffe__internal_loader->griffe__internal_enumerations griffe__internal_loader->griffe__internal_exceptions griffe__internal_loader->griffe__internal_expressions griffe__internal_loader->griffe__internal_extensions griffe__internal_loader->griffe__internal_finder griffe__internal_loader->griffe__internal_git griffe__internal_loader->griffe__internal_importer griffe__internal_loader->griffe__internal_logger griffe__internal_loader->griffe__internal_merger griffe__internal_loader->griffe__internal_models griffe__internal_loader->griffe__internal_stats platformdirs platformdirs griffe__internal_loader->platformdirs griffe__internal_merger->griffe__internal_exceptions griffe__internal_merger->griffe__internal_logger griffe__internal_merger->griffe__internal_models griffe__internal_mixins->griffe__internal_encoders griffe__internal_mixins->griffe__internal_enumerations griffe__internal_mixins->griffe__internal_exceptions griffe__internal_mixins->griffe__internal_merger griffe__internal_models->griffe__internal_c3linear griffe__internal_models->griffe__internal_collections griffe__internal_models->griffe__internal_docstrings griffe__internal_models->griffe__internal_docstrings_models griffe__internal_models->griffe__internal_docstrings_parsers griffe__internal_models->griffe__internal_enumerations griffe__internal_models->griffe__internal_expressions griffe__internal_models->griffe__internal_logger griffe__internal_models->griffe__internal_mixins griffe__internal_stats->griffe__internal_enumerations griffe__internal_stats->griffe__internal_models griffe__internal_tests->griffe__internal_agents griffe__internal_tests->griffe__internal_agents_inspector griffe__internal_tests->griffe__internal_agents_visitor griffe__internal_tests->griffe__internal_collections griffe__internal_tests->griffe__internal_docstrings griffe__internal_tests->griffe__internal_docstrings_parsers griffe__internal_tests->griffe__internal_enumerations griffe__internal_tests->griffe__internal_extensions griffe__internal_tests->griffe__internal_extensions_base griffe__internal_tests->griffe__internal_loader griffe__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_bcef7787 File: inspector cluster_57f52df2 Class: Inspector node_d5295c9c 123: __init__() node_d5295c9c->node_d5295c9c node_52e71c9f 175: _get_docstring() node_c6ac9df8 197: _get_linenos() node_938376a0 263: generic_inspect() node_938376a0->node_d5295c9c node_7c35c160 255: inspect() node_938376a0->node_7c35c160 node_88869e46 300: inspect_module() node_938376a0->node_88869e46 node_37bb502d 207: get_module() node_37bb502d->node_7c35c160 node_80657180 539: handle_attribute() node_80657180->node_52e71c9f node_a8adc850 443: handle_function() node_a8adc850->node_52e71c9f node_a8adc850->node_c6ac9df8 node_c0541c92 619: _convert_object_to_annotation() node_a8adc850->node_c0541c92 node_3babb2cb 596: _convert_parameter() node_a8adc850->node_3babb2cb node_48216150 655: _convert_type_parameters() node_a8adc850->node_48216150 node_50942943 531: inspect_attribute() node_50942943->node_80657180 node_c09f1747 403: inspect_builtin_function() node_c09f1747->node_a8adc850 node_9c64514c 379: inspect_builtin_method() node_9c64514c->node_a8adc850 node_99f4cafc 419: inspect_cached_property() node_99f4cafc->node_a8adc850 node_82fed0bf 322: inspect_class() node_82fed0bf->node_52e71c9f node_82fed0bf->node_c6ac9df8 node_82fed0bf->node_938376a0 node_82fed0bf->node_48216150 node_a3c796bb 363: inspect_classmethod() node_a3c796bb->node_a8adc850 node_3cb3be76 395: inspect_coroutine() node_3cb3be76->node_a8adc850 node_941ab815 411: inspect_function() node_941ab815->node_a8adc850 node_3cf637b2 435: inspect_getset_descriptor() node_3cf637b2->node_a8adc850 node_0289d577 387: inspect_method() node_0289d577->node_a8adc850 node_9a2c1b31 371: inspect_method_descriptor() node_9a2c1b31->node_a8adc850 node_88869e46->node_52e71c9f node_029c8678 427: inspect_property() node_029c8678->node_a8adc850 node_47c60188 355: inspect_staticmethod() node_47c60188->node_a8adc850 node_6a275d5b 507: inspect_type_alias() node_6a275d5b->node_52e71c9f node_6a275d5b->node_c6ac9df8 node_6a275d5b->node_48216150 node_bb5415a3 698: _convert_type_to_annotation() node_6a275d5b->node_bb5415a3 node_3babb2cb->node_c0541c92 node_48216150->node_bb5415a3 node_bb5415a3->node_c0541c92 node_bb5415a3->node_bb5415a3 node_d7725d55 55: inspect() node_d7725d55->node_d5295c9c node_d7725d55->node_37bb502d 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_de1506dd File: assignments node_4cc4193d 40: _get_annassign_names() node_9d1af4c3 23: get_name() node_4cc4193d->node_9d1af4c3 node_8112bc99 35: _get_assign_names() node_8112bc99->node_9d1af4c3 node_4c02e2c8 9: _get_attribute_name() node_4c02e2c8->node_9d1af4c3 node_636857df 63: get_instance_names() node_2907e57e 51: get_names() node_636857df->node_2907e57e ast.py
This module contains utilities for navigating AST nodes.
G cluster_0a64c2e9 File: ast node_46db93fe 26: ast_children() node_36f6097a 137: ast_first_child() node_36f6097a->node_46db93fe node_d298197b 155: ast_last_child() node_d298197b->node_46db93fe node_a7efe73c 119: ast_next() node_ea59c515 66: ast_next_siblings() node_a7efe73c->node_ea59c515 node_ea59c515->node_46db93fe node_222881d2 100: ast_previous() node_ba06aed6 50: ast_previous_siblings() node_222881d2->node_ba06aed6 node_ba06aed6->node_46db93fe node_566c75bd 82: ast_siblings() node_566c75bd->node_46db93fe 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_0e0df943 File: exports node_4287a796 74: _extract() node_e3034782 33: _extract_attribute() node_e3034782->node_4287a796 node_df10a255 37: _extract_binop() node_df10a255->node_4287a796 node_161218c8 51: _extract_sequence() node_161218c8->node_4287a796 node_10c2b589 58: _extract_starred() node_10c2b589->node_4287a796 node_774e8996 78: get__all__() node_774e8996->node_4287a796 node_57dcc230 93: safe_get__all__() node_57dcc230->node_774e8996 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_c04458f7 File: runtime cluster_aeba9a59 Class: ObjectNode node_b23a5ab0 52: __init__() node_28b6bc2d 264: _pick_member() node_e561dc8b 274: alias_target_path() node_4ba7eccc 36: _same_components() node_e561dc8b->node_4ba7eccc node_0ed4550f 154: children() node_0ed4550f->node_b23a5ab0 node_0ed4550f->node_28b6bc2d values.py
This module contains utilities for extracting attribute values.
G cluster_cd3c98b5 File: values node_9cdbcc24 15: get_value() node_18ea1716 29: safe_get_value() node_18ea1716->node_9cdbcc24 visitor.py
This module contains our static analysis agent, capable of parsing and visiting sources, statically.
G cluster_297c8cb4 File: visitor cluster_52b0943b Class: Visitor node_243b5e42 136: __init__() node_243b5e42->node_243b5e42 node_7d2fe62f 196: _get_docstring() node_142363ac 216: _get_type_parameters() node_0ed93808 346: decorators_to_labels() node_274fd7fd 267: generic_visit() node_ee674043 259: visit() node_274fd7fd->node_ee674043 node_77724bed 364: get_base_property() node_64e2ae9c 245: get_module() node_64e2ae9c->node_ee674043 node_bf70f43e 601: handle_attribute() node_bf70f43e->node_7d2fe62f node_4ab2ce63 388: handle_function() node_4ab2ce63->node_7d2fe62f node_4ab2ce63->node_142363ac node_4ab2ce63->node_0ed93808 node_4ab2ce63->node_274fd7fd node_4ab2ce63->node_77724bed node_029f80fd 712: visit_annassign() node_029f80fd->node_bf70f43e node_b638ab52 704: visit_assign() node_b638ab52->node_bf70f43e node_d23c7259 500: visit_asyncfunctiondef() node_d23c7259->node_4ab2ce63 node_ed8ff471 298: visit_classdef() node_ed8ff471->node_7d2fe62f node_ed8ff471->node_142363ac node_ed8ff471->node_0ed93808 node_ed8ff471->node_274fd7fd node_f8afc7ca 492: visit_functiondef() node_f8afc7ca->node_4ab2ce63 node_3449cc35 741: visit_if() node_3449cc35->node_274fd7fd node_00337888 276: visit_module() node_00337888->node_7d2fe62f node_00337888->node_274fd7fd node_51f91765 511: visit_typealias() node_51f91765->node_7d2fe62f node_51f91765->node_142363ac node_e952aef3 79: visit() node_e952aef3->node_243b5e42 node_e952aef3->node_64e2ae9c c3linear.py
This module contains a single function, c3linear_merge
. The function is generic enough to be in its own module.
G cluster_3b72ec69 File: c3linear cluster_d93b46ad Class: _Dependency cluster_fff5df0a Class: _DependencyList node_44a261a4 29: tail() node_28470f4f 60: __len__() node_44a261a4->node_28470f4f node_81661453 48: __init__() node_874e89ee 64: __repr__() node_874e89ee->node_874e89ee node_f3bc1b15 82: remove() node_00b54974 93: c3linear_merge() node_00b54974->node_81661453 node_00b54974->node_f3bc1b15 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_86d7406b File: cli cluster_65218993 Class: _DebugInfo node_64907cda 51: __init__() node_64907cda->node_64907cda node_1aff283e 69: _load_packages() node_70c41f9c 59: _print_data() node_e6d957bb 331: dump() node_e6d957bb->node_1aff283e node_e6d957bb->node_70c41f9c node_ec8cd26f 130: get_parser() node_12b9a237 575: main() node_12b9a237->node_ec8cd26f collections.py
This module contains collection-related classes, which are used throughout the API.
G cluster_7bd38080 File: collections cluster_4e6cf197 Class: LinesCollection node_7a5fa742 56: items() node_7a5fa742->node_7a5fa742 node_ca70ce09 40: keys() node_ca70ce09->node_ca70ce09 node_d99fd914 48: values() node_d99fd914->node_d99fd914 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_245fe946 File: debug node_a1dcd05a 80: _get_debug_info() node_c59f477d 65: _get_version() node_a1dcd05a->node_c59f477d node_160201e7 54: _interpreter_name_version() node_a1dcd05a->node_160201e7 node_123d95c9 99: _print_debug_info() node_123d95c9->node_a1dcd05a 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_e153e39c File: diff cluster_b6492382 Class: Breakage node_092929de 221: _explain_github() node_ced49d45 164: _format_new_value() node_092929de->node_ced49d45 node_22c752b3 161: _format_old_value() node_092929de->node_22c752b3 node_ef9a35d7 153: _format_title() node_092929de->node_ef9a35d7 node_c134860f 201: _explain_markdown() node_c134860f->node_ced49d45 node_c134860f->node_22c752b3 node_bd4816cb 167: _explain_oneline() node_b4a123f9 156: _format_kind() node_bd4816cb->node_b4a123f9 node_05dd6bf2 148: _format_location() node_bd4816cb->node_05dd6bf2 node_bd4816cb->node_ced49d45 node_bd4816cb->node_22c752b3 node_bd4816cb->node_ef9a35d7 node_ad5e0f55 183: _explain_verbose() node_ad5e0f55->node_b4a123f9 node_ad5e0f55->node_05dd6bf2 node_ad5e0f55->node_ced49d45 node_ad5e0f55->node_22c752b3 node_ad5e0f55->node_ef9a35d7 node_c49d08a0 522: _alias_incompatibilities() node_7effbbd8 559: _type_based_yield() node_c49d08a0->node_7effbbd8 node_fe207ba4 513: _attribute_incompatibilities() node_ce319a8d 425: _class_incompatibilities() node_0e05a8b8 538: _member_incompatibilities() node_ce319a8d->node_0e05a8b8 node_da70799a 438: _function_incompatibilities() node_7f7369b6 596: _returns_are_compatible() node_da70799a->node_7f7369b6 node_0e05a8b8->node_7effbbd8 node_7effbbd8->node_fe207ba4 node_7effbbd8->node_ce319a8d node_7effbbd8->node_da70799a node_e57794f9 620: find_breaking_changes() node_e57794f9->node_0e05a8b8 docstrings
These submodules define models and parsers for docstrings.
google.py
This module defines functions to parse Google-style docstrings into structured data.
G cluster_bae00d87 File: google node_2fae360d 617: _annotation_from_parent() node_5924732e 586: _get_name_annotation_description() node_04c959d8 833: _is_empty_line() node_df02ddaa 345: _read_attributes_section() node_a503bcaf 92: _read_block_items() node_df02ddaa->node_a503bcaf node_9515cdca 156: _read_block() node_9515cdca->node_04c959d8 node_a503bcaf->node_04c959d8 node_549b9f31 573: _read_block_items_maybe() node_549b9f31->node_9515cdca node_549b9f31->node_a503bcaf node_73ede500 424: _read_classes_section() node_73ede500->node_a503bcaf node_a100e682 774: _read_examples_section() node_a100e682->node_04c959d8 node_a100e682->node_9515cdca node_72eed35e 387: _read_functions_section() node_72eed35e->node_a503bcaf node_99a17f71 486: _read_modules_section() node_99a17f71->node_a503bcaf node_c5c7cf14 265: _read_other_parameters_section() node_df1dfa7c 187: _read_parameters() node_c5c7cf14->node_df1dfa7c node_df1dfa7c->node_a503bcaf node_2ce53a40 255: _read_parameters_section() node_2ce53a40->node_df1dfa7c node_841fb723 514: _read_raises_section() node_841fb723->node_a503bcaf node_ce744541 728: _read_receives_section() node_ce744541->node_2fae360d node_ce744541->node_5924732e node_ce744541->node_549b9f31 node_6b8de4b7 636: _read_returns_section() node_6b8de4b7->node_2fae360d node_6b8de4b7->node_5924732e node_6b8de4b7->node_549b9f31 node_eb05b9a5 461: _read_type_aliases_section() node_eb05b9a5->node_a503bcaf node_93cbed0f 276: _read_type_parameters_section() node_93cbed0f->node_a503bcaf node_c973d58e 545: _read_warns_section() node_c973d58e->node_a503bcaf node_c229144c 682: _read_yields_section() node_c229144c->node_2fae360d node_c229144c->node_5924732e node_c229144c->node_549b9f31 node_cfb57506 857: parse_google() node_cfb57506->node_04c959d8 node_cfb57506->node_9515cdca models.py
This module contains the models for storing docstrings structured data.
G cluster_ddee58e4 File: models cluster_2a4c873c Class: DocstringSection node_779a409b 246: as_dict() node_779a409b->node_779a409b 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_6b4c496b File: numpy node_73531b9c 857: _append_section() node_4a114729 95: _is_dash_line() node_49069022 91: _is_empty_line() node_4a114729->node_49069022 node_c2e32192 637: _read_attributes_section() node_5b34a153 99: _read_block_items() node_c2e32192->node_5b34a153 node_a1710f62 161: _read_block() node_a1710f62->node_4a114729 node_a1710f62->node_49069022 node_5b34a153->node_4a114729 node_5b34a153->node_49069022 node_ca68f95b 708: _read_classes_section() node_ca68f95b->node_5b34a153 node_62adaba3 404: _read_deprecated_section() node_62adaba3->node_5b34a153 node_2ecbe4d7 792: _read_examples_section() node_2ecbe4d7->node_49069022 node_2ecbe4d7->node_a1710f62 node_e1a1974a 676: _read_functions_section() node_e1a1974a->node_5b34a153 node_776a0f91 760: _read_modules_section() node_776a0f91->node_5b34a153 node_6ff71048 312: _read_other_parameters_section() node_5b550d68 223: _read_parameters() node_6ff71048->node_5b550d68 node_5b550d68->node_5b34a153 node_2febda33 297: _read_parameters_section() node_2febda33->node_5b550d68 node_98e0e01c 587: _read_raises_section() node_98e0e01c->node_5b34a153 node_ca005592 540: _read_receives_section() node_ca005592->node_5b34a153 node_6fc4d3f7 430: _read_returns_section() node_6fc4d3f7->node_5b34a153 node_2f151066 740: _read_type_aliases_section() node_2f151066->node_5b34a153 node_107f26de 334: _read_type_parameters_section() node_107f26de->node_5b34a153 node_a12f4f11 612: _read_warns_section() node_a12f4f11->node_5b34a153 node_ed62d10c 489: _read_yields_section() node_ed62d10c->node_5b34a153 node_84cdb4d3 895: parse_numpy() node_84cdb4d3->node_73531b9c node_84cdb4d3->node_4a114729 node_84cdb4d3->node_49069022 parsers.py
This module imports all the defined parsers and provides a generic function to parse docstrings.
G cluster_2511de80 File: parsers node_3aebeb0d 107: infer_docstring_style() node_89bbdbc3 239: parse() node_e6b3f8ae 180: parse_auto() node_e6b3f8ae->node_3aebeb0d node_e6b3f8ae->node_89bbdbc3 sphinx.py
This module defines functions to parse Sphinx docstrings into structured data.
G cluster_f7f23e26 File: sphinx cluster_8d9382ac Class: _FieldType node_1d218799 49: matches() node_3ab1aa57 448: _consolidate_continuation_lines() node_5cb33343 461: _consolidate_descriptive_type() node_3deb3d96 200: _determine_param_annotation() node_1429ae64 193: _determine_param_default() node_30c8565b 435: _parse_directive() node_30c8565b->node_3ab1aa57 node_59ea70b1 419: _parsed_values_to_sections() node_aa332bce 465: _strip_blank_lines() node_59ea70b1->node_aa332bce node_90c2103b 266: _read_attribute() node_90c2103b->node_30c8565b node_ae53f753 313: _read_attribute_type() node_ae53f753->node_5cb33343 node_ae53f753->node_30c8565b node_aa3368a7 343: _read_exception() node_aa3368a7->node_30c8565b node_0a9619b8 130: _read_parameter() node_0a9619b8->node_3deb3d96 node_0a9619b8->node_1429ae64 node_0a9619b8->node_30c8565b node_1eed6674 235: _read_parameter_type() node_1eed6674->node_5cb33343 node_1eed6674->node_30c8565b node_6d2adbbc 364: _read_return() node_6d2adbbc->node_30c8565b node_1a04f716 398: _read_return_type() node_1a04f716->node_5cb33343 node_1a04f716->node_30c8565b node_05273641 86: parse_sphinx() node_05273641->node_1d218799 node_05273641->node_59ea70b1 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_2e049a4d File: encoders cluster_a9b3cc4d Class: JSONEncoder node_0481c662 51: __init__() node_0481c662->node_0481c662 node_1bf29a3f 137: _attach_parent_to_expr() node_88f4f54f 147: _attach_parent_to_exprs() node_88f4f54f->node_1bf29a3f node_9a741132 254: _load_attribute() node_8060cda5 88: _load_docstring() node_9a741132->node_8060cda5 node_a0540d91 208: _load_class() node_a0540d91->node_88f4f54f node_1ec01392 94: _load_decorators() node_a0540d91->node_1ec01392 node_a0540d91->node_8060cda5 node_ab0c5fa7 98: _load_expression() node_a36ccb76 236: _load_function() node_a36ccb76->node_1ec01392 node_a36ccb76->node_8060cda5 node_e058d696 184: _load_module() node_e058d696->node_88f4f54f node_e058d696->node_8060cda5 node_f4556362 118: _load_parameter() node_f4556362->node_8060cda5 node_0452210a 284: _load_type_alias() node_0452210a->node_8060cda5 node_14752a34 128: _load_type_parameter() node_f26f9698 305: json_decoder() node_f26f9698->node_ab0c5fa7 node_f26f9698->node_f4556362 node_f26f9698->node_14752a34 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_dc8e8a9e File: expressions cluster_aca46e05 Class: Expr cluster_9e645261 Class: ExprAttribute cluster_f58564c2 Class: ExprBinOp cluster_4eb3143e Class: ExprBoolOp cluster_ef137b33 Class: ExprCall cluster_8511eb3b Class: ExprCompare cluster_c62070da Class: ExprComprehension cluster_779c27d1 Class: ExprDict cluster_9a7e779c Class: ExprDictComp cluster_0b8ab7bf Class: ExprExtSlice cluster_d940293e Class: ExprFormatted cluster_df7ee20e Class: ExprGeneratorExp cluster_d543c273 Class: ExprIfExp cluster_506aaf73 Class: ExprJoinedStr cluster_b15744b2 Class: ExprKeyword cluster_f93e23e8 Class: ExprVarPositional cluster_6e67390d Class: ExprVarKeyword cluster_89172aab Class: ExprLambda cluster_765fc36c Class: ExprList cluster_ff6df368 Class: ExprListComp cluster_40f7d510 Class: ExprNamedExpr cluster_3ca53503 Class: ExprSet cluster_082bb120 Class: ExprSetComp cluster_87543e76 Class: ExprSlice cluster_3cad63d0 Class: ExprSubscript cluster_82c553fc Class: ExprTuple cluster_39e72c09 Class: ExprUnaryOp cluster_6511cdbb Class: ExprYield cluster_744abd7d Class: ExprYieldFrom node_9a20d162 173: __iter__() node_d1ab17a9 177: iterate() node_9a20d162->node_d1ab17a9 node_48240fce 170: __str__() node_48240fce->node_d1ab17a9 node_41e04090 206: as_dict() node_d62a8769 143: _expr_as_dict() node_41e04090->node_d62a8769 node_4991dc20 280: append() node_4991dc20->node_4991dc20 node_827e3fec 268: iterate() node_1ffa3a75 1118: _get_precedence() node_827e3fec->node_1ffa3a75 node_62a6b608 66: _yield() node_827e3fec->node_62a6b608 node_8b637a36 325: iterate() node_8b637a36->node_1ffa3a75 node_8b637a36->node_62a6b608 node_20d0dcb3 346: iterate() node_20d0dcb3->node_1ffa3a75 node_20d0dcb3->node_62a6b608 node_9f2870f9 370: iterate() node_9f2870f9->node_1ffa3a75 node_78a3151b 109: _join() node_9f2870f9->node_78a3151b node_9f2870f9->node_62a6b608 node_88d03368 389: iterate() node_88d03368->node_1ffa3a75 node_88d03368->node_62a6b608 node_e3d24d07 411: iterate() node_e3d24d07->node_78a3151b node_e3d24d07->node_62a6b608 node_02a59982 449: iterate() node_02a59982->node_78a3151b node_39327193 471: iterate() node_39327193->node_78a3151b node_39327193->node_62a6b608 node_2ed307ee 488: iterate() node_2ed307ee->node_78a3151b node_6f680d2b 500: iterate() node_6f680d2b->node_62a6b608 node_b8628f86 517: iterate() node_b8628f86->node_78a3151b node_b8628f86->node_62a6b608 node_6160c844 535: iterate() node_6160c844->node_6160c844 node_6160c844->node_1ffa3a75 node_6160c844->node_62a6b608 node_7ba44645 561: iterate() node_7ba44645->node_78a3151b node_07735c09 602: iterate() node_07735c09->node_62a6b608 node_a156dbfe 644: iterate() node_a156dbfe->node_62a6b608 node_a8887bb1 686: iterate() node_a8887bb1->node_78a3151b node_10f880ab 702: iterate() node_10f880ab->node_78a3151b node_10f880ab->node_62a6b608 node_a3bd5659 815: iterate() node_a3bd5659->node_62a6b608 node_9e900d1f 844: iterate() node_9e900d1f->node_78a3151b node_c6c0fd4d 860: iterate() node_c6c0fd4d->node_78a3151b node_c6c0fd4d->node_62a6b608 node_1971c165 880: iterate() node_1971c165->node_62a6b608 node_405f1ad9 909: _to_binop() node_405f1ad9->node_405f1ad9 node_684d5478 901: iterate() node_684d5478->node_1ffa3a75 node_684d5478->node_62a6b608 node_12024f9c 924: modernize() node_12024f9c->node_405f1ad9 node_12024f9c->node_12024f9c node_bc687aa7 960: iterate() node_bc687aa7->node_78a3151b node_36830fe7 986: iterate() node_36830fe7->node_1ffa3a75 node_36830fe7->node_62a6b608 node_9e279547 629: iterate() node_9e279547->node_62a6b608 node_022a2c8d 616: iterate() node_022a2c8d->node_62a6b608 node_f6e21f1a 1001: iterate() node_f6e21f1a->node_62a6b608 node_0606d839 1016: iterate() node_0606d839->node_62a6b608 node_d7d7003e 1404: _build() node_696ba234 1122: _build_attribute() node_696ba234->node_4991dc20 node_696ba234->node_d7d7003e node_58324d21 1134: _build_binop() node_58324d21->node_d7d7003e node_81537872 1142: _build_boolop() node_81537872->node_d7d7003e node_fdcb457c 1149: _build_call() node_fdcb457c->node_d7d7003e node_31650976 1156: _build_compare() node_31650976->node_d7d7003e node_3ec975e5 1164: _build_comprehension() node_3ec975e5->node_d7d7003e node_fc2e30c9 1173: _build_constant() node_fc2e30c9->node_d7d7003e node_96b20815 1212: _build_dict() node_96b20815->node_d7d7003e node_e69562f4 1219: _build_dictcomp() node_e69562f4->node_d7d7003e node_9970bbb1 1227: _build_formatted() node_9970bbb1->node_d7d7003e node_64a53ddd 1237: _build_generatorexp() node_64a53ddd->node_d7d7003e node_b8d906bc 1244: _build_ifexp() node_b8d906bc->node_d7d7003e node_558c68c1 1252: _build_joinedstr() node_558c68c1->node_d7d7003e node_00054d97 1262: _build_keyword() node_00054d97->node_d7d7003e node_6c585246 1268: _build_lambda() node_6c585246->node_d7d7003e node_a1022358 1438: safe_get_expression() node_6c585246->node_a1022358 node_d2443b39 1285: _build_list() node_d2443b39->node_d7d7003e node_f3e5a53d 1289: _build_listcomp() node_f3e5a53d->node_d7d7003e node_fe746ff6 1297: _build_named_expr() node_fe746ff6->node_d7d7003e node_a7b2c5be 1301: _build_set() node_a7b2c5be->node_d7d7003e node_4bdb09a3 1305: _build_setcomp() node_4bdb09a3->node_d7d7003e node_933455f6 1309: _build_slice() node_933455f6->node_d7d7003e node_90c9748a 1317: _build_starred() node_90c9748a->node_d7d7003e node_d64f1b52 1321: _build_subscript() node_d64f1b52->node_d7d7003e node_9c57870c 1350: _build_tuple() node_9c57870c->node_d7d7003e node_b49021c5 1360: _build_unaryop() node_b49021c5->node_d7d7003e node_8aeed8bf 1364: _build_yield() node_8aeed8bf->node_d7d7003e node_60bd4182 1368: _build_yield_from() node_60bd4182->node_d7d7003e node_3b9e331c 132: _field_as_dict() node_d62a8769->node_3b9e331c node_3b9e331c->node_3b9e331c node_78a3151b->node_62a6b608 node_62a6b608->node_1ffa3a75 node_62a6b608->node_62a6b608 node_c542fa60 1408: get_expression() node_c542fa60->node_d7d7003e node_a1022358->node_c542fa60 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_4ceee077 File: base cluster_75d75fea Class: Extension cluster_d860edd8 Class: Extensions node_1f92d2c7 56: generic_inspect() node_2da3f5d5 48: inspect() node_1f92d2c7->node_2da3f5d5 node_47a18a52 39: generic_visit() node_5404e6df 31: visit() node_47a18a52->node_5404e6df node_fd8132a9 313: __init__() node_b5437a08 322: add() node_fd8132a9->node_b5437a08 node_e877cb97 359: _load_extension() node_784e4567 348: _load_extension_path() node_e877cb97->node_784e4567 node_3081a0a7 450: load_extensions() node_3081a0a7->node_fd8132a9 node_3081a0a7->node_b5437a08 node_3081a0a7->node_e877cb97 dataclasses.py
Built-in extension adding support for dataclasses.
This extension re-creates __init__
methods of dataclasses during static analysis.
G cluster_e4e8e94d File: dataclasses cluster_cb35b0ed Class: DataclassesExtension node_ab461c4a 227: on_package_loaded() node_801f66cc 203: _apply_recursively() node_ab461c4a->node_801f66cc node_801f66cc->node_801f66cc node_8e6a32b6 195: _del_members_annotated_as_initvar() node_801f66cc->node_8e6a32b6 node_3bbcf2f7 157: _set_dataclass_init() node_801f66cc->node_3bbcf2f7 node_be930a84 49: _dataclass_arguments() node_e1a5c989 25: _dataclass_decorator() node_be930a84->node_e1a5c989 node_15816b8b 32: _expr_args() node_be930a84->node_15816b8b node_81d3ff0c 66: _dataclass_parameters() node_81d3ff0c->node_be930a84 node_a1631db6 55: _field_arguments() node_81d3ff0c->node_a1631db6 node_15816b8b->node_15816b8b node_a1631db6->node_15816b8b node_2772cd46 139: _reorder_parameters() node_3bbcf2f7->node_e1a5c989 node_3bbcf2f7->node_81d3ff0c node_3bbcf2f7->node_2772cd46 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_0e931907 File: finder cluster_1e142691 Class: ModuleFinder node_8cae3ee3 102: __init__() node_9b227b74 386: _extend_from_pth_files() node_8cae3ee3->node_9b227b74 node_75e05d07 119: append_search_path() node_8cae3ee3->node_75e05d07 node_9db55af2 374: _contents() node_9b227b74->node_9db55af2 node_9b227b74->node_75e05d07 node_e1369b70 442: _handle_pth_file() node_9b227b74->node_e1369b70 node_ef164ded 395: _filter_py_modules() node_fa972d54 359: _module_name_path() node_f572517e 403: _top_module_name() node_e4bf52ed 132: insert_search_path() node_f572517e->node_e4bf52ed node_3f4043da 229: find_package() node_3f4043da->node_9db55af2 node_a0080f74 427: _is_pkg_style_namespace() node_3f4043da->node_a0080f74 node_7c2f5156 146: find_spec() node_7c2f5156->node_fa972d54 node_7c2f5156->node_f572517e node_7c2f5156->node_3f4043da node_c950ef1d 276: iter_submodules() node_c950ef1d->node_ef164ded node_c950ef1d->node_c950ef1d node_99a520bd 342: submodules() node_99a520bd->node_c950ef1d node_40dc9bf2 472: _handle_editable_module() node_8eb609a8 51: _match_pattern() node_40dc9bf2->node_8eb609a8 node_e1369b70->node_40dc9bf2 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_bcb57fa8 File: git node_81fce214 25: _normalize() node_8c63efc9 31: assert_git_repo() node_6cd5e332 102: tmp_worktree() node_6cd5e332->node_81fce214 node_6cd5e332->node_8c63efc9 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_e7259c0a File: importer node_abb44035 17: _error_details() node_1dcc15c9 43: dynamic_import() node_1dcc15c9->node_abb44035 node_efcc90d6 22: sys_path() node_1dcc15c9->node_efcc90d6 loader.py
This module contains all the logic for loading API data from sources or compiled modules.
G cluster_9bde4566 File: loader cluster_ccbb2918 Class: GriffeLoader node_6ac54592 52: __init__() node_b88c1b4e 624: _create_module() node_2cd49121 709: _expand_wildcard() node_2e1f9419 679: _get_or_create_parent_module() node_2e1f9419->node_b88c1b4e node_c2e7224e 652: _inspect_module() node_73c223a4 525: _load_module() node_ae5fe92e 544: _load_module_path() node_73c223a4->node_ae5fe92e node_ae5fe92e->node_b88c1b4e node_ae5fe92e->node_c2e7224e node_b62f4856 569: _load_submodules() node_ae5fe92e->node_b62f4856 node_a0e21b2a 632: _visit_module() node_ae5fe92e->node_a0e21b2a node_15305598 510: _load_package() node_15305598->node_73c223a4 node_cad57fa9 305: expand_wildcards() node_15305598->node_cad57fa9 node_9d887fa8 573: _load_submodule() node_9d887fa8->node_2e1f9419 node_9d887fa8->node_73c223a4 node_b62f4856->node_9d887fa8 node_8306773d 192: _post_load() node_077afcc7 264: expand_exports() node_8306773d->node_077afcc7 node_8306773d->node_cad57fa9 node_077afcc7->node_077afcc7 node_cad57fa9->node_2cd49121 node_cad57fa9->node_cad57fa9 node_f0190ced 100: load() node_cad57fa9->node_f0190ced node_f0190ced->node_c2e7224e node_f0190ced->node_15305598 node_f0190ced->node_8306773d node_7fb01726 208: resolve_aliases() node_7fb01726->node_cad57fa9 node_0113e66b 421: resolve_module_aliases() node_7fb01726->node_0113e66b node_0113e66b->node_f0190ced node_0113e66b->node_0113e66b node_737ddc71 718: load() node_737ddc71->node_6ac54592 node_737ddc71->node_f0190ced node_737ddc71->node_7fb01726 node_583c952f 823: load_git() node_583c952f->node_737ddc71 node_93e1aa1a 908: load_pypi() node_93e1aa1a->node_737ddc71 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_a49bafc5 File: logger cluster_6c5ae9f9 Class: Logger node_7e201e31 0: (global)() node_6582080d 43: _get() node_7e201e31->node_6582080d node_2f975528 49: _patch_loggers() node_2f3db781 93: get_logger() node_2f3db781->node_6582080d node_8965df61 105: patch_loggers() node_8965df61->node_2f975528 merger.py
This module contains utilities to merge stubs data and concrete data.
G cluster_1322c160 File: merger node_1a52d05b 37: _merge_attribute_stubs() node_c8386a00 49: _merge_stubs_docstring() node_1a52d05b->node_c8386a00 node_24f2b1fc 21: _merge_class_stubs() node_24f2b1fc->node_c8386a00 node_2afb347e 67: _merge_stubs_members() node_24f2b1fc->node_2afb347e node_e2e96778 59: _merge_stubs_overloads() node_24f2b1fc->node_e2e96778 node_10aeee7b 54: _merge_stubs_type_parameters() node_24f2b1fc->node_10aeee7b node_de5dceac 28: _merge_function_stubs() node_de5dceac->node_c8386a00 node_de5dceac->node_10aeee7b node_ca45d8d7 15: _merge_module_stubs() node_ca45d8d7->node_c8386a00 node_ca45d8d7->node_2afb347e node_ca45d8d7->node_e2e96778 node_2afb347e->node_1a52d05b node_2afb347e->node_de5dceac node_d6635b26 44: _merge_type_alias_stubs() node_2afb347e->node_d6635b26 node_d6635b26->node_c8386a00 node_d6635b26->node_10aeee7b node_fa8562a1 110: merge_stubs() node_fa8562a1->node_ca45d8d7 mixins.py
This module contains some mixins classes that hold shared methods of the different kinds of objects, and aliases.
G cluster_05d41eb4 File: mixins cluster_4dd2f82f Class: GetMembersMixin cluster_31ae6063 Class: DelMembersMixin cluster_1c44da7c Class: SetMembersMixin node_7fb7b07f 97: __delitem__() node_c5c24c74 22: _get_parts() node_7fb7b07f->node_c5c24c74 node_0a672d1a 124: del_member() node_0a672d1a->node_0a672d1a node_0a672d1a->node_c5c24c74 node_902edd03 42: __getitem__() node_902edd03->node_c5c24c74 node_b0c202d7 64: get_member() node_b0c202d7->node_b0c202d7 node_b0c202d7->node_c5c24c74 node_5120fa63 157: __setitem__() node_5120fa63->node_c5c24c74 node_6782e136 183: set_member() node_6782e136->node_6782e136 node_6782e136->node_c5c24c74 models.py
This module contains our models definitions, to represent Python objects (and other aspects of Python APIs)... in Python.
G cluster_8f8ff995 File: models cluster_69e0702d Class: Docstring cluster_e8c45f71 Class: Parameter cluster_b0ea5745 Class: Parameters cluster_d92aecd6 Class: TypeParameters cluster_5527d766 Class: Object cluster_cb69d77c Class: Alias cluster_fe258588 Class: Class cluster_a2ac1279 Class: Function node_53544fe5 1280: __init__() node_0408d660 2049: _update_target_aliases() node_53544fe5->node_0408d660 node_0758f7ed 2033: _resolve_target() node_e07cb2a6 2000: resolve_target() node_0758f7ed->node_e07cb2a6 node_f474c666 1457: as_json() node_f474c666->node_f474c666 node_09b570f1 1669: filter_members() node_09b570f1->node_09b570f1 node_b2569b49 1656: has_labels() node_b2569b49->node_b2569b49 node_67c28909 1435: inherited_members() node_67c28909->node_53544fe5 node_b08ad553 1569: is_kind() node_b08ad553->node_b08ad553 node_c8c6792e 1415: members() node_c8c6792e->node_53544fe5 node_3831baaa 1396: parent() node_3831baaa->node_0408d660 node_34cb8d75 1778: resolve() node_34cb8d75->node_34cb8d75 node_f6c1cec4 1951: target() node_f6c1cec4->node_e07cb2a6 node_94464b3c 2326: _mro() node_94464b3c->node_94464b3c node_33d44898 2337: mro() node_33d44898->node_94464b3c node_1a54e3e4 2274: parameters() node_6f28bc5d 298: __init__() node_1a54e3e4->node_6f28bc5d node_f5ee760e 155: parse() node_bb511983 151: parsed() node_bb511983->node_f5ee760e node_da9bb942 2367: __init__() node_da9bb942->node_6f28bc5d node_8c845cfb 569: __init__() node_e9109def 478: __init__() node_8c845cfb->node_e9109def node_37161dc5 767: inherited_members() node_37161dc5->node_53544fe5 node_3c02eea4 1138: resolve() node_3c02eea4->node_3c02eea4 node_a0211ca2 264: as_dict() node_a0211ca2->node_a0211ca2 stats.py
This module contains utilities to compute loading statistics, like time spent visiting modules statically or dynamically.
G cluster_933d92a9 File: stats cluster_3df880d1 Class: Stats node_701c1648 20: __init__() node_174501c3 74: _itercount() node_701c1648->node_174501c3 node_174501c3->node_174501c3 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_bd530df0 File: tests node_73af85f0 403: module_vtree() node_9f5e6410 360: vtree() node_73af85f0->node_9f5e6410 node_b827dfcc 309: temporary_inspected_module() node_90ccc42d 54: temporary_pyfile() node_b827dfcc->node_90ccc42d node_42becf08 189: temporary_inspected_package() node_fc3653ff 72: temporary_pypackage() node_42becf08->node_fc3653ff node_4401608d 263: temporary_visited_module() node_4401608d->node_90ccc42d node_ef6ea04a 121: temporary_visited_package() node_ef6ea04a->node_fc3653ff