Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] type pylance #696

Open
CAPITAINMARVEL opened this issue Sep 10, 2023 · 7 comments
Open

[BUG] type pylance #696

CAPITAINMARVEL opened this issue Sep 10, 2023 · 7 comments

Comments

@CAPITAINMARVEL
Copy link
Contributor

CAPITAINMARVEL commented Sep 10, 2023

Describe the bug
so I did try the example from github and i have a pylance error

To Reproduce
(beanie example)

other issue
#807 and #864

@roman-right
Copy link
Member

Thank you for the catch

@CAPITAINMARVEL
Copy link
Contributor Author

I also have another isue with sorting

It is not possible to assign the argument of type “int” to the parameter “args” of type “str | Tuple[str, SortDirection] | List[Tuple[str, SortDirection]] | None” in “sort” function
Cannot assign type 'int' to type 'str | Tuple[str, SortDirection] | List[Tuple[str, SortDirection]] | None »
“int” is not compatible with “str”
“int” is not compatible with “Tuple[str, SortDirection]”
“int” is not compatible with “List[Tuple[str, SortDirection]]”
Type cannot be assigned to type “None” Pylance

await DocPlayer.find(DocPlayer.lb.rep >0).sort(-DocPlayer.lb.rep).project(ProjectTopRep).to_list()

class ProjectTopRep(BaseModel):
    player_id: int
    rep: int

    class Settings:
        projection = {"player_id": True, "rep": "$lb.rep"}

@CAPITAINMARVEL
Copy link
Contributor Author

CAPITAINMARVEL commented Sep 21, 2023

Unable to assign argument of type “dict[bool, bool]” to parameter “expression” of type “Dict[ExpressionField | str, Any]” in the “set” function
Unable to assign type 'bool' to type 'ExpressionField | str »
“bool” is not compatible with “ExpressionField”
“bool” is not compatible with “str”Pylanc

how to do it :

class Player(Document):
    player_id: int
    hidestats: bool

await Product.find_one().set({Player.hidestats : True})

It does update the field but Pylance do not like it

@CAPITAINMARVEL
Copy link
Contributor Author

class Quiz(Document):
    right: int
await Quiz.find_one(Quiz.id == self.quiz.id).inc({Quiz.right : 1})

Unable to assign argument of type “dict[int, int]” to parameter “expression” of type “Dict[ExpressionField | str, Any]” in the “inc” function
Cannot assign type 'int' to type 'ExpressionField | str »
“int” is not compatible with “ExpressionField”
“int” is not compatible with “str”PylancereportGeneralTypeIssues
(variable) right: int

@CAPITAINMARVEL
Copy link
Contributor Author

CAPITAINMARVEL commented Sep 22, 2023

class Player(Document):
    money: int
        data = await Player.find(
            Player.money >0,
            sort=[(Player.money, -1)]
            ).to_list()

Unable to assign argument of type “list[tuple[int, Literal[-1]]]” to parameter “sort” of type “str | List[Tuple[str, SortDirection]] | None” in “find” function
“int” is not compatible with “str”
“Literal[-1]” is not compatible with “SortDirection” Pylance

class Player(Document):
    money: int
        data = await Player.find(
            Player.money >0).sort(-Player.money).to_list()

Cannot assign argument of type "int" to parameter "args" of type "str | Tuple[str, SortDirection] | List[Tuple[str, SortDirection]] | None” in “sort” function
Cannot assign type 'int' to type 'str | Tuple[str, SortDirection] | List[Tuple[str, SortDirection]] | None »
“int” is not compatible with “str”
“int” is not compatible with “Tuple[str, SortDirection]”
“int” is not compatible with “List[Tuple[str, SortDirection]]”
Type cannot be assigned to type “None” Pylance

@HazyFish
Copy link

Any plans to address the typing issues?

@CAPITAINMARVEL
Copy link
Contributor Author

Any plans to address the typing issues?

#929
i fixed it there no idea if its gonna be approved

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

No branches or pull requests

3 participants