Support config inheritance (extends) so a generated pyrefly.toml can build on [tool.pyrefly]
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 516
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Bug
### Summary
Pyrefly reads a single config file and has no way for one config to inherit from another. When a directory has both a `pyrefly.toml` and a `pyproject.toml` with a `[tool.pyrefly]` section, `pyrefly.toml` is used
and `[tool.pyrefly]` is ignored, with no diagnostic. This makes it hard for a tool that generates a `pyrefly.toml` to coexist with a package's own settings.
### Reproduction (pyrefly 1.0.0)
`pyproject.toml`:
```toml
[tool.pyrefly]
preset = "strict"
```
`src/a.py`:
```python
def f(x):
return x
```
`pyrefly check` reports 1 error (`implicit-any-parameter`), because `preset = "strict"` applies.
Now add an empty `pyrefly.toml` next to it and run again: 0 errors. The `preset` from `[tool.pyrefly]` no longer applies, and nothing reports that it was dropped.
### Why this matters
A common pattern is a tool that generates a `pyrefly.toml` to point Pyrefly at an environment it computes (interpreter path, search paths, third-party package paths). Today, generating that file silently voids
the package's own `[tool.pyrefly]`. To preserve it, the tool must read `[tool.pyrefly]` itself and copy every key into the generated file, which means re-implementing config handling and tracking Pyrefly's schema
as it changes.
Pyright avoids this with its `extends` key: a generated `pyrightconfig.json` sets `extends = "pyproject.toml"` and adds only the keys it owns. Pyrefly has no equivalent.
### Proposed solution
Either of:
1. An `extends` field, so a config inherits from another file and overrides selected keys. This matches Pyright's `extends` and the same request for ty in astral-sh/ty#2137.
2. Merge `pyrefly.toml` with `pyproject.toml`'s `[tool.pyrefly]` when both exist, under a documented precedence, instead of ignoring one.
Option 1 is more general, since it composes across more than two files.
### Prior art
- Pyright's `extends` key.
- ruff's `extend`.
- astral-sh/ty#2137 (open) requests the same `extend` field for ty.
### Sandbox Link
_No response_
### (Only applicable for extension issues) IDE Information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.