Repository navigation
Conversation
…ment script Add [tool.ty] and [tool.pyrefly] sections without machine-specific paths. The new utils/typecheck_env.py creates a virtual environment whose .pth file points to the Python code of a GRASS build or installation, so that type checkers find the generated grass.lib package. Pyright is pointed to the same environment. The configuration and script were written with AI assistance.
…tual environment The grass launcher sets PYTHONPATH to the Python code of the build or installation, which ty, pyrefly, pyright, basedpyright and Zuban all use to find the generated grass.lib package. This removes the need for a helper script and for any machine-specific path in the configuration.
…ronment script for editors Describe two ways to let type checkers find the generated grass.lib package: running them in a GRASS session, and a virtual environment created by utils/typecheck_env.py for editors. The configuration and script were written with AI assistance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
[tool.ty]and[tool.pyrefly]sections topyproject.toml(plusvenvPathfor pyright) without machine-specific paths, a "Type checking" section indoc/development/testing.md, andutils/typecheck_env.py.The generated
grass.libpackage only exists in a build or install tree, so checkers must be pointed to one. Two approaches are documented:grass --tmp-project XY --exec ty check. The launcher setsPYTHONPATH; no setup needed.python utils/typecheck_env.pycreates.venvwith a.pthfile pointing to the build or install tree, which language servers pick up through the selected interpreter.Motivation and context
A single static config that works for Autotools, CMake and installed trees on any platform.
ty needs
root = ["."]: otherwise it findspython/grassfirst and does not look forgrass.libelsewhere.How has this been tested?
CMake build on Linux.
grass.libresolved with no import errors by ty, pyrefly, Zuban, pyright and basedpyright, in both approaches (the.venvroute was checked with ty only). Fullpython/run throughgrass --exec:Not tested: Autotools or installed trees, Windows, VS Code itself.
Known limitations: results are not clean (mostly the runtime
_gettext builtin and missing optional dependencies), so nothing is enforced. Thegrasspackage comes from the build copy, so source edits need a rebuild to show up in cross-module checks.Written with AI assistance (Claude); the script and config are small and every line was reviewed.
Types of changes
Checklist
pre-defined prefixes
of this project.
Generated by Claude Code