vtkmodules.generate_pyi#

This program will generate .pyi files for all the VTK modules in the “vtkmodules” package (or whichever package you specify). These files are used for type checking and autocompletion in some Python IDEs.

The VTK modules must be in Python’s path when you run this script. Options are as follows:

-p PACKAGE The package to generate .pyi files for [vtkmodules] -o OUTPUT The output directory [default is the package directory] -e EXT The file suffix [.pyi] -i IMPORTER The static module importer (for static builds only) -h HELP

With no arguments, the script runs with the defaults (the .pyi files are put inside the existing vtkmodules package). This is equivalent to the following:

python -m vtkmodules.generate_pyi -p vtkmodules

To put the pyi files somewhere else, perhaps with a different suffix:

python -m vtkmodules.generate_pyi -o /path/to/vtkmodules -e .pyi

To generate pyi files for just one or two modules:

python -m vtkmodules.generate_pyi -p vtkmodules vtkCommonCore vtkCommonDataModel

To generate pyi files for your own modules in your own package:

python -m vtkmodules.generate_pyi -p mypackage mymodule [mymodule2 ...]

Module Contents#

Classes#

Graph

A graph for topological sorting.

Node

A node for the graph.

Functions#

isvtkmethod

Check for VTK’s custom method descriptor

isnamespace

Check for namespaces within a module

isenum

Check for enums (currently derived from int)

typename

Generate a typename that can be used for annotation.

typename_forward

Generate a typename, or if necessary, a forward reference.

build_graph

Build a graph from a module’s dictionary.

sorted_graph_helper

Helper for topological sorting.

sorted_graph

Sort a graph and return the sorted items.

topologically_sorted_items

Return the items from a module’s dictionary, topologically sorted.

parse_error

Print a parse error, syntax or otherwise.

annotation_text

Return the new text to be used for an annotation.

fix_annotations

Fix the annotations in a method definition. The signature must be a single-line function def, no decorators.

push_signature

Process a method signature and add it to the list.

get_signatures

Return a list of method signatures found in the docstring.

get_constructors

Get constructors from the class documentation.

handle_static

If method has no “self”, add @static decorator.

add_indent

Add the given indent before every line in the string.

namespace_pyi

Fake a namespace by creating a dummy class.

class_pyi

Generate all the method stubs for a class.

module_pyi

Generate the contents of a .pyi file for a VTK module.

main

Data#

API#

vtkmodules.generate_pyi.types#

‘set(…)’

vtkmodules.generate_pyi.ismethod#

None

vtkmodules.generate_pyi.isclass#

None

vtkmodules.generate_pyi.vtkmethod#

‘type(…)’

vtkmodules.generate_pyi.template#

‘type(…)’

vtkmodules.generate_pyi.isvtkmethod(m)#

Check for VTK’s custom method descriptor

vtkmodules.generate_pyi.isnamespace(m)#

Check for namespaces within a module

vtkmodules.generate_pyi.isenum(m)#

Check for enums (currently derived from int)

vtkmodules.generate_pyi.typename(o)#

Generate a typename that can be used for annotation.

vtkmodules.generate_pyi.typename_forward(o)#

Generate a typename, or if necessary, a forward reference.

class vtkmodules.generate_pyi.Graph#

A graph for topological sorting.

Initialization

__getitem__(name)#
__setitem__(name, node)#
class vtkmodules.generate_pyi.Node(o, d)#

A node for the graph.

Initialization

vtkmodules.generate_pyi.build_graph(d)#

Build a graph from a module’s dictionary.

vtkmodules.generate_pyi.sorted_graph_helper(graph, m, visited, items)#

Helper for topological sorting.

vtkmodules.generate_pyi.sorted_graph(graph)#

Sort a graph and return the sorted items.

vtkmodules.generate_pyi.topologically_sorted_items(d)#

Return the items from a module’s dictionary, topologically sorted.

vtkmodules.generate_pyi.string#

‘compile(…)’

vtkmodules.generate_pyi.identifier#

‘compile(…)’

vtkmodules.generate_pyi.indent#

‘compile(…)’

vtkmodules.generate_pyi.has_self#

‘compile(…)’

vtkmodules.generate_pyi.keychar#

‘compile(…)’

vtkmodules.generate_pyi.parse_error(message, text, begin, pos)#

Print a parse error, syntax or otherwise.

vtkmodules.generate_pyi.annotation_text(a, text, is_return)#

Return the new text to be used for an annotation.

vtkmodules.generate_pyi.fix_annotations(signature)#

Fix the annotations in a method definition. The signature must be a single-line function def, no decorators.

vtkmodules.generate_pyi.push_signature(o, l, signature)#

Process a method signature and add it to the list.

vtkmodules.generate_pyi.get_signatures(o)#

Return a list of method signatures found in the docstring.

vtkmodules.generate_pyi.get_constructors(c)#

Get constructors from the class documentation.

vtkmodules.generate_pyi.handle_static(o, signature)#

If method has no “self”, add @static decorator.

vtkmodules.generate_pyi.add_indent(s, indent)#

Add the given indent before every line in the string.

vtkmodules.generate_pyi.namespace_pyi(c, mod)#

Fake a namespace by creating a dummy class.

vtkmodules.generate_pyi.class_pyi(c)#

Generate all the method stubs for a class.

vtkmodules.generate_pyi.module_pyi(mod, output)#

Generate the contents of a .pyi file for a VTK module.

vtkmodules.generate_pyi.main(argv=sys.argv)#