Last active
July 10, 2025 17:14
-
-
Save johacks/4ef917abf1b67066fc9890adab8f8801 to your computer and use it in GitHub Desktop.
Python ruff-uv setup in VS Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[project] | |
name = "project-name" | |
version = "0.1.0" | |
description = "Project description" | |
readme = "README.md" | |
requires-python = ">=3.9" | |
authors = [ | |
{ name = "<your-name>", email = "<your-email>" }, | |
] | |
dependencies = [ | |
"numpy==2.0.0", | |
# ... | |
] | |
classifiers = [ | |
"Development Status :: 4 - Beta", | |
"Intended Audience :: Developers", | |
"Intended Audience :: Science/Research", | |
"License :: OSI Approved :: MIT License", | |
"Programming Language :: Python :: 3", | |
"Programming Language :: Python :: 3.9", | |
"Programming Language :: Python :: 3.10", | |
] | |
license = { file = "LICENSE.md" } | |
keywords = ["AI", "bitcoin", "blockchain"] | |
[project.urls] | |
Homepage = "https://github.com/<username>/<repo>" | |
[project.scripts] | |
# Defines a runnable `my-script` | |
# Equivalent to `from my_module.my_submodule import my_function; my_function()` | |
my-script = "my_module.my_submodule:my_function" | |
[tool.ruff] | |
line-length = 88 | |
[tool.ruff.format] | |
docstring-code-format = true | |
[tool.ruff.lint] | |
# Adds isort and docstring linting | |
extend-select = ["I", "D"] | |
# Ignore bothersome warnings | |
extend-ignore = ["E402"] | |
# Don't autoremove unused imports, variable, etc. | |
unfixable = ["F401"] | |
# A file or directory to exclude from linting | |
exclude = ["scratchpad.py"] | |
[tool.ruff.lint.pydocstyle] | |
# Or "numpy" for example | |
convention = "google" | |
[build-system] | |
requires = ["hatchling"] | |
build-backend = "hatchling.build" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"[python]": { | |
"editor.codeActionsOnSave": { | |
"source.fixAll.ruff": "always", | |
"source.organizeImports.ruff": "always", | |
}, | |
"editor.defaultFormatter": "charliermarsh.ruff", | |
"editor.formatOnSave": true, | |
"editor.rulers": [ | |
88 | |
] | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This short Gist contains a recommended configuration for using uv and ruff in a python project. | |
The `.vscode/settings.json` configures editor to format on save on Python files and show a ruler for configured line-length. | |
For it to work, the ruff VS Code extension should be installed. | |
The `pyproject.toml` shows a template for a Python project publishable to PyPi. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment