Type hints for "let" are missing generic param for Mapping

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: Typing
    • None
    • Python Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Our type hint for "let" is incorrect because they're missing generics:

      $ git grep '\[Mapping\]'
      pymongo/asynchronous/collection.py:707:        let: Optional[Mapping] = None,
      pymongo/asynchronous/collection.py:3205:        let: Optional[Mapping] = None,
      pymongo/asynchronous/mongo_client.py:2405:        let: Optional[Mapping] = None,
      pymongo/synchronous/collection.py:706:        let: Optional[Mapping] = None,
      pymongo/synchronous/collection.py:3198:        let: Optional[Mapping] = None,
      pymongo/synchronous/mongo_client.py:2393:        let: Optional[Mapping] = None,
      

      We should update them to something like: "let: Optional[Mapping[str, Any]] = None,"

      A user commented on how pyright raises errors on partially unknown types (for example Mapping and List instead of Mapping[str, Any] and List[int])

      It would be nice to eventually turn on the appropriate flags in mypy (disallow_any_generics) and pyright (reportMissingTypeArgument) that enforces typed containers.

      As of the creation of this ticket, turning on the flag in pyright seemed to produce ~250 errors (and i'd guess about half of these errors are duplicated sync errors)

            Assignee:
            Unassigned
            Reporter:
            Iris Ho
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: