Skip to content

Commit

Permalink
Update Python profile documentation and refine Ruff settings
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-ma committed Jan 7, 2025
1 parent 2934b8d commit e4a2278
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
26 changes: 10 additions & 16 deletions profiles/python/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,20 @@ A python profile with useful settings and a full theme already configured. The t

Ligatures are disabled by default. To enable them, search for "ligature" in the settings then change the `editor.fontLigatures` setting to `true`.

### Ruff / black settings

It is not recommended putting any settings for black and ruff (or any other formatter/linter/type checker) in a `settings.json` file, because it will always override settings that are put in a `pyproject.toml` file in the workspace (which is the recommended way to configure those tools for any project, even without vscode).

Instead, you should put the settings in a `pyproject.toml` file at the root of your project / workspace. Here is an example of a `pyproject.toml` template file:
### Ruff settings

Default settings (rules) are set in the `settings.json` file.
To override them, use a `pyproject.toml` file at the root of your project / workspace. This is the recommended way to configure those tools for any project, even without vscode. Here is an example of a `pyproject.toml` file for the Ruff linter:
<details>
<summary>pyproject.toml</summary>
<p>

```toml
[tool.black]
# should be same as ruff
line-length = 88

[tool.ruff]
# should be same as black
line-length = 88
fix=true

[tool.ruff.lint]
# https://beta.ruff.rs/docs/rules/
select = [
"E", # pycodestyle
Expand Down Expand Up @@ -87,10 +82,10 @@ exclude = [
"venv",
]

[tool.ruff.extend-per-file-ignores]
[tool.ruff.lint.extend-per-file-ignores]
"__init__.py" = ["F401"] # disable unused import rule in __init__.py files

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
# https://beta.ruff.rs/docs/settings/#pydocstyle-convention
convention = "google"

Expand All @@ -100,10 +95,10 @@ multiline-quotes = "double"
docstring-quotes = "double"


[tool.ruff.pylint]
[tool.ruff.lint.pylint]
max-args = 5

[tool.pyright]
[tool.lint.pyright]
# deactivate pyright features that are already covered by ruff
# actually only enables type checking
# https://microsoft.github.io/pyright/#/configuration?id=diagnostic-rule-defaults for more info
Expand All @@ -123,8 +118,7 @@ reportUnusedFunction = false
- `Python` - Python extension for Visual Studio Code.
- `Pylance` - Fast, feature-rich language support for Python, including the pyright static type checker.
- `Python environment manager` - Browse and manage all of your Python environments & packages from a single place.
- `Black formatter` - Support for the [Black](https://github.com/psf/black) formatter.
- `Ruff` - Support for the [Ruff](https://beta.ruff.rs/docs/) linter.
- `Ruff` - Support for the [Ruff](https://beta.ruff.rs/docs/) linter and code formatter.
- `Python indent` - Correct python indentation in VS Code.
- `autoDocstring` - Automatically generates docstrings.
- `Even Better TOML` - TOML file support, for project config setup files like `pyproject.toml`.
Expand Down
3 changes: 2 additions & 1 deletion scripts/build_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def dump_snippets(self) -> str | None:
not_dumped = {
"snippets": {
snippet.name: snippet.read_text(encoding="utf8") for snippet in snippets
}
},
}
return json.dumps(not_dumped)

Expand Down Expand Up @@ -180,5 +180,6 @@ def main():
path = DIRECTORY / name.lower().replace(" ", "_")
Profile(path).write_code_profile(name)


if __name__ == "__main__":
main()

0 comments on commit e4a2278

Please sign in to comment.