Closed
Description
mypy 0.990 was released today. When I have mypy 0.990 and mypy_django_plugin
enabled, it fails with AssertionError
on code that uses the django_cas_ng
package.
The problematic code appears to be:
from django.conf import settings as django_settings
# ...
def get_service_url(request: HttpRequest, redirect_to: Optional[str] = None) -> str:
"""Generates application django service URL for CAS"""
if hasattr(django_settings, 'CAS_ROOT_PROXIED_AS') and django_settings.CAS_ROOT_PROXIED_AS:
# ^^^^^^^^^^^
Link to source: https://github.com/django-cas-ng/django-cas-ng/blob/a67653cf85244aa137edbabb3c2e94e07f97c773/django_cas_ng/utils.py#L50-L53
Output:
.../site-packages/django_cas_ng/utils.py:53: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.990
The stacktrace:
Traceback (most recent call last):
File "mypy/checkexpr.py", line 4665, in accept
File "mypy/nodes.py", line 1957, in accept
File "mypy/checkexpr.py", line 2769, in visit_op_expr
File "mypy/checkexpr.py", line 3406, in check_boolean_op
File "mypy/checker.py", line 5184, in find_isinstance_check
File "mypy/checker.py", line 5223, in find_isinstance_check_helper
File "mypy/checker.py", line 6486, in hasattr_type_maps
File "mypy/checker.py", line 6522, in has_valid_attribute
File "mypy/checkmember.py", line 191, in analyze_member_access
File "mypy/checkmember.py", line 210, in _analyze_member_access
File "mypy/checkmember.py", line 331, in analyze_instance_member_access
File "mypy/checkmember.py", line 547, in analyze_member_var_access
File ".../site-packages/mypy_django_plugin/transformers/settings.py", line 24, in get_type_of_settings_attribute
assert isinstance(ctx.context, MemberExpr)
AssertionError:
System information
- OS: macOS
python
version: 3.11.0django
version: 4.1.3mypy
version: 0.990django-stubs
version: 1.13.0django-stubs-ext
version: 0.7.0