You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading from version 2.7.1 to 2.8.0, Pyright started reporting the following 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)
...
I believe this issue is caused by a commit that changed _cli_settings_source from CliSettingsSource[Any]|None to CliSettingsSource[object]|None.
I attempted to resolve the problem by defining T as a covariant type variable in sources.py. While this adjustment satisfied Pyright, it resulted in a mypy failure (#554):
Mypy.....................................................................Failed
- hook id: mypy
- exit code: 2
mypy pydantic_settings
pydantic_settings/sources.py:1632: error: Cannot use a covariant type variable as a parameter [misc]
Found 1 error in 1 file (checked 5 source files)
make: *** [mypy] Error 1
Steps to Reproduce:
Run pyright test.py with the following content:
#!/usr/bin/env python
from pydantic_settings import BaseSettings, EnvSettingsSource, CliSettingsSource
class OptionsBase:
pass
class MyOptions(OptionsBase):
pass
cli_source: CliSettingsSource[object] = CliSettingsSource[MyOptions](BaseSettings)
Please let me know if further information is needed.
The text was updated successfully, but these errors were encountered:
After upgrading from version 2.7.1 to 2.8.0, Pyright started reporting the following error :
I attempted to resolve the problem by defining T as a covariant type variable in sources.py. While this adjustment satisfied Pyright, it resulted in a mypy failure (#554):
Steps to Reproduce:
Run
pyright test.py
with the following content:Please let me know if further information is needed.
The text was updated successfully, but these errors were encountered: