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

Settings inheritance with ENV prefix does not work #1091

Closed
perminovs opened this issue Dec 9, 2019 · 5 comments · Fixed by #1093
Closed

Settings inheritance with ENV prefix does not work #1091

perminovs opened this issue Dec 9, 2019 · 5 comments · Fixed by #1093
Labels
bug V1 Bug related to Pydantic V1.X

Comments

@perminovs
Copy link

perminovs commented Dec 9, 2019

Bug

  • OS: ubuntu 18.04
  • Python version import sys; print(sys.version): 3.7.5 (default, Nov 7 2019, 10:50:52)
  • Pydantic version import pydantic; print(pydantic.VERSION): 1.0b1 or 1.2, but works fine with 0.32
import os
from pydantic import BaseSettings


class MyBaseSettings(BaseSettings):
    var: int = 10


class MySubSettings(MyBaseSettings):
    class Config:
        env_prefix = 'PREFIX_'


os.environ['PREFIX_VAR'] = '2'
k = MySubSettings()
print(k.var)  # 10, but should be 2

We expect that k.var will be equal to 2, but it has default value 10.
It's reproduced since 1.0b1.

@perminovs perminovs added the bug V1 Bug related to Pydantic V1.X label Dec 9, 2019
@samuelcolvin
Copy link
Member

I'm looking into this, but I'm afraid the solution isn't trivial.

Weird that this got 11 👍 and 2 👀 in 2 hours. Any idea why this happened?

@kataev
Copy link
Contributor

kataev commented Dec 9, 2019

Yep, we are team.

@perminovs
Copy link
Author

Thanks for quick support! Hope fix won't be difficult.

@livestreamx
Copy link

That's what exactly happens when you upgrade your project with Pydantic from 0.32 to 1.2 directly... Thank you for support, @samuelcolvin !

@samuelcolvin
Copy link
Member

samuelcolvin commented Dec 10, 2019

See #1093, should be fixed there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug V1 Bug related to Pydantic V1.X
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants