attr_utils.mypy_plugin

Plugin for mypy which adds support for attr_utils.

New in version 0.4.0.

To use this plugin, add the following to your mypy configuration file:

[mypy]
plugins=attr_utils.mypy_plugin

See https://mypy.readthedocs.io/en/stable/extending_mypy.html#configuring-mypy-to-use-plugins for more information.

Classes:

AttrUtilsPlugin

Plugin for mypy which adds support for attr_utils.

Functions:

add_classmethod_to_class(​api, cls, name, …)

Adds a new classmethod to a class definition.

attr_utils_serialise_serde(​cls_def_ctx)

Handles attr_utils.serialise.serde().

plugin(​version)

Entry point to attr_utils.mypy_plugin.

class AttrUtilsPlugin[source]

Bases: Plugin

Plugin for mypy which adds support for attr_utils.

get_class_decorator_hook(fullname)[source]

Allows mypy to handle decorators that add extra methods to classes.

Parameters

fullname (str) – The full name of the decorator.

Return type

Optional[Callable[[ClassDefContext], None]]

add_classmethod_to_class(api, cls, name, args, return_type, cls_type=None, tvar_def=None)[source]

Adds a new classmethod to a class definition.

Parameters
  • api (SemanticAnalyzerPluginInterface)

  • cls (ClassDef)

  • name (str)

  • args (List[Argument])

  • return_type (Type)

  • cls_type (Optional[Type]) – Default None.

  • tvar_def (Optional[Any]) – Default None.

attr_utils_serialise_serde(cls_def_ctx)[source]

Handles attr_utils.serialise.serde().

Parameters

cls_def_ctx (ClassDefContext)

plugin(version)[source]

Entry point to attr_utils.mypy_plugin.

Parameters

version (str) – The current mypy version.