How to add built-in function (gettext) to pyright?

135 Views Asked by At

I have a python project with gettext. And I use gettext.install for adding _ to built-ins, so it works correctly. But my pyright always shows error: _ is not defined. How can I let pyright know this function?

My pyrightconfig.json:

{
    "venvPath": ".",
    "venv": "env"
}
1

There are 1 best solutions below

0
jsuddsjr On

According to the pyright documentation, you can add custom built-in types by adding a __builtins__.pyi file to the root of your project.

# __builtins__.pyi
def _(str:str) -> str: ...

See Extending Builtins.