From e7d08d7645dfbd5bff2eed98298012037231c173 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sun, 8 Sep 2024 14:33:07 +0100 Subject: [PATCH] [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 --- __builtins__.pyi | 6 ++++++ pyproject.toml | 4 ++++ 2 files changed, 10 insertions(+) create mode 100644 __builtins__.pyi diff --git a/__builtins__.pyi b/__builtins__.pyi new file mode 100644 index 000000000..d03460554 --- /dev/null +++ b/__builtins__.pyi @@ -0,0 +1,6 @@ +from twisted.web.http import Request + +__request__: Request + +def _(string: str) -> str: ... +def _n(string: str) -> str: ... diff --git a/pyproject.toml b/pyproject.toml index beec7960a..8b65e52dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"