Skip to content

Fares

Fare

Bases: BaseModel

Source code in passengersim/config/fares.py
class Fare(BaseModel, extra="forbid"):
    carrier: str
    orig: str
    dest: str
    booking_class: str
    price: float
    advance_purchase: int
    restrictions: list[str] = []
    category: str | None = None
    cabin: str | None = "Y"

    @field_validator("restrictions", mode="before")
    @classmethod
    def allow_unrestricted(cls, v):
        """Allow restrictions to be None or missing."""
        if v is None:
            v = []
        return v

    @field_validator("restrictions", mode="before")
    @classmethod
    def allow_pipe_sep(cls, v):
        """Allow restrictions to be a string of pipe or slash separated values."""
        if isinstance(v, str):
            v = list(filter(None, re.split(r"[|/]", v)))
        return v

advance_purchase instance-attribute

advance_purchase: int

booking_class instance-attribute

booking_class: str

cabin class-attribute instance-attribute

cabin: str | None = 'Y'

carrier instance-attribute

carrier: str

category class-attribute instance-attribute

category: str | None = None

dest instance-attribute

dest: str

orig instance-attribute

orig: str

price instance-attribute

price: float

restrictions class-attribute instance-attribute

restrictions: list[str] = []

allow_pipe_sep classmethod

allow_pipe_sep(v)

Allow restrictions to be a string of pipe or slash separated values.

Source code in passengersim/config/fares.py
@field_validator("restrictions", mode="before")
@classmethod
def allow_pipe_sep(cls, v):
    """Allow restrictions to be a string of pipe or slash separated values."""
    if isinstance(v, str):
        v = list(filter(None, re.split(r"[|/]", v)))
    return v

allow_unrestricted classmethod

allow_unrestricted(v)

Allow restrictions to be None or missing.

Source code in passengersim/config/fares.py
@field_validator("restrictions", mode="before")
@classmethod
def allow_unrestricted(cls, v):
    """Allow restrictions to be None or missing."""
    if v is None:
        v = []
    return v