<@ULVA73B9P> whenever I run the prefect cli comman...
# ask-marvin
b
@Marvin whenever I run the prefect cli command or run any prefect flow or task from my computer, I get these annoying Pydantic warning messages. How can I fix my configuration so that these warning stop appearing?
Copy code
/Users/benjamingroves/playground/boxing-data/combat-data-pipelines/.venv/lib/python3.12/site-packages/pydantic_settings/main.py:425: UserWarning: Config key `pyproject_toml_table_header` is set in model_config but will be ignored because no PyprojectTomlConfigSettingsSource source is configured. To use this config key, add a PyprojectTomlConfigSettingsSource source to the settings sources via the settings_customise_sources hook.
  self._settings_warn_unused_config_keys(sources, self.model_config)
/Users/benjamingroves/playground/boxing-data/combat-data-pipelines/.venv/lib/python3.12/site-packages/pydantic_settings/main.py:425: UserWarning: Config key `toml_file` is set in model_config but will be ignored because no TomlConfigSettingsSource source is configured. To use this config key, add a TomlConfigSettingsSource source to the settings sources via the settings_customise_sources hook.
  self._settings_warn_unused_config_keys(sources, self.model_config)
I am using Macbook pro M1 Ventura, with Python 3 virtual env
Copy code
python --version
Python 3.12.8

pip --version
pip 24.3.1
m
thought for 147.5 seconds
Thanks for sharing the exact warning text — that helps. What you’re seeing is a known interaction between Prefect 3.x and pydantic-settings 2.11+, which started emitting new warnings when certain config keys (like
pyproject_toml_table_header
and
toml_file
) are present. It’s tracked here: PrefectHQ/prefect#19028. Functionality isn’t broken, but the warnings are noisy. Quickest fix (recommended) - Pin pydantic-settings to a version prior to 2.11 in your virtualenv:
Copy code
pip install "pydantic-settings<2.11"
- If you maintain a requirements.txt/pyproject, add the same constraint there so it stays pinned. You can confirm your version with:
Copy code
python -c "import pydantic_settings as ps; print(ps.__version__)"
Optional: try updating Prefect first - If you’re not on the latest Prefect 3.x, upgrade, then see if the warnings persist:
Copy code
pip install -U prefect
If you still see the warnings afterward, apply the pin above. If you need to temporarily silence the warnings (not ideal long-term) - For CLI sessions only:
Copy code
export PYTHONWARNINGS="ignore:Config key.*is set in model_config.*:UserWarning"
- Or in Python code (e.g., a bootstrap script):
Copy code
import warnings
warnings.filterwarnings(
    "ignore",
    category=UserWarning,
    message=r"Config key .* is set in model_config .*",
)
This suppresses more than just these two warnings, so prefer the dependency pin. If you can, share your
prefect version
output — it helps confirm your Prefect/Pydantic/pydantic-settings versions. The command is:
Copy code
prefect version
References - Issue with context and workaround: PrefectHQ/prefect#19028 - Prefect settings overview (for background): Settings and profiles