1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
# Regression test for #893
- case: annotated_should_not_interfere
main: |
from dataclasses import dataclass
from typing_extensions import Annotated, TypedDict, reveal_type
from myapp.models import Blog
class IntegerType:
def __init__(self, min_value: int, max_value: int) -> None:
pass
@dataclass(unsafe_hash=True)
class RatingComposite:
max_value: Annotated[int, IntegerType(min_value=1, max_value=10)] = 5
class Obj(TypedDict):
foo: int
class X:
x: Annotated[Blog, Obj]
reveal_type(X().x) # N: Revealed type is "myapp.models.Blog"
reveal_type(X().x.foo) # E: "Blog" has no attribute "foo" [attr-defined] # N: Revealed type is "Any"
installed_apps:
- myapp
files:
- path: myapp/__init__.py
- path: myapp/models.py
content: |
from django.db import models
class Blog(models.Model):
text = models.CharField(max_length=100)
|