code-yeongyu / AiShell

AiShell: A Natural Language Shell like GitHub Copilot X, Powered by ChatGPT
MIT License
151 stars 14 forks source link

Replace `pyright` with `mypy` #7

Closed code-yeongyu closed 1 year ago

code-yeongyu commented 1 year ago

Context

Type Checker Philosophies

  1. No errors when type can be inferable
  2. If type cannot be inferable, type hints should be added
  3. Using of external modules that are not typed should be no error
  4. faster the better

mypy

mypy cannot satisfy philosophy 1

The following code cannot be passed by mypy while the return type can be inferable.

def greeting(name: str):
    print(f"hello {name}")

this can be ignored by setting no-untyped-def=false.

but that code violates 2.

def greeting(name):
    print(f"hello {name}")

and it's slow.

pyright

pyright satisfies the philosophy, with these options in this PR.

... and it's way faster than mypy and easy to integrate with vscode's pylance.

Changes