[Typing] Add pyright config to suppress warnings

VSCode uses pylance/pyright, a performant type checker. So
setup the builtins used by Deluge and set missing imports to
informational due to OS-specific imports.

It might be possible using extraPaths with extra stubs or use
defineConstants to make pyright not check Windows or Macos conditional
paths but that would require changing all usage so leaving for another
time.

Refs: https://github.com/microsoft/pyright/blob/main/docs/configuration.md
Refs: https://github.com/microsoft/pyright/blob/main/docs/builtins.md
This commit is contained in:
Calum Lind 2024-09-08 14:33:07 +01:00
parent 90c5e75373
commit e7d08d7645
No known key found for this signature in database
GPG Key ID: 90597A687B836BA3
2 changed files with 10 additions and 0 deletions

6
__builtins__.pyi Normal file
View File

@ -0,0 +1,6 @@
from twisted.web.http import Request
__request__: Request
def _(string: str) -> str: ...
def _n(string: str) -> str: ...

View File

@ -58,3 +58,7 @@ extend-function-names = ["_n"]
"deluge/**/gtkui.py" = ["E402"]
"deluge/plugins/Stats/deluge_stats/graph.py" = ["E402"]
"deluge/ui/gtk3/*.py" = ["E402"]
[tool.pyright]
reportMissingImports = "information"
reportMissingModuleSource = "information"