-
Hello, I have a somewhat specific use case and a question about it. Is it possible to configure both UV and Ruff to use the same pyproject.toml file without syncing all dependencies? What I want is a single pyproject.toml that defines:
For example: [project]
name = "random_name"
version = "0.1.0"
requires-python = "==3.12.*"
dependencies = [
"loguru==0.7.2",
...
]
[tool.ruff]
line-length = 120
lint.ignore = ["PLR0913", "RET504", "PLR0912"]
lint.select = ["E", "F", "UP", "I", "BLE", "T20", "RET", "SIM"]
exclude = ["*.yaml", "*.yml", "*.pyi"]
[tool.ruff.lint.per-file-ignores]
"Test/*" = ["PLR0911", "PLR0915"] When I use uv to create a virtual environment based on this file, it installs all dependencies. That’s fine for development. However, for testing and static analysis (e.g., ruff, mypy), I want to use uv to run these tools in isolation without installing the full dependency list. For example, using My question is: Thanks! EDIT: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Thanks for opening a discussion!
Is that expected? That seems surprising to me, and ruff seems to respect my pyproject.toml when I tried this locally.
import random
from tenacity import Retrying, retry_if_exception_type, stop_after_attempt
def try_lottery() -> float:
for attempt in Retrying(
retry=retry_if_exception_type(RuntimeError), stop=stop_after_attempt(3)
):
with attempt:
if random.random() < 0.001: # Some stochastic condition
return 1e6
raise RuntimeError("The lottery was not won.") it should trigger RET503, a non-default rule.
[project]
requires-python = ">=3.13"
[tool.ruff]
lint.select = ["RET"] uv command and output: > uv tool run ruff check --no-cache .
try.py:6:1: RET503 Missing explicit `return` at the end of function able to return non-`None` value
|
6 | / def try_lottery() -> float:
7 | | for attempt in Retrying(
8 | | retry=retry_if_exception_type(RuntimeError), stop=stop_after_attempt(3)
9 | | ):
10 | | with attempt:
11 | | if random.random() < 0.001: # Some stochastic condition
12 | | return 1e6
13 | | raise RuntimeError("The lottery was not won.")
| |__________________________________________________________^ RET503
|
= help: Add explicit `return` statement
Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option). |
Beta Was this translation helpful? Give feedback.
Thanks for opening a discussion!
Is that expected? That seems surprising to me, and ruff seems to respect my pyproject.toml when I tried this locally.
try.py
that I had laying around from another issue: