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] Issue with parameter expression from inc set and update #1020

Closed
CAPITAINMARVEL opened this issue Sep 5, 2024 · 1 comment
Closed

Comments

@CAPITAINMARVEL
Copy link
Contributor

Describe the bug
This bug is a type hint issue

To Reproduce

Please add a code snippet here, that reproduces the problem completely
```py
from beanie import Document

class Player(Document):  # This is the model
    name: str
    money: int

async def main():
    doc = Player(name="test",money=500)
    await doc.set({Player.money:100})
    await doc.inc({Player.money:100})

Expected behavior
The behavior is only changed for the type hint, so i expect set allowing any type and inc allowing number type
The $inc operator accepts positive and negative values.
The $set operator replaces the value of a field with the specified value.

Additional context
Unable to assign argument of type “dict[int, int]” to parameter “expression” of type “Dict[ExpressionField | str, Any]” in the “inc” function
Type “int” is not compatible with type “ExpressionField | str »
“int” is not compatible with “ExpressionField”
“int” is not compatible with “str”PylancereportArgumentType

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

@CAPITAINMARVEL CAPITAINMARVEL changed the title [BUG] Issue with parameter expression: Dict[ExpressionField | str, Any] from .set and .inc method not allowing any as key for set and for inc a number [BUG] Issue with parameter expression from inc set and update Sep 5, 2024
@CAPITAINMARVEL
Copy link
Contributor Author

Ill make the pull request tomorrow

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

No branches or pull requests

1 participant