tortoise-orm
tortoise-orm copied to clipboard
Pylance: Expression of type "ForeignKeyRelation[Unknown]" cannot be assigned to declared type
Describe the bug
To Reproduce
Analyze the following with Pylance in vscode:
class User(Model):
pass
class Profile(Model):
user: fields.ForeignKeyRelation[User] = fields.ForeignKeyField(
"models.User", on_delete=fields.SET_NULL, null=True, blank=True
)
Expected behavior Mypy seems to think it's okay but Pylance doesn't. I can't be sure where the issue lies and I've already spent quite a bit of time investigating this to no avail.
Note this follows the documentation.
https://tortoise-orm.readthedocs.io/en/latest/models.html#improving-relational-type-hinting
Fixed in aa3d51126065f352e21f7e1531b09547e54aee97 👍
Confirming fixed, thank you!