Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
OlehChyhyryn opened this issue Nov 14, 2023 · 0 comments

Comments

@OlehChyhyryn
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant