Feature Request: Support `pandera` and `class Config` override pattern
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 516
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Feature Request
Pandera's `DataFrameModel` uses an inner `class Config` pattern for schema-wide
configuration. Subclasses redefine `class Config` to customize settings. This is
the standard, documented way to use `pandera`. Their [docs](https://pandera.readthedocs.io/en/latest/dataframe_models.html#config) explicitly say
"It is not required for the `Config` to subclass `BaseConfig`."
Pyrefly flags every such override as `bad-override` because the child `Config`
class is not a subtype of the parent's `Config` class. This same inner-class
override pattern is used by Django , and pydantic v1 (Config). Pyrefly already
has special handling for pydantic, pandera would benefit from similar treatment.
See [config ](https://pandera.readthedocs.io/en/latest/dataframe_models.html#config)for more information on how `class Config` in `pandera` works. There is a [feature request](https://github.com/unionai-oss/pandera/issues/2419) for the `pydantic` v2 style of `model_config` which may remove the need for this, but many will continue to use this `class Config` in the meanwhile.
---
Requires: `pip install pandera`
repro.py:
```
from pandera import DataFrameModel, Field
from pandera.typing import Series
class BaseSchema(DataFrameModel):
timestamp: Series[str] = Field()
class Config:
strict = True
unique = ["timestamp"]
class ChildSchema(BaseSchema):
mode: Series[str] = Field()
class Config:
strict = False
```
pyrefly.toml:
```
preset = "strict"
```
Output:
```
ERROR Class member `BaseSchema.Config` overrides parent class `DataFrameModel` in an inconsistent manner [bad-override]
`BaseSchema.Config` is a ClassVar, but `DataFrameModel.Config` is not
ERROR Class member `ChildSchema.Config` overrides parent class `BaseSchema` in an inconsistent manner [bad-override]
```
---
It's difficult to fix this with `pyrefly.toml` settings, since the second error is from first party code. All instances of the first error can be removed with `replace-imports-with-any`. Still, fixing this across my codebase would require many suppressions in first party code. `pyrefly` is correct that the override changes the type, but this is a widespread pattern that flagging it creates significant noise in codebases using `pandera` schemas. `pandera` seems like a large enough project that this is a worthwhile effort.
### Sandbox Link
No sandbox due to `pandera` requirement.
### (Only applicable for extension issues) IDE Information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.