mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-11 03:13:51 +00:00
Enable ty's unresolved-import rule
Broken first-party imports previously went undetected, since the rule was globally disabled to accommodate optional extras and platform-specific modules. These are now handled narrowly: per-file overrides for the agno integration (optional extra, not installed in CI) and for the pywebview integration (several macOS-only imports), and an inline suppression for the single macOS-only import in the dashboard.
This commit is contained in:
1 parent
fee1aef934
commit
f38f12915b
2 files changed
+12
-5
No files matched your search
+11
-4
@@ -114,10 +114,8 @@ python-version = "3.11"
|
||||
python-platform = "all"
|
||||
|
||||
[tool.ty.rules]
|
||||
# Mirror mypy's ignore_missing_imports=true: optional extras (e.g. agno, google-genai) and
|
||||
# platform-specific modules (e.g. AppKit on macOS) are not installed in the default dev environment,
|
||||
# so we do not want unresolvable imports to fail the type check.
|
||||
unresolved-import = "ignore"
|
||||
# Unresolvable imports do fail the type check (catching broken first-party imports); the exceptions for
|
||||
# optional extras and platform-specific modules are handled per file/line below.
|
||||
possibly-missing-submodule = "ignore"
|
||||
|
||||
[tool.ty.src]
|
||||
@@ -127,6 +125,15 @@ possibly-missing-submodule = "ignore"
|
||||
# test/resources is instead excluded from the `ty check test` CLI task via its --exclude flag.
|
||||
exclude = ["build/", "docs/"]
|
||||
|
||||
[[tool.ty.overrides]]
|
||||
# Modules whose imports cannot be resolved in the default dev environment: the agno integration depends
|
||||
# on the optional extra `agno`, and the pywebview integration imports macOS-only modules (AppKit, PyObjCTools)
|
||||
# in several places. Elsewhere, individual platform-specific imports are suppressed inline.
|
||||
include = ["src/serena/agno.py", "src/serena/util/pywebview.py"]
|
||||
|
||||
[tool.ty.overrides.rules]
|
||||
unresolved-import = "ignore"
|
||||
|
||||
[[tool.ty.overrides]]
|
||||
# Test code is heavily dynamic (pytest fixtures, MagicMock, intentionally loose Optionals). ty models
|
||||
# pytest's fail/skip helpers and MagicMock far more strictly than mypy did (mypy inferred `Any` for
|
||||
|
||||
@@ -1190,7 +1190,7 @@ class SerenaDashboardTrayManager:
|
||||
# set up tray icon with a dynamic menu (callable returns items on each open)
|
||||
kwargs: dict[str, Any] = {}
|
||||
if sys.platform == "darwin":
|
||||
from AppKit import NSApplication, NSApplicationActivationPolicyAccessory
|
||||
from AppKit import NSApplication, NSApplicationActivationPolicyAccessory # ty: ignore[unresolved-import] (macOS only)
|
||||
|
||||
nsapp = NSApplication.sharedApplication()
|
||||
# run as an accessory app so that only the menu bar icon is shown (no Dock icon)
|
||||
|
||||
Reference in new issue
Block a user