rye
rye copied to clipboard
Ability to easily chain built-in rye commands, e.g., `rye lint`
Currently interested in chaining or extending the rye lint command to also perform typechecking. For example:
[tool.rye.scripts]
typecheck = "mypy mymodule"
check = { chain = ["rye lint", "typecheck"] }
linter = "lint" # also fails
This seems to fail because rye is not available in the environment. I also could not find any documentation on if I could customize the lint command.
Suggestion
Make rye native commands accessible to scripts.
I would also find this helpful. An initial work around:
- Install ruff
rye add --dev ruff - Add to
pyproject.toml
[tool.rye.scripts]
check-lint = "ruff check"
Related https://github.com/astral-sh/rye/discussions/1142
Does chain do what you need? https://rye.astral.sh/guide/pyproject/#chain
# pyproject.toml
[tool.rye.scripts]
lint = { chain = ["lint:black", "lint:flake8"] }
"lint:black" = "black --check src"
"lint:flake8" = "flake8 src"
Then:
rye lint: runs Ruffrye run lint: runs the above scripts
@jamesbraza I want to keep the rye lint command that runs ruff, but also run mypy, and allow people to continue using rye lint in their workflows.
Are you suggesting a workaround where I redefine what rye lint does in a new command (e.g., lint:ruff) that can be chained? This is how I understood asmith26's suggestion.
Oh @linjer thanks for following up. Yeah your ideal was basically overriding rye lint such that rye lint runs Ruff, mypy, and possibly other tools. I like your request, it makes sense.
You're correct that my comment didn't resolve that directly, it instead adds an additional script called lint (invoked via rye run lint) that calls other tools