Uploaded image for project: 'Motor'
  1. Motor
  2. MOTOR-1173

CodecOptions type not parsed correctly

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      When trying to use the @overload pattern for type stubs, it seems that the type system is resolving CodecOptions[_CodecDocumentType] as Any in the second signature, which supersedes Optional[CodecOptions[_CodecDocumentType]] :

      motor/core.pyi:264: error: Overloaded function signature 3 will never be matched: signature 2's parameter type(s) are the same or broader [misc] async def command(

      The full signatures:

      @overload
      async def command(
          self,
          conn: Connection,
          command: Union[str, MutableMapping[str, Any]],
          value: int = 1,
          check: bool = True,
          allowable_errors: Optional[Sequence[Union[str, int]]] = None,
          read_preference: Optional[_ServerMode] = ReadPreference.PRIMARY,
          codec_options: CodecOptions[Dict[str, Any]] = DEFAULT_CODEC_OPTIONS,
          write_concern: Optional[WriteConcern] = None,
          parse_write_concern_error: bool = False,
          session: Optional[AgnosticClientSession] = None,
          **kwargs: Any,
      ) -> Dict[str, Any]:
          ...
      
      @overload
      async def command(
          self,
          conn: Connection,
          command: Union[str, MutableMapping[str, Any]],
          value: int = 1,
          check: bool = True,
          allowable_errors: Optional[Sequence[Union[str, int]]] = None,
          read_preference: Optional[_ServerMode] = ReadPreference.PRIMARY,
          codec_options: CodecOptions[_CodecDocumentType] = ...,
          write_concern: Optional[WriteConcern] = None,
          parse_write_concern_error: bool = False,
          session: Optional[AgnosticClientSession] = None,
          **kwargs: Any,
      ) -> _CodecDocumentType:
          ...
      
      @overload
      async def command(
          self,
          conn: Connection,
          command: Union[str, MutableMapping[str, Any]],
          value: int = 1,
          check: bool = True,
          allowable_errors: Optional[Sequence[Union[str, int]]] = None,
          read_preference: Optional[_ServerMode] = ReadPreference.PRIMARY,
          codec_options: Union[
              CodecOptions[Dict[str, Any]], CodecOptions[_CodecDocumentType]
          ] = DEFAULT_CODEC_OPTIONS,
          write_concern: Optional[WriteConcern] = None,
          parse_write_concern_error: bool = False,
          session: Optional[AgnosticClientSession] = None,
          **kwargs: Any,
      ) -> Union[Dict[str, Any], _CodecDocumentType]: ...
       

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            noah.stapp@mongodb.com Noah Stapp
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: