Commit 8d73d42
committed
In sources.py, define T as a covariant type variable.
Previously, the type parameter was invariant, leading Pyright to report a type
incompatibility error:
```
$ pyright test
...
"CliSettingsSource[MyOptions]" is not assignable to "CliSettingsSource[object]"
Type parameter "T@CliSettingsSource" is invariant, but "MyOptions" is not
the same as "object" (reportAssignmentType)
...
```
Here's the content of `test.py`:
```
from pydantic_settings import BaseSettings, EnvSettingsSource, CliSettingsSource
class OptionsBase:
pass
class MyOptions(OptionsBase):
pass
cli_source: CliSettingsSource[object] = CliSettingsSource[MyOptions](BaseSettings)
```1 parent 1a4f3f4 commit 8d73d42
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
| 168 | + | |
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| |||
0 commit comments