| 111 | |
| 112 | def redis_settings_validation(): |
| 113 | class Settings(BaseModel, arbitrary_types_allowed=True): |
| 114 | redis_settings: RedisSettings |
| 115 | |
| 116 | @field_validator('redis_settings', mode='before') |
| 117 | def parse_redis_settings(cls, v): |
| 118 | if isinstance(v, str): |
| 119 | return RedisSettings.from_dsn(v) |
| 120 | else: |
| 121 | return v |
| 122 | |
| 123 | s1 = Settings(redis_settings='redis://foobar:123/4') |
| 124 | assert s1.redis_settings.host == 'foobar' |
no outgoing calls
searching dependent graphs…