stubs¶
Cincoconfig configuration objects are dynamic in nature which makes working with a cincoconfig
object cumbersome inside of an IDE that attempts to provide autocomplete / Intellisense results.
To work around this, Python type stub files, *.pyi
, can be used that define the structure of a
cincoconfig configuration so that the IDE or type checker can work properly with configuration
objects.
- cincoconfig.generate_stub(config, class_name=None)¶
Generate the Python stub class (pyi file) for a provided Schema instance, Config instance, or ConfigType class. Generating a pyi stub file is useful when developing in an IDE, such as VSCode, to make the autocompleter / Intellisense / Language Server understand the structure of the configuration and properly show autocomplete results and perform type checking / linting.
Save the generated pyi stub file to a location in your project repository and then configure the IDE / type checked (MyPy) to use the directory to load additional type information from.