BeanieODM / beanie

Asynchronous Python ODM for MongoDB
http://beanie-odm.dev/
Apache License 2.0
1.94k stars 203 forks source link

[BUG] Pylance strict mode: type of "delete_all" is partially unknown #769

Closed dotKokott closed 7 months ago

dotKokott commented 8 months ago

When using pylance in strict mode a lot of static document methods have a typing issue

Type of "delete_all" is partially unknown
  Type of "delete_all" is "(session: ClientSession | None = None, bulk_writer: BulkWriter | None = None, **pymongo_kwargs: Unknown) -> Coroutine[Any, Any, DeleteResult | None]"Pylance[reportUnknownMemberType](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportUnknownMemberType)

This is not only for delete_all but also for:

And probably more

To Reproduce In VSCode, set pylance type checking mode to strict

class Sample(Document):
    name: str
    age: int
    is_active: bool
    _id: Optional[PydanticObjectId] = None

Sample.delete_all() # pylance issue

Expected behavior I would like to be able to use beanie document functions while using pylance strict type checking mode. Is there a way to fix this apart from ignoring typing on the whole line with # type: ignore?

github-actions[bot] commented 7 months ago

This issue is stale because it has been open 30 days with no activity.

github-actions[bot] commented 7 months ago

This issue was closed because it has been stalled for 14 days with no activity.

fabifont commented 6 months ago

Hi, this problem hasn't been fixed yet. Can you reopen it?