beanie icon indicating copy to clipboard operation
beanie copied to clipboard

[BUG] pylance for set inc and delete method (function

Open CAPITAINMARVEL opened this issue 1 year ago • 4 comments

Describe the bug

So im trying update a document using set (for a boolean and i have this error pylance : 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”PylancereportGeneralTypeIssues (variable) published: bool

im trying increase an integer using the inc method and have this error pylance : 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” Pylance

error on using delete method Missing argument for parameter "self"PylancereportGeneralTypeIssues (method) delete: _Wrapped[..., Unknown, (self: Unknown, *args: Unknown, skip_actions: List[ActionDirections | str] | None = None, **kwargs: Unknown), Coroutine[Any, Any, Unknown ]]

To Reproduce

class Character(Document):
    published: bool
    age: int
    class Settings:
        name = "Characters"
    test = await Character.find_one()
    if test:
        await test.set({Character.published: True})
        await test.inc({Character.age:1})
        await test.delete()




CAPITAINMARVEL avatar Sep 16 '23 11:09 CAPITAINMARVEL

the function itself do the correct things, its just the pylance errors (i tried my best to explain it im still new on doing github issues)

CAPITAINMARVEL avatar Sep 16 '23 11:09 CAPITAINMARVEL

Hi! Thank you for the catch. I'll check and fix it this/next week.

roman-right avatar Oct 02 '23 21:10 roman-right

class DocPlayer(Document):
    money: int

await DocPlayer.find_all().sort(-DocPlayer.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'

another one that is a bit annoying on trying to sort by highest to lowest

CAPITAINMARVEL avatar Oct 03 '23 18:10 CAPITAINMARVEL

Hi, Sorry for the delay. I'll try to pick up typing bugs soon. But I have to fix runtime bugs firstly.

roman-right avatar Dec 03 '23 23:12 roman-right