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

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

advance_purchase instance-attribute

advance_purchase: int

booking_class instance-attribute

booking_class: str

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_unrestricted

allow_unrestricted(v)

Allow restrictions to be None or missing.

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