tortoise-orm icon indicating copy to clipboard operation
tortoise-orm copied to clipboard

Pylance: Expression of type "ForeignKeyRelation[Unknown]" cannot be assigned to declared type

Open jleclanche opened this issue 3 years ago • 2 comments

Describe the bug image

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.

jleclanche avatar Nov 29 '21 19:11 jleclanche

Note this follows the documentation.

https://tortoise-orm.readthedocs.io/en/latest/models.html#improving-relational-type-hinting

jleclanche avatar Nov 29 '21 19:11 jleclanche

Fixed in aa3d51126065f352e21f7e1531b09547e54aee97 👍

BobDotCom avatar May 18 '22 04:05 BobDotCom

Confirming fixed, thank you!

jleclanche avatar Aug 26 '22 20:08 jleclanche