{"record":{"id":"a1f940fc852ddb3d","repo":"HKUDS/Vibe-Trading","slug":"model-eps-basis-must-be-one-of-eps-bases-got","errorCode":null,"errorMessage":"{model}: eps_basis must be one of {EPS_BASES}, got {eps_basis!r}","messagePattern":"(.+?): eps_basis must be one of (.+?), got (.+?)","errorType":"exception","errorClass":"ValuationError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/valuation/comps.py","lineNumber":596,"sourceCode":"        cash_and_equivalents=float(cash_and_equivalents),\n        minority_interest=minority_interest,\n        preferred_stock=preferred_stock,\n        investments_in_associates=investments_in_associates,\n        omitted_components=omitted,\n    )\n\n\ndef _require_name(name: str, model: str) -> str:\n    \"\"\"Reject a blank company name -- every report keys off it.\"\"\"\n    if not isinstance(name, str) or not name.strip():\n        raise ValuationError(f\"{model}: name is required and cannot be blank, got {name!r}\")\n    return name\n\n\ndef _require_eps_basis(eps_basis: str, model: str) -> str:\n    \"\"\"Reject an EPS basis that is not one of the two this module recognises.\"\"\"\n    if eps_basis not in EPS_BASES:\n        raise ValuationError(\n            f\"{model}: eps_basis must be one of {EPS_BASES}, got {eps_basis!r}\"\n        )\n    return eps_basis\n\n\n@dataclass(frozen=True)\nclass PeerCompany:\n    \"\"\"One comparable company's raw inputs for the EV bridge and multiple matrix.\n\n    Attributes:\n        name: Identifier (ticker or short name), used in every report and\n            exclusion message for this peer.\n        market_cap: Equity market value.\n        total_debt: Interest-bearing debt.\n        cash_and_equivalents: Cash and short-term investments.\n        ebitda: Fiscal-period figures for EBITDA.\n        ebit: Fiscal-period figures for EBIT.\n        revenue: Fiscal-period figures for revenue/sales.","sourceCodeStart":578,"sourceCodeEnd":614,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/valuation/comps.py#L578-L614","documentation":"EPS basis must be one of the two recognised values in EPS_BASES (basic or diluted); _require_eps_basis runs at dataclass construction so a typo'd or foreign value fails immediately rather than silently skewing the P/E distribution.","triggerScenarios":"Constructing a peer/target with eps_basis='Diluted' (wrong case), 'adj', 'gaap', or any string not exactly in EPS_BASES.","commonSituations":"Case mismatches from user config or CSV headers; new basis vocabulary added by a data vendor; hand-written literals drifting from the enum.","solutions":["Import EPS_BASES from the module and select from it instead of hardcoding strings.","Normalize incoming basis strings (strip/lower) and map to the canonical values.","Add a startup assertion listing valid choices for configuration-driven basis values."],"exampleFix":"# before\npeer = CompPeer(name='ACME', eps_basis='Diluted', ...)\n\n# after\nfrom quantlib.valuation.comps import EPS_BASES\nassert eps_basis in EPS_BASES, f'{eps_basis=} not in {EPS_BASES}'\npeer = CompPeer(name='ACME', eps_basis=eps_basis, ...)","handlingStrategy":"type-guard","validationCode":"from quantlib.valuation.comps import EPS_BASES\nif eps_basis not in EPS_BASES:\n    raise ValueError(f'eps_basis must be one of {EPS_BASES}')","typeGuard":"def valid_eps_basis(b):\n    from quantlib.valuation.comps import EPS_BASES\n    return b in EPS_BASES","tryCatchPattern":"except ValuationError as e:\n    if 'eps_basis' in str(e):\n        eps_basis = 'diluted'  # documented default choice","preventionTips":["Select basis values from EPS_BASES, never literals","Normalize case of incoming basis strings"],"tags":["valuation","eps-basis","enum","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}