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

Stub library for motor.

    • Type: Icon: New Feature New Feature
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.3
    • Affects Version/s: None
    • Component/s: None
    • None

      Hey, all. I was baffled this https://jira.mongodb.org/browse/MOTOR-331 ticket didnt got that much attention, and it got thrown to the backlog. So I am trying to create my own stubs.

       

      https://github.com/DAMACANER/motor/tree/stubs-branch

       

      And before I proceed any further, I came to request help.

       

      Currently, in my stub .pyi files, I am declaring every function as not `AsyncRead()`, but with the signature itself. https://github.com/DAMACANER/motor/blob/stubs-branch/motor/core.pyi#L238

       

      As you already know, 

      ```py

      something: AsyncRead

      ```

      gives `AsyncRead` is not Callable error. So I am writing every function call as just, functions. Leading to something like this:

      ```py   

      async def find_one(
              self,
              filter: Optional[Any] = None,
              projection: Optional[Any] = None,
              skip: int = 0,
              no_cursor_timeout: bool = False,
              cursor_type: int = CursorType.NON_TAILABLE,
              sort: Optional[Any] = None,
              allow_partial_results: bool = False,
              oplog_replay: bool = False,
              batch_size: int = 0,
              collation: Optional[Any] = None,
              hint: Optional[Any] = None,
              max_scan: Optional[int] = None,
              max_time_ms: Optional[int] = None,
              max: Optional[Any] = None,
              min: Optional[Any] = None,
              return_key: bool = False,
              show_record_id: bool = False,
              snapshot: bool = False,
              comment: Optional[str] = None,
              session: Optional[Any] = None,
              allow_disk_use: Optional[bool] = None,
          ) -> Mapping[str, Any]:
              f"""
              {find_one_doc} QWEQWEQWEQWE
              """ 

      ```

       

      There is one single problem. I dont know how I will add docstrings from the `motor.docstrings` to the docstrings of functions I created in stub files.

       

      I only thought and tried:

      ```py

      find_one._doc_ = find_one_doc

      ```

      but Pylance does not catch it in quick documentation.  Can you please help?

            Assignee:
            Unassigned Unassigned
            Reporter:
            canercetin853@gmail.com Can Çetin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: