Skip to content

FireO 2.2.1 issues with pylance and co #219

Description

@ingwinlu

I am currently evaluating if I want to replace my own ORM solution based on pydantic models and some inheritance of base models (very simple, basically can only do crud) with FireO.

However my python language server / tooling complains basically all the time when using FireO:

class User(Model):
    name = TextField()
    age = NumberField()


u = User()
u.name = "Azeem"
u.age = 26
u.save()

Errors (removed filenames):

[{
	"owner": "_generated_diagnostic_collection_name_#10",
	"code": {
		"value": "reportGeneralTypeIssues",
		"target": {
			"$mid": 1,
			"path": "/microsoft/pyright/blob/main/docs/configuration.md",
			"scheme": "https",
			"authority": "github.com",
			"fragment": "reportGeneralTypeIssues"
		}
	},
	"severity": 8,
	"message": "Cannot assign member \"name\" for type \"User\"\n  Expression of type \"Literal['Azeem']\" cannot be assigned to member \"name\" of class \"User\"\n    Member \"__set__\" is unknown\n    \"Literal['Azeem']\" is incompatible with \"TextField\"",
	"source": "Pylance",
	"startLineNumber": 58,
	"startColumn": 3,
	"endLineNumber": 58,
	"endColumn": 7
},{
	"owner": "_generated_diagnostic_collection_name_#10",
	"code": {
		"value": "reportGeneralTypeIssues",
		"target": {
			"$mid": 1,
			"path": "/microsoft/pyright/blob/main/docs/configuration.md",
			"scheme": "https",
			"authority": "github.com",
			"fragment": "reportGeneralTypeIssues"
		}
	},
	"severity": 8,
	"message": "Cannot assign member \"age\" for type \"User\"\n  Expression of type \"Literal[26]\" cannot be assigned to member \"age\" of class \"User\"\n    Member \"__set__\" is unknown\n    \"Literal[26]\" is incompatible with \"NumberField\"",
	"source": "Pylance",
	"startLineNumber": 59,
	"startColumn": 3,
	"endLineNumber": 59,
	"endColumn": 6
}]

I also noticed that things like the .get method seem to indicate wrong types even though when I look at the code I see typevars that should be able to let the language server know the object's class when calling the funciton:

image

Hence my question: Am I doing something completely wrong? Is the type hinting working as expected?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions