-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
We should stop raising DeprecationWarning when no UuidRepresentation has been specified by the user.
Note that a similar warning will be added back to PyMongo 3.12 as part of PYTHON-2309 to aid users in transitioning from PyMongo 3.x to PyMongo 4.x.
Original Description
We should improve the uuidRepresentation deprecation warnings added in PYTHON-2152. For example, this should raise a warning but doesn’t:
>>> import bson >>> bson.encode({'u': uuid.uuid4()}) b'\x1d\x00\x00\x00\x05u\x00\x10\x00\x00\x00\x03W\xbd\xdchssDr\x86\x1e\x07i\xe1\xa2\xc4B\x00'
Same for bson.decode(), and json_util.loads/dumps when encoding/decoding UUIDs with the default options.
Another area to improve is that creating a MongoClient seems to cause a warning to be created but it’s attributed to codec_options.py. It’ll be hard for users to diagnose this warning:
>>> c = MongoClient() /Users/shane/git/mongo-python-driver/bson/codec_options.py:333: DeprecationWarning: Starting in PyMongo 4.0, the default uuidRepresentation will be changed to 'unspecified'. Applications will need to explicitly set 'uuidRepresentation=pythonLegacy' in the connection string to preserve current behavior. return CodecOptions(
Instead the DeprecationWarning should point to line where the MongoClient was created.
- is related to
-
PYTHON-2309 Migration guide for the change in the default UUID representation value
- Closed
- related to
-
PYTHON-2152 Support Handling of Native UUID Types Specification
- Closed
-
PYTHON-2252 Add examples and documentation for new UUID behavior
- Closed