Skip to content

method_decorator should accept list first argument #78

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

Closed
PeterJCLaw opened this issue May 15, 2019 · 0 comments · Fixed by #90
Closed

method_decorator should accept list first argument #78

PeterJCLaw opened this issue May 15, 2019 · 0 comments · Fixed by #90

Comments

@PeterJCLaw
Copy link
Contributor

PeterJCLaw commented May 15, 2019

The following code is valid, but yields a warning I think is incorrect:

from django.utils.decorators import method_decorator
from wherever import decorator_1, decorator_2

new_decorator = method_decorator(
    [
        decorator_1,
        decorator_2,
    ],
    name='dispatch',
)

errors with:

Argument 1 to "method_decorator" has incompatible type "List[Any]"; expected "Union[Callable[..., Any], Set[Callable[..., Any]], Tuple[Callable[..., Any], Callable[..., Any]]]"

I'm guessing the fix is to add List or perhaps Sequence or Container into the allowed container types in the union. (If you agree that's a good solution I'd be happy to put up a PR)

PeterJCLaw referenced this issue in PeterJCLaw/django-stubs Jun 12, 2019
From reading the source of Django 2.1.9, this seems to be what's
allowed there.

Fixes https://github.com/mkurnikov/django-stubs/issues/78.
mkurnikov referenced this issue Jul 1, 2019
From reading the source of Django 2.1.9, this seems to be what's
allowed there.

Fixes https://github.com/mkurnikov/django-stubs/issues/78.
@TonyRippy TonyRippy mentioned this issue Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant