require-nodecode-for-splitting-settings-field
Warn when an unconditional raw-string splitter lacks a pydantic-settings decoding policy.
Why
pydantic-settings JSON-decodes complex environment fields before field validators run; a raw-string splitter without NoDecode can fail during process startup.
Fix
After confirming the intended environment format, annotate the field as Annotated[FieldType, NoDecode] or disable decoding for the settings class so the validator receives the raw string.
Examples
import osfrom pydantic import field_validatorfrom pydantic_settings import BaseSettings
class Settings(BaseSettings): emails: list[str]
@field_validator("emails", mode="before") @classmethod def split_emails(cls, value): return value.split(",")
os.environ["EMAILS"] = "one@example.com,two@example.com"Settings()import osfrom typing import Annotatedfrom pydantic import field_validatorfrom pydantic_settings import BaseSettings, NoDecode
class Settings(BaseSettings): emails: Annotated[list[str], NoDecode]
@field_validator("emails", mode="before") @classmethod def split_emails(cls, value): return value.split(",")
os.environ["EMAILS"] = "one@example.com,two@example.com"Settings()