Checks
Question
Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":
pydantic version: 1.7.2
pydantic compiled: True
install path: /Users/michaeloliver/echo/app/.venv/lib/python3.9/site-packages/pydantic
python version: 3.9.0 (default, Oct 27 2020, 14:15:17) [Clang 12.0.0 (clang-1200.0.32.21)]
platform: macOS-10.16-x86_64-i386-64bit
optional deps. installed: ['typing-extensions']
I would like to use DirectoryPath with a default value if no environment override exists (using BaseSettings)
from pathlib import Path
from pydantic import BaseSettings, DirectoryPath
BASE_DIR = Path(__file__).parent
class Config(BaseSettings):
CONTENT_DIR: DirectoryPath = BASE_DIR / "content"
mypy complains:
src/hublib/config.py:8: error: Incompatible types in assignment (expression has type "Path", variable has type "DirectoryPath")
What would be the best approach ?
Checks
Question
Output of
python -c "import pydantic.utils; print(pydantic.utils.version_info())":I would like to use
DirectoryPathwith a default value if no environment override exists (usingBaseSettings)mypycomplains:What would be the best approach ?