Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-2426

Explicitly list all BSON types accepted by bson.encode (instead of Any)

    • Type: Icon: Task Task
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Methods that accept/return BSON documents are currently annotated with Mapping[str, Any]. Ideally we could list the acceptable BSON value types to improve type safety. For example we could define the BSON value types:

      BsonType = Union[str, int, ObjectId, datatime, Timestamp, Decimal128, etc..., Mapping[str, 'BsonType'], List['BsonType']]
      Mapping[str, BsonType]
      

      Even if we list the BSON types explicitly, we may still need to include "Any" so that we accept custom types handled by the TypeRegistry.

            Assignee:
            Unassigned Unassigned
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: