help works fine:
uv run test-pydantic.py -h
pydantic_settings.VERSION='2.13.1'
usage: test-pydantic.py [-h] [--config CONFIG] [--db_url HttpUrl] [--api_key str] [--port int] [--env {dev,stg,prod}] [--created_at AwareDatetime] [--debug bool] [--log_dir Path]
options:
-h, --help show this help message and exit
--config CONFIG
--db_url HttpUrl The database connection string (required)
--api_key str API key for external services (default: default_key)
--port int (default: 8000)
--env {dev,stg,prod} (default: dev)
--created_at AwareDatetime
(default: 2026-04-16 20:00:00.909125+02:00)
--debug bool (default: False)
--log_dir Path Directory for log files (default: logs)
config file also works fine
uv run test-pydantic.py --config test.toml
pydantic_settings.VERSION='2.13.1'
Verified Config: {'db_url': HttpUrl('http://localhost/'), 'api_key': 'default_key', 'port': 9999, 'env': <Environment.stg: 'staging'>, 'created_at': datetime.datetime(2026, 4, 16, 20, 30, 50, 348786, tzinfo=datetime.timezone(datetime.timedelta(seconds=7200), 'CEST')), 'debug': True, 'log_dir': PosixPath('logs')}
db_url=HttpUrl('http://localhost/') api_key='default_key' port=9999 env=<Environment.stg: 'staging'> created_at=datetime.datetime(2026, 4, 16, 20, 30, 50, 348786, tzinfo=datetime.timezone(datetime.timedelta(seconds=7200), 'CEST')) debug=True log_dir=PosixPath('logs')
{
"$defs": {
"Environment": {
"enum": [
"development",
"staging",
"production"
],
"title": "Environment",
"type": "string"
}
},
"properties": {
"db_url": {
"description": "The database connection string",
"format": "uri",
"maxLength": 2083,
"minLength": 1,
"title": "Db Url",
"type": "string"
},
"api_key": {
"default": "default_key",
"description": "API key for external services",
"title": "Api Key",
"type": "string"
},
"port": {
"default": 8000,
"examples": [
8080
],
"maximum": 65535,
"minimum": 1,
"title": "Port",
"type": "integer"
},
"env": {
"$ref": "#/$defs/Environment",
"default": "development"
},
"created_at": {
"default": "2026-04-16T20:30:50.348786+02:00",
"format": "date-time",
"title": "Created At",
"type": "string"
},
"debug": {
"default": false,
"title": "Debug",
"type": "boolean"
},
"log_dir": {
"default": "logs",
"description": "Directory for log files",
"format": "path",
"title": "Log Dir",
"type": "string"
}
},
"required": [
"db_url"
],
"title": "SettingModel",
"type": "object"
}
#:schema ./test.schema
db_url = "http://localhost/"
api_key = "default_key"
port = 9999
env = "staging"
created_at = "2026-04-16T20:30:50.348786+02:00"
debug = true
log_dir = "logs"
#:schema ./test.schema
db_url = "http://localhost/"
api_key = "default_key"
port = 9999
env = "staging"
created_at = "2026-04-16T20:30:50.348786+02:00"
debug = true
log_dir = "logs"
test = 2
{
"$schema": "./test.schema",
"db_url": "http://localhost/",
"api_key": "default_key",
"port": 9999,
"env": "staging",
"created_at": "2026-04-16T20:30:50.348786+02:00",
"debug": true,
"log_dir": "logs"
}