Skip to content
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 whn instantiating a settings object #164

Closed
vladdu opened this issue Sep 9, 2023 · 3 comments
Closed

mypy complains whn instantiating a settings object #164

vladdu opened this issue Sep 9, 2023 · 3 comments
Assignees

Comments

@vladdu
Copy link

vladdu commented Sep 9, 2023

Hi! I couldn't find any other mention of this, so probably I'm doing something wrong.

I have a settings class inheriting from BaseSettings, and when instantiating it with a no-parameter constructor, mypy complains that arguments are missing. Is this something that the pydantic.mypy plugin handles? Unfortunately, I can't use that, because for some reason it makes mypy crash. Is there another workaround than providing dummy default values for everything?

@hramezani
Copy link
Member

Hi @vladdu,

Thanks for reporting this issue 🙏

Yes, The only possible way to fix mypy error is using pydantic mypy plugin

@dmontagu
Copy link
Contributor

@vladdu if you can share some more details about your crash we can look into it and try to resolve it

@tshipenchko
Copy link

I confirm that using pydantic mypy plugin fixes the issue

$ mypy app/cli/__main__.py  # without plugin
app/cli/__main__.py:18: error: Missing named argument "bot_token" for "Config"  [call-arg]
Found 1 error in 1 file (checked 1 source file)
$ mypy app/cli/__main__.py  # with plugin
Success: no issues found in 1 source file

My pyproject.toml:

[tool.mypy]
plugins = ["pydantic.mypy"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants