From 8b293edd7c11e9d97fc9e2e658bd4f1f7af4dab4 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Thu, 16 Feb 2023 03:33:08 -0600 Subject: [PATCH] Move mypy config into pyproject.toml. Ignore 2 remaining mypy issues --- .mypy.ini | 13 ------------- pyproject.toml | 17 ++++++++++++++++- src/khoj/search_type/text_search.py | 2 +- src/khoj/utils/state.py | 2 +- 4 files changed, 18 insertions(+), 16 deletions(-) delete mode 100644 .mypy.ini diff --git a/.mypy.ini b/.mypy.ini deleted file mode 100644 index fd43bd47..00000000 --- a/.mypy.ini +++ /dev/null @@ -1,13 +0,0 @@ -[mypy] -strict_optional = False -ignore_missing_imports = True -install_types = True -non_interactive = True -show_error_codes = True -exclude = (?x)( - src/khoj/interface/desktop/main_window.py - | src/khoj/interface/desktop/file_browser.py - | src/khoj/interface/desktop/system_tray.py - | build/* - | tests/* - ) diff --git a/pyproject.toml b/pyproject.toml index 328ef2bb..775b5b21 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,4 +72,19 @@ dev = ["khoj-assistant[test]"] include = ["src/khoj"] [tool.hatch.build.targets.wheel] -packages = ["src/khoj"] \ No newline at end of file +packages = ["src/khoj"] + +[tool.mypy] +files = "src/khoj" +pretty = true +strict_optional = false +ignore_missing_imports = true +install_types = true +non_interactive = true +show_error_codes = true +warn_unused_ignores = true +exclude = [ + "src/khoj/interface/desktop/main_window.py", + "src/khoj/interface/desktop/file_browser.py", + "src/khoj/interface/desktop/system_tray.py", +] diff --git a/src/khoj/search_type/text_search.py b/src/khoj/search_type/text_search.py index bd5715b6..59022e13 100644 --- a/src/khoj/search_type/text_search.py +++ b/src/khoj/search_type/text_search.py @@ -216,7 +216,7 @@ def deduplicate_results(entries: List[Entry], hits: List[dict]) -> List[dict]: with timer("Deduplication Time", logger, state.device): seen, original_hits_count = set(), len(hits) hits = [hit for hit in hits - if entries[hit['corpus_id']].raw not in seen and not seen.add(entries[hit['corpus_id']].raw)] + if entries[hit['corpus_id']].raw not in seen and not seen.add(entries[hit['corpus_id']].raw)] # type: ignore[func-returns-value] duplicate_hits = original_hits_count - len(hits) logger.debug(f"Removed {duplicate_hits} duplicates") diff --git a/src/khoj/utils/state.py b/src/khoj/utils/state.py index 7e6abc1e..7616cf11 100644 --- a/src/khoj/utils/state.py +++ b/src/khoj/utils/state.py @@ -27,7 +27,7 @@ search_index_lock = threading.Lock() if torch.cuda.is_available(): # Use CUDA GPU device = torch.device("cuda:0") -elif version.parse(torch.__version__) >= version.parse("1.13.0.dev") and torch.backends.mps.is_available(): +elif version.parse(torch.__version__) >= version.parse("1.13.0.dev") and torch.backends.mps.is_available(): # type: ignore[attr-defined] # Use Apple M1 Metal Acceleration device = torch.device("mps") else: