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

.env file not work with poetry #187

Closed
1 task done
JuanOrtizOvied opened this issue Nov 7, 2023 · 0 comments
Closed
1 task done

.env file not work with poetry #187

JuanOrtizOvied opened this issue Nov 7, 2023 · 0 comments
Assignees

Comments

@JuanOrtizOvied
Copy link

Initial Checks

  • I confirm that I'm using Pydantic V2

Description

⚠️ M2 apple chip

I have a poetry project, i call config file from main file and value vars are empty, values from .env file are not read

What's my mistake ?

pydantic-test
├── pydantic_test
│   └── config.py
│   └── main.py
│   └── .env
│   └── __init__.py
└── tests
│    └── __init__.py
└── pyproject.toml

Screenshot 2023-11-07 at 10 28 44 AM

Screenshot 2023-11-07 at 10 28 58 AM

Example Code

from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):
    DRIVER: str = 'postgresql'
    USERNAME: str = ''
    PASSWORD: str = ''
    HOST: str = ''
    PORT: int = 5432
    DATABASE: str = ''
    SQLALCHEMY_DATABASE_URL: str = f"{DRIVER}://{USERNAME}:{PASSWORD}@{HOST}:{PORT}/{DATABASE}"

    model_config = SettingsConfigDict(
        env_file='.env',
        env_file_encoding='utf-8',
        extra='ignore',
        case_sensitive=True,
    )


settings = Settings()

Python, Pydantic & OS Version

pydantic version: 2.4.2
        pydantic-core version: 2.10.1
          pydantic-core build: profile=release pgo=false
                 install path: /Users/juan/Library/Caches/pypoetry/virtualenvs/pydantic-test-K3b8D-bR-py3.10/lib/python3.10/site-packages/pydantic
               python version: 3.10.6 (v3.10.6:9c7b4bd164, Aug  1 2022, 17:13:48) [Clang 13.0.0 (clang-1300.0.29.30)]
                     platform: macOS-14.0-arm64-arm-64bit
             related packages: typing_extensions-4.8.0 pydantic-settings-2.0.3
@hramezani hramezani transferred this issue from pydantic/pydantic Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants