Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting in Python doesn't work despite running language servers #25419

Open
marinegor opened this issue Feb 23, 2025 · 1 comment
Open

Formatting in Python doesn't work despite running language servers #25419

marinegor opened this issue Feb 23, 2025 · 1 comment

Comments

@marinegor
Copy link

marinegor commented Feb 23, 2025

Summary

Formatting in Python doesn't work despite running language servers (ruff and pyright).

Steps to trigger the problem:

  1. Open a python file and format it incorrectly (in my case, 5 extra spaces around the = sign). For instance: a = 5
  2. Save, or press Cmd+I, or go to command palette and select "format"

Actual Behavior:
Nothing happens -- file doesn't get formatted

Expected Behavior:
File should be formatted without extra spaces around the =

I've also attached my settings file:

settings.json

Zed Version and System Specs

Zed: v0.174.6 (Zed)
OS: macOS 12.7.6
Memory: 16 GiB
Architecture: x86_64

@quinn-caverly
Copy link

I had this same problem yesterday. I am also using pyright and ruff. Try these things:

  • uninstall your pyright and ruff installations via the cli. Zed will install them automatically
  • add py-project.toml pointing to the source code:
[tool.pyright]
include = ["src"]
extraPaths = ["src"]
reportMissingImports = true
  • make sure you have pycache and other similar dirs gitignored so language server doesn't try to analyze them
__pycache__/
*.pyc
.pytest_cache/
  • have a pyrightconfig.json so pyright gets your virtual env:
{
  "venvPath": ".",
  "venv": "venv"
}

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

No branches or pull requests

2 participants