Move mypy config into pyproject.toml. Ignore 2 remaining mypy issues

This commit is contained in:
Debanjum Singh Solanky 2023-02-16 03:33:08 -06:00
parent 7a9a811874
commit 8b293edd7c
4 changed files with 18 additions and 16 deletions

View file

@ -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/*
)

View file

@ -73,3 +73,18 @@ include = ["src/khoj"]
[tool.hatch.build.targets.wheel] [tool.hatch.build.targets.wheel]
packages = ["src/khoj"] 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",
]

View file

@ -216,7 +216,7 @@ def deduplicate_results(entries: List[Entry], hits: List[dict]) -> List[dict]:
with timer("Deduplication Time", logger, state.device): with timer("Deduplication Time", logger, state.device):
seen, original_hits_count = set(), len(hits) seen, original_hits_count = set(), len(hits)
hits = [hit for hit in 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) duplicate_hits = original_hits_count - len(hits)
logger.debug(f"Removed {duplicate_hits} duplicates") logger.debug(f"Removed {duplicate_hits} duplicates")

View file

@ -27,7 +27,7 @@ search_index_lock = threading.Lock()
if torch.cuda.is_available(): if torch.cuda.is_available():
# Use CUDA GPU # Use CUDA GPU
device = torch.device("cuda:0") 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 # Use Apple M1 Metal Acceleration
device = torch.device("mps") device = torch.device("mps")
else: else: