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

fix function overload of Library.simple_tag #2390

Merged

Conversation

asottile
Copy link
Contributor

@asottile asottile commented Oct 3, 2024

previously failing with:

/tmp/django-stubs/tests/typecheck/template/test_library.yml:68: 
E   pytest_mypy_plugins.utils.TypecheckAssertionError: Invalid output: 
E   Actual:
E     main:7: error: No overload variant of "simple_tag" of "Library" matches argument types "Callable[[str], str]", "str"  [call-overload] (diff)
E     main:7: note: Possible overload variants:     (diff)
E     main:7: note:     def [_C] simple_tag(self, func: _C) -> _C (diff)
E     main:7: note:     def simple_tag(self, takes_context: Optional[bool] = ..., name: Optional[str] = ...) -> Callable[[_C], _C] (diff)
E     main:7: note: Revealed type is "Any"          (diff)
E   Expected:
E     main:7: note: Revealed type is "def (s: builtins.str) -> builtins.str" (diff)
E   Alignment of first line difference:
E     E: main:7: note: Revealed type is "def (s: builtins.str) -> builtins.str"...
E     A: main:7: error: No overload variant of "simple_tag" of "Library" matches ...
E        

real usage: https://github.com/getsentry/sentry/blob/a1acfad04851c894d29daa5e2ddd78d25a506be6/src/sentry/templatetags/sentry_assets.py#L15

implementation: https://github.com/django/django/blob/c334c1a8ff4579cdb1dd77cce8da747070ac9fc4/django/template/library.py#L121

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@sobolevn sobolevn merged commit 79ee646 into typeddjango:master Oct 4, 2024
38 checks passed
@asottile asottile deleted the library-simple-tag-other-args branch October 5, 2024 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants