ruff
30be8844 - [ty] Very basic Django support (#29642)

Commit
6 days ago
[ty] Very basic Django support (#29642) ## Summary This PR adds basic tests for Django support in ty, and adds a first customization point where we now synthesize `.id` and `.pk` attributes for primary keys on Django models. Django support currently relies on `django-types`, a fork of `django-stubs` which requires less special-casing in type checkers. Example ```py from django.db import models class Book(models.Model): isbn = models.CharField(max_length=13, primary_key=True) title = models.CharField() pages = models.IntegerField(null=True) def _(book: Book): reveal_type(book.isbn) # str reveal_type(book.title) # str reveal_type(book.pages) # int | None (because null=True) reveal_type(book.pk) # str (because `isbn` is the primary key) book.id # error: no automatic `id` with a custom primary key ``` ## Test Plan I wrote new Markdown test and also verified all of our assertions against Django's runtime behavior.
Author
Parents
Loading