Skip to content

🏷️ types: move to ty#75

Merged
SigureMo merged 5 commits intomainfrom
copilot/move-to-ty
Apr 25, 2026
Merged

🏷️ types: move to ty#75
SigureMo merged 5 commits intomainfrom
copilot/move-to-ty

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 25, 2026

Summary

  • replace pyright with ty in the dev dependency set, lockfile, and lint command
  • remove the old Pyright config, remove the Pylance recommendation/workspace settings, and recommend the ty VS Code extension
  • fix the small typing issues that ty --error-on-warning surfaced so local lint, tests, and build stay green

Validation

  • uv run ruff format --check .
  • npx --yes prettier --check '**/*.md'
  • uv run ty check --error-on-warning src/watchfs tests
  • uv run ruff check .
  • uv run pytest --reruns 3 --reruns-delay 1
  • uv build

Agent-Logs-Url: https://github.com/ShigureLab/watchfs/sessions/58f1d339-3811-4f7b-93e3-e13db85f0dce

Co-authored-by: SigureMo <38436475+SigureMo@users.noreply.github.com>
Comment thread .vscode/extensions.json Outdated
@@ -2,6 +2,7 @@
"recommendations": [
"ms-python.python",
"ms-python.vscode-pylance",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot pylance 肯定得删掉啊!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已删掉 Pylance 推荐,并顺手去掉了对应的 workspace python.analysis.* 设置,避免配置不一致。commit: 92b2d10

Comment thread src/watchfs/exceptions.py Outdated
Comment on lines +36 to +49
type ExceptionHook = Callable[[type[BaseException], BaseException, TracebackType | None], object]

oldHook: ExceptionHook = sys.excepthook


def handle_uncaught_exception(
exctype: type[BaseException], exception: BaseException, trace: TracebackType | None
) -> None:
oldHook(exctype, exception, trace)
if isinstance(exception, WatchFsBaseException):
sys.exit(exception.code.value)
raise SystemExit(exception.code.value)


sys.excepthook, oldHook = handleUncaughtException, sys.excepthook
sys.excepthook = handle_uncaught_exception
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot yutto 那边也没这么写啊,为啥这个要改成这样?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里已经改回更接近原来那版的写法了:保留 handleUncaughtException / oldHook 这套结构,只补了让 ty 通过所需的参数类型和返回类型。commit: 92b2d10

Copilot AI and others added 2 commits April 25, 2026 19:03
Agent-Logs-Url: https://github.com/ShigureLab/watchfs/sessions/d42dbe9d-7495-4032-976f-a69bc166bf33

Co-authored-by: SigureMo <38436475+SigureMo@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ShigureLab/watchfs/sessions/d42dbe9d-7495-4032-976f-a69bc166bf33

Co-authored-by: SigureMo <38436475+SigureMo@users.noreply.github.com>
Copilot AI requested a review from SigureMo April 25, 2026 19:05
Comment thread src/watchfs/exceptions.py Outdated


def handleUncaughtException(exctype: type[Exception], exception: Exception, trace: TracebackType):
def handleUncaughtException(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def handleUncaughtException(
def handle_uncaught_exception(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已按建议改成 snake_case。commit: 4efc436

Comment thread src/watchfs/exceptions.py Outdated
def handleUncaughtException(
exctype: type[BaseException], exception: BaseException, trace: TracebackType | None
) -> None:
oldHook(exctype, exception, trace)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
oldHook(exctype, exception, trace)
old_hook(exctype, exception, trace)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已改成 old_hook。commit: 4efc436

Comment thread src/watchfs/exceptions.py Outdated
Comment on lines +43 to +44
oldHook = sys.excepthook
sys.excepthook = handleUncaughtException
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot 写回一行

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经写回一行了。commit: 4efc436

Agent-Logs-Url: https://github.com/ShigureLab/watchfs/sessions/370ffd1c-7142-4d31-81e8-075ab705e7a2

Co-authored-by: SigureMo <38436475+SigureMo@users.noreply.github.com>
@SigureMo SigureMo marked this pull request as ready for review April 25, 2026 19:16
Copilot AI review requested due to automatic review settings April 25, 2026 19:16
Agent-Logs-Url: https://github.com/ShigureLab/watchfs/sessions/370ffd1c-7142-4d31-81e8-075ab705e7a2

Co-authored-by: SigureMo <38436475+SigureMo@users.noreply.github.com>
@SigureMo SigureMo merged commit a10feef into main Apr 25, 2026
4 checks passed
Copilot AI requested a review from SigureMo April 25, 2026 19:17
@SigureMo SigureMo deleted the copilot/move-to-ty branch April 25, 2026 19:19
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the repo’s type-checking workflow from Pyright to ty, updates the dev toolchain configuration accordingly, and includes a few small code tweaks to satisfy stricter typing checks.

Changes:

  • Replace pyright with ty across dev dependencies, lockfile, and just lint command.
  • Remove Pyright-specific configuration and adjust VS Code recommendations/settings.
  • Minor typing-driven refactors (sync wrapper for subprocess.run, explicit “unreachable” marker, exception hook typing cleanup, remove a type: ignore import).

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
uv.lock Drops pyright/nodeenv, adds ty to the locked dev dependency set.
pyproject.toml Replaces pyright with ty in dev deps; removes [tool.pyright]; adjusts Ruff ignores.
justfile Updates lint command to ty check --error-on-warning.
.vscode/settings.json Removes Pylance type-checking/inlay-hints settings.
.vscode/extensions.json Recommends astral-sh.ty and drops ms-python.vscode-pylance.
src/watchfs/targets.py Introduces _run_command_sync wrapper and uses capture_output for typing clarity.
src/watchfs/mappings.py Adds an explicit unreachable marker after structural pattern matching.
src/watchfs/exceptions.py Renames/retokens excepthook handler, improves typing, uses SystemExit.
src/watchfs/main.py Removes # type: ignore on watchfiles import.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .vscode/extensions.json
Comment on lines 2 to 6
"recommendations": [
"ms-python.python",
"ms-python.vscode-pylance",
"astral-sh.ty",
"charliermarsh.ruff",
"esbenp.prettier-vscode",
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description says to keep Pylance for editor inlay hints, but this change removes the ms-python.vscode-pylance recommendation entirely. Either re-add the Pylance extension here, or update the PR description to match the intended editor setup (and ensure inlay hints are still enabled somewhere if that’s desired).

Copilot uses AI. Check for mistakes.
Comment thread .vscode/settings.json
Comment on lines 1 to 5
{
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
"python.analysis.typeCheckingMode": "strict",
"python.analysis.inlayHints.functionReturnTypes": true,
"python.analysis.inlayHints.variableTypes": true,
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff"
}
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description mentions keeping Pylance for inlay hints, but these settings removed the explicit inlay-hint options (and strict typeCheckingMode). If inlay hints are still intended as part of the recommended setup, consider keeping the inlay-hint settings (or documenting the new defaults) so contributors get consistent editor behavior.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants