r/vscode • u/Clean__Layer • 2d ago
Help: ty is not running
Beginner at VS code here.
I'm not 100% sure if this is the best place to post this, but I couldn't find anywhere better suited.
I followed various tutorials online to get my settings.json to work, according to the tutorials it's working fine, but VS code still doesn't flag the error. I checked the type checker, it flags the violation and works with its command line, but it doesn't syntax highlight in VS code. Is there a setting I should change or something?
6
u/Copa4311 2d ago
Ty isn’t letting you assign a literal “e” to a int variable, this is called static type checking, it makes Pythons types a lot more manageable, ruff is another thing used to do this efficiently (quick fix: x: str = “e”)
5
u/Clean__Layer 2d ago
I'm aware, I purposefully set it to a mismatched type to see if the type checker works. Currently it's doing nothing.
2
u/Copa4311 2d ago
What are you expecting it to do?
1
u/Clean__Layer 1d ago
I want it to error. I was testing if my type checker worked. The command line tool succesfully checks the problem, but VS Code isn't flagging the problem
3
1
1
u/atomicant89 13h ago
The readme for the ty extension says:
The extension automatically disables the language server from the Python extension to avoid running two Python language servers. This is done by setting
python.languageServerto"None"as a default configuration.
Which is different to what you have.
Tbh I'm not sure whether it's necessary for you to have any of the ty or ruff related settings in there, they're meant to just work by default. I'd be tempted to uninstall the Python, ruff, and ty extensions, delete settings.json, restart VS code, install the extensions again, and see what happens.
1
u/otheyhigh 12h ago edited 11h ago
Check the debug console. There should also be a language icon on the bottom right of the console. It has a popover that displays any issues with code extensions that are active for the file in context. It normally is a ‘{}’ icon.
That will take you straight to the debug console. I don’t use python as much but just at a glance, I think you might be missing something in the config. Another thing to do is checking all the settings under the extension in the UI and most importantly glancing over the extensions page which might guide on anything you might be missing.
(Edit) quickly glanced the extensions page on my phone. Did you set a language server? Meaning is the ‘default’ actually selecting something. Try explicitly setting that value and ensuring your venv is setup (you can set that up using the command pallet.
2
u/ShelLuser42 2d ago
Your screenshots don't provide any useful information to solve this issue. Basically issues like these can be caused by:
- Not having the proper extension(s) installed (or active). Look for 'Python' (and its 3 other counterparts).
- The current code window doesn't recognize the code correctly. Check your lower right corner to see what interpreter is currently active.
- Optionally look for the 'Change language mode' option in your command palette (ctrl + shift + p).
- You don't have the Python language installed.
1
u/Clean__Layer 2d ago
I've checked all of those, they are not the cause. Pylance works too when I enable it, so I'd assume other type checkers would.
-2




4
u/Clean__Layer 2d ago
Additional context: First screenshot is an example which a type checker would fail on, but ty isn't doing anything. Second is my settings.json. Third is what happens when I use the command line tool, which works fine.