# pyright.createtypestub

As mentioned earlier, this blog is as much a "note to self" as it is a blog..

Today, I needed typesubs for [smbclient](https://pypi.org/project/smbprotocol/) of package [smbprotocol](https://pypi.org/project/smbprotocol/).

```bash
:CocCommand pyright.createstypestub smbclient
```

This creates the necessary typestubs.

In my case I use nvim with [Conquer of Completion](https://github.com/neoclide/coc.nvim) and pyright. Yes, I know nvim now has built-in lsp support, but CoC works better for me.

For the stubs to work with pyright you need a *pyrightconfig.json* file.

It might look something like this

```json

    "include": [
      "src",
    ],

    "exclude": [
      "**/__pycache__"
    ],

    "ignore": [
    ],
    "typeshedPath": "/home/you/yoursource/typeshed",
    "stubPath": "/home/you/yoursource/stubs",
    "venvPath": ".",

    "reportMissingImports": true,
    "reportMissingTypeStubs": true,

    "pythonVersion": "3.11",
    "pythonPlatform": "Linux",

    "executionEnvironments": [
      {
        "root": "/",
        "venv": ".venv",
        "pythonVersion": "3.11",
        "pythonPlatform": "Linux",
        "extraPaths": [
          ""
        ]
      }
    ]
  }
```

and if */src* are your sources it should be present alongside your */src* directory.

This should solve missing type hints in smbclient. I did however encounter a different problem (this is not always the case).

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1675164975869/823660c8-7dd5-45b5-b945-28c677024178.png align="center")

To fix this, navigate to your `stubs folder /smbclient` and edit the *\_\_init\_\_.py* file in that directory.

In the *\_\_init\_\_.py* file add *\_\_all\_\_*

```python
""" 
This type stub file was generated by pyright. 
""" 
 
import logging 
import smbclient.path
from smbclient._io import SEEK_CUR, SEEK_END, SEEK_SET
from smbclient._os import (
    SMBDirEntry,
    .
    open_file, 
    readlink,
    remove, 
    .
    .
)

# add this after all the imports
__all__ = ["open_file", "readlink", "remove", ....]
```

and pyright will stop complaining.

There might be a better way of doing this. Please comment if you know of a better way!
