-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mypy complains about settings object #103
Comments
Thanks @sr-verde for reporting this issue 🙏 You've imported I've tested your provided example by changing the import and it looks fine: from typing import Literal
from pydantic_settings import BaseSettings, SettingsConfigDict
class Config(BaseSettings):
log_level: Literal["NOTSET", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] = "WARNING"
model_config = SettingsConfigDict(env_file=".env") Could you please try it? |
Yes, that solves the issue. And I know how it happened. Seems to be a bug in bump-pydantic. I had this config in Pydantic v1: from typing import Literal
from pydantic import BaseSettings
class Config(BaseSettings):
log_level: Literal["NOTSET", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] = "WARNING"
class Config:
env_file = ".env" Then, I executed dump-pydantic and got the following config file: from typing import Literal
from pydantic import ConfigDict
from pydantic_settings import BaseSettings
class Config(BaseSettings):
log_level: Literal["NOTSET", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] = "WARNING"
model_config = ConfigDict(env_file=".env") As one can see bump-pydantic imported |
Thanks for the clarification. It would be great to open an issue in bump-pydantic |
Thanks for your help! |
Hey, sorry, need to reopen that issue again. Using strict mode in mypy this error still occurs:
|
Could you install I couldn't see the error by the mypy config you provided. |
Yes, seems to be fixed in main branch. So I’ll wait for the next release. Sorry to interrupt you again. |
No worries. new release will come probably today. |
Initial Checks
main
branch, or equivalentDescription
Mypy complains about my settings object.
This error only occurs in strict mode:
Example Code
Python, Pydantic & OS Version
The text was updated successfully, but these errors were encountered: