Skip to content

PydanticMixin doesn't have super() call which leads to issues with decomposition.  #177

@OlehChyhyryn

Description

@OlehChyhyryn

https://github.com/snok/flake8-type-checking/blob/7aa077e3a34d966c3810c2d2ee6f5b098dcb2e00/flake8_type_checking/checker.py#L201C2-L201C2

def visit_FunctionDef(self, node: FunctionDef) -> None:
        """Remove and map function arguments and returns."""
        if self._function_is_wrapped_by_validate_arguments(node):
            for path in [node.args.args, node.args.kwonlyargs, node.args.posonlyargs]:
                for argument in path:
                    if hasattr(argument, 'annotation') and argument.annotation:
                        self.visit(argument.annotation)

    def visit_AsyncFunctionDef(self, node: AsyncFunctionDef) -> None:
        """Remove and map function arguments and returns."""
        if self._function_is_wrapped_by_validate_arguments(node):
            for path in [node.args.args, node.args.kwonlyargs, node.args.posonlyargs]:
                for argument in path:
                    if hasattr(argument, 'annotation') and argument.annotation:
                        self.visit(argument.annotation)

At the moment, plugin code is organized in the way, where main logic is keep the same, but additional logic can be added using decomposition with Mixins.

The behaviour supposed to have chain of super calls in each of Mixin class, to apply each of visit function, if required by option.

At the moment, PydanticMixin implemented without super call, which leads to heavy dependence on MRO for future mixins.

For my opinion, it should be resolved by adding super call to Pydantic Mixin (quick solution), or changing the decomposition pattern.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions