luigi.mypy

Plugin that provides support for luigi.Task

This Code reuses the code from mypy.plugins.dataclasses https://github.com/python/mypy/blob/0753e2a82dad35034e000609b6e8daa37238bfaa/mypy/plugins/dataclasses.py

Functions

plugin(version)

Classes

TaskAttribute(name, has_default, line, ...)

TaskPlugin(*args, **kwargs)

TaskTransformer(cls, reason, api, task_plugin)

Implement the behavior of gokart.Task.

class luigi.mypy.TaskPlugin(*args: Any, **kwargs: Any)[source]
get_base_class_hook(fullname: str) Callable[[mypy.plugin.ClassDefContext], None] | None[source]
get_function_hook(fullname: str) Callable[[mypy.plugin.FunctionContext], mypy.types.Type] | None[source]

Adjust the return type of the Parameters function.

check_parameter(fullname)[source]
class luigi.mypy.TaskAttribute(name: str, has_default: bool, line: int, column: int, type: Type | None, info: TypeInfo, api: SemanticAnalyzerPluginInterface)[source]
to_argument(current_info: mypy.nodes.TypeInfo, *, of: Literal['__init__']) mypy.nodes.Argument[source]
expand_type(current_info: TypeInfo) Type | None[source]
to_var(current_info: mypy.nodes.TypeInfo) mypy.nodes.Var[source]
serialize() mypy.nodes.JsonDict[source]
classmethod deserialize(info: mypy.nodes.TypeInfo, data: mypy.nodes.JsonDict, api: mypy.plugin.SemanticAnalyzerPluginInterface) TaskAttribute[source]
expand_typevar_from_subtype(sub_type: mypy.nodes.TypeInfo) None[source]

Expands type vars in the context of a subtype when an attribute is inherited from a generic super type.

class luigi.mypy.TaskTransformer(cls: ClassDef, reason: Expression | Statement, api: SemanticAnalyzerPluginInterface, task_plugin: TaskPlugin)[source]

Implement the behavior of gokart.Task.

transform() bool[source]

Apply all the necessary transformations to the underlying gokart.Task

collect_attributes() List[TaskAttribute] | None[source]

Collect all attributes declared in the task and its parents.

All assignments of the form

a: SomeType b: SomeOtherType = …

are collected.

Return None if some base class hasn’t been processed yet and thus we’ll need to ask for another pass.

is_parameter_call(expr: mypy.nodes.Expression) bool[source]

Checks if the expression is a call to luigi.Parameter()

luigi.mypy.plugin(version: str) type[mypy.plugin.Plugin][source]