Hi guys!
I'm using your library in my project. I have a very strict typing setup, with poetry and python 3.13, and mypy complains about certain things. Using the latest (5.10) version of bson .
Context
...
[tool.poetry.dependencies]
python = "^3.13"
...
[tool.poetry.group.mongo.dependencies]
pymongo = "^4.11.3"
bson = "^0.5.10"
mongoengine = "^0.29.1"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.mypy]
python_version = "3.13"
strict = true
ignore_missing_imports = true
plugins = ["pydantic.mypy"]
explicit_package_bases = true
exclude = [
"tests/types",
]
Issues
- More of a question, but could point to an issue:
from bson import ObjectId
Yields the typing error:
Module "bson" does not explicitly export attribute "ObjectId"
Which gets fixed by doing:
from bson.objectid import ObjectId
Does this make sense as a solution on my side? both seem to point to the same place
- Independently of that, doing a simple:
value = ObjectId(<anything>)
Yields the typing error:
Call to untyped function "ObjectId" in typed context
The issue seems to come from this line not being properly typed:
|
def __init__(self, oid=None): |
A possible fix:
def __init__(self, oid: Any = None) -> None:
Thanks a lot! Let me know if this makes sense, or if you need more details
Hi guys!
I'm using your library in my project. I have a very strict typing setup, with poetry and python 3.13, and mypy complains about certain things. Using the latest (5.10) version of
bson.Context
Issues
Yields the typing error:
Module "bson" does not explicitly export attribute "ObjectId"Which gets fixed by doing:
Does this make sense as a solution on my side? both seem to point to the same place
Yields the typing error:
Call to untyped function "ObjectId" in typed contextThe issue seems to come from this line not being properly typed:
bson/bson/objectid.py
Line 85 in 5a85a1c
A possible fix:
Thanks a lot! Let me know if this makes sense, or if you need more details