Skip to content

Settings inheritance with ENV prefix does not work #1091

@perminovs

Description

@perminovs

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug V1Bug related to Pydantic V1.X

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions