Hey everyone! 👋 I'm facing a bit of a challenge at work due to company restrictions. I can't install Pyright for type checking, but I can use Ty from Astral. I really like running it in the terminal with the watch option, but I prefer having strict type checking. Can anyone share their configuration tips to help me get Ty to provide error messages similar to Pyright in strict mode? Thanks a lot for any assistance! 🙏
5 Answers
I wish I had a solution for you, but it's true that Ty isn't quite there yet. However, you can try using Ruff with all rules enabled along with Ty; that should provide a lot of coverage.
I’m not sure if this will help, but Pydantic has a [validate_call decorator](https://docs.pydantic.dev/latest/concepts/validation_decorator/) that might be useful.
Unfortunately, Ty doesn’t have a strict mode yet. I found this link that might help: https://docs.astral.sh/ty/reference/typing-faq/#does-ty-have-a-strict-mode.
That's an odd restriction! Doesn't your company allow Python development in VSCode?
I don't know of a specific list for this, but you could run checks in the terminal to pinpoint where Ty might be lacking in strictness. Then you can add those as errors in the rules section of your ty.toml or `[tools.ty.rules]` in your pyproject.toml. I feel like Ty is stricter than both mypy and Pyright based on my experience, especially since my code passed those before I started using Ty. It’s got some gaps that are being addressed during this beta phase, so it's worth using if it fits your situation.

Good point! I think implementing the flake8-annotations ruleset (ANN) together with Ty might cover most of what you need. Just add this to your pyproject.toml:
```
# pyproject.toml
…
[tool.ruff.lint]
select = ["ANN", …]
```
Astral actually recommends doing this!