Open egregors opened 3 years ago
@egregors Hi! Thanks for letting us know about the problem. Sadly, I don't know what should we fix to solve this issue.
I am not a PyCharm user, so I cannot tell if it is the same for me.
I spent some time messing around with django-stubs files, and found out something interesting.
Temporary fix : If you rename the __init__.pyi
file in the site-packages/django-stubs folder to __init__.py
, all Django template tags (built-in or custom) start working again, and it has no observable affect on the working of the django-stubs package.
Even having an empty __init__.pyi
file in the django-stubs folder with nothing else breaks Pycharm's analyzer. This is probably something that is an internal issue with pycharm, and not a problem with this package.
Now I went through mypy's documentation for stub packages to check whether changing from __init__.pyi
to __init__.py
actually makes a difference, and it seems that it's just a convention. Even PEP 561's spec doesn't restrain you to use the .pyi
extension for __init__
files of stub-only packages. So technically, you could rename it manually, at least till PyCharm releases a patch.
There is a PyCharm an existing issue: https://youtrack.jetbrains.com/issue/PY-37744
Is this template tags issue still affecting anyone?
The issue mentioned by 1oglop1 PY-37744 has been marked fixed (will be part of the next release), but that issue was about Model/QuerySet type inference, so I doubt it had any effect on Django template tags.
If this issue still occurs for anyone, then please report a new PyCharm ticket at https://youtrack.jetbrains.com/issues/PY
Bug report
What's wrong
Looks like presence
django-stubs
package breaks PyCharm tag resolving mechanism for Django templates.Literally, all Django template tags (built-in or custom) become unresolved and the only way to fix it – remove
django-stubs
package .This is a huge thread from JetBrains tech support site about this problem. https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003433179-Pycharm-suddenly-not-detecting-ANY-Django-tags-in-template
How is that should be
I believe, stubs package shouldn't break the base mechanisms for one of the most popular Python IDE.
System information
python
version: 3.9django
version: Anymypy
version: 0.790django-stubs
version: 1.7.0PyCharm
version: 2020.3