You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Python 3.7, importing django_stubs_ext causes ImportError: cannot import name 'Protocol' from 'typing' (/usr/local/lib/python3.7/typing.py).
This issue only surfaced in django-stubs 1.10.0 and django-stubs-ext 0.4.0.
The workaround in the meantime is to stay on 1.9.0 and 0.3.0.
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/check.py", line 69, in handle
databases=options['databases'],
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 423, in check
databases=databases,
File "/usr/local/lib/python3.7/site-packages/django/core/checks/registry.py", line 76, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/usr/local/lib/python3.7/site-packages/django/core/checks/templates.py", line 29, in check_string_if_invalid_is_string
for conf in settings.TEMPLATES:
File "/usr/local/lib/python3.7/site-packages/django/conf/__init__.py", line 82, in __getattr__
self._setup(name)
File "/usr/local/lib/python3.7/site-packages/django/conf/__init__.py", line 69, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python3.7/site-packages/django/conf/__init__.py", line 170, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/testsite/testsite/settings.py", line 4, in <module>
import django_stubs_ext
File "/usr/local/lib/python3.7/site-packages/django_stubs_ext/__init__.py", line 5, in <module>
from .types import AnyAttrAllowed as AnyAttrAllowed
File "/usr/local/lib/python3.7/site-packages/django_stubs_ext/types.py", line 1, in <module>
from typing import Any, Protocol
ImportError: cannot import name 'Protocol' from 'typing' (/usr/local/lib/python3.7/typing.py)
How is that should be
If Python 3.7 compatibility is desired, we shuld use Protocol from typing_extensions instead.
System information
OS:
python version: 3.7
django version: 3.2
mypy version: 0.910
django-stubs version: 1.10.0
django-stubs-ext version: 0.4.0
The text was updated successfully, but these errors were encountered:
* Fix stubs related to `(Async)RequestFactory` and `(Async)Client`
* Revert incorrect removal.
* Allow set as `unique_together`, use shared type alias.
* Revert `Q.__init__` to use only `*args, **kwargs` to remove false-positive with `Q(**{...})`
* Add abstract methods to `HttpResponseBase` to create common interface.
* Remove monkey-patched attributes from `HttpResponseBase` subclasses.
* Add QueryDict mutability checks (+ plugin support)
* Fix lint
* Return back GenericForeignKey to `Options.get_fields`
* Minor fixup
* Make plugin code typecheck with `--warn-unreachable`, minor performance increase.
* Better types for `{unique, index}_together` and Options.
* Fix odd type of `URLResolver.urlconf_name` which isn't a str actually.
* Better types for field migration operations.
* Revert form.files to `MultiValueDict[str, UploadedFile]`
* Compatibility fix (#916)
* Do not assume that `Annotated` is always related to django-stubs (fixes#893)
* Restrict `FormView.get_form` return type to `_FormT` (class type argument). Now it is resolved to `form_class` argument if present, but also errors if it is not subclass of _FormT
* Fix CI (make test runnable on 3.8)
* Fix CI (make test runnable on 3.8 _again_)
Bug report
What's wrong
On Python 3.7, importing
django_stubs_ext
causesImportError: cannot import name 'Protocol' from 'typing' (/usr/local/lib/python3.7/typing.py)
.This issue only surfaced in django-stubs 1.10.0 and django-stubs-ext 0.4.0.
The workaround in the meantime is to stay on 1.9.0 and 0.3.0.
How is that should be
If Python 3.7 compatibility is desired, we shuld use
Protocol
fromtyping_extensions
instead.System information
python
version: 3.7django
version: 3.2mypy
version: 0.910django-stubs
version: 1.10.0django-stubs-ext
version: 0.4.0The text was updated successfully, but these errors were encountered: