{"record":{"id":"30d05893931cc7de","repo":"Textualize/textual","slug":"expected-dimensions-found-str-self-r","errorCode":null,"errorMessage":"expected dimensions; found {str(self)!r}","messagePattern":"expected dimensions; found (.+?)","errorType":"validation","errorClass":"ScalarResolveError","httpStatus":null,"severity":"error","filePath":"src/textual/css/scalar.py","lineNumber":291,"sourceCode":"            size: Size of the container.\n            viewport: Size of the viewport (typically terminal size)\n\n        Raises:\n            ScalarResolveError: If the unit is unknown.\n\n        Returns:\n            A size (in cells)\n        \"\"\"\n        value, unit, percent_unit = self\n\n        if unit == Unit.PERCENT:\n            unit = percent_unit\n        try:\n            dimension = RESOLVE_MAP[unit](\n                value, size, viewport, fraction_unit or _FRACTION_ONE\n            )\n        except KeyError:\n            raise ScalarResolveError(f\"expected dimensions; found {str(self)!r}\")\n        return dimension\n\n    def copy_with(\n        self,\n        value: float | None = None,\n        unit: Unit | None = None,\n        percent_unit: Unit | None = None,\n    ) -> Scalar:\n        \"\"\"Get a copy of this Scalar, with values optionally modified\n\n        Args:\n            value: The new value, or None to keep the same value\n            unit: The new unit, or None to keep the same unit\n            percent_unit: The new percent_unit, or None to keep the same percent_unit\n        \"\"\"\n        return Scalar(\n            value if value is not None else self.value,\n            unit if unit is not None else self.unit,","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/Textualize/textual/blob/06dbeef4bb70fb718236aa418ed658ef4667a126/src/textual/css/scalar.py#L273-L309","documentation":"Raised by Scalar.resolve when the scalar's unit has no entry in RESOLVE_MAP, i.e. the unit cannot be resolved to a dimension in the current context (typically a percent/relative unit resolved without a reference size).","triggerScenarios":"Calling scalar.resolve(size, viewport, fraction_unit) where scalar has a unit (e.g. Unit.PERCENT as percent_unit) but the corresponding resolver is missing from RESOLVE_MAP — commonly resolving a scalar that was constructed with mismatched units, or resolving CELLS/percent units without proper dimension context.","commonSituations":"Manually constructing Scalar objects with inconsistent unit/percent_unit arguments; resolving a scalar captured from a different layout context; version changes that add new units not present in RESOLVE_MAP.","solutions":["Construct scalars via Scalar.parse or Scalar.from_number instead of manual unit combos","Ensure you pass a concrete size when resolving percent-based scalars","Check that unit and percent_unit arguments are compatible (both dimensionful or both fractional)"],"exampleFix":"// before\nscalar = Scalar(50.0, Unit.PERCENT, Unit.PERCENT)\nscalar.resolve(None, viewport)\n// after\nscalar = Scalar(50.0, Unit.PERCENT, Unit.CELLS)\nscalar.resolve(container_width, viewport)","handlingStrategy":"validation","validationCode":"from textual.css.scalar import Scalar\ndef resolvable(scalar: Scalar) -> bool:\n    from textual.css.scalar import RESOLVE_MAP\n    return scalar.unit in RESOLVE_MAP","typeGuard":null,"tryCatchPattern":"from textual.css.scalar import ScalarResolveError\ntry:\n    dim = scalar.resolve(size, viewport)\nexcept ScalarResolveError:\n    dim = scalar.resolve(size, viewport, percent_unit=Unit.CELLS)","preventionTips":["Always construct scalars with Scalar.parse or from_number","Pass a real reference size when resolving percent/fraction scalars","Keep unit and percent_unit compatible"],"tags":["textual","css","scalar","resolve","units"],"backgroundTag":"unit-resolution-failure","analyzedSha":"06dbeef4bb70fb718236aa418ed658ef4667a126","analyzedAt":"2026-08-27T02:36:57.214Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}