Repository: Textualize/textual
File: src/textual/widgets/_progress_bar.py (Python)

Code before:
        &> .bar--indeterminate {
            color: $error;
            background: $surface;
        }
        &> .bar--complete {
            color: $success;
            background: $surface;
        }
    }
    """

    percentage: reactive[float | None] = reactive[Optional[float]](None)
    """The percentage of progress that has been completed."""

    gradient: reactive[Gradient | None] = reactive(None)
    """An optional gradient."""

    def __init__(
        self,
        name: str | None = None,
        id: str | None = None,
        classes: str | None = None,
        disabled: bool = False,
        clock: Clock | None = None,
        gradient: Gradient | None = None,
        bar_renderable: BarRenderable = BarRenderable,
    ):
        """Create a bar for a [`ProgressBar`][textual.widgets.ProgressBar]."""
        self._clock = (clock or Clock()).clone()
        super().__init__(name=name, id=id, classes=classes, disabled=disabled)
        self.set_reactive(Bar.gradient, gradient)
        self.bar_renderable = bar_renderable

    def _validate_percentage(self, percentage: float | None) -> float | None:
        """Avoid updating the bar, if the percentage increase is too small to render."""
        width = self.size.width * 2
        return (
            None
            if percentage is None
            else (int(percentage * width) / width if width else percentage)
        )

    def watch_percentage(self, percentage: float | None) -> None:
        """Manage the timer that enables the indeterminate bar animation."""
        if percentage is not None:
            self.auto_refresh = None
        else:
            self.auto_refresh = 1 / 15

    def render(self) -> RenderResult:
        """Render the bar with the correct portion filled."""

Review comment (suggestion):
I tested the code and the type hinter was unhappy, but it is an easy fix. You assign a class, not a class instance, to the `bar_renderable` parameter. So change this to:
```py
from typing import Type
...
        bar_renderable: Type[BarRenderable] = BarRenderable,
```

Code after:
        &> .bar--indeterminate {
            color: $error;
            background: $surface;
        }
        &> .bar--complete {
            color: $success;
            background: $surface;
        }
    }
    """

    percentage: reactive[float | None] = reactive[Optional[float]](None)
    """The percentage of progress that has been completed."""

    gradient: reactive[Gradient | None] = reactive(None)
    """An optional gradient."""

    def __init__(
        self,
        name: str | None = None,
        id: str | None = None,
        classes: str | None = None,
        disabled: bool = False,
        clock: Clock | None = None,
        gradient: Gradient | None = None,
        bar_renderable: Type[BarRenderable] = BarRenderable,
    ):
        """Create a bar for a [`ProgressBar`][textual.widgets.ProgressBar]."""
        self._clock = (clock or Clock()).clone()
        super().__init__(name=name, id=id, classes=classes, disabled=disabled)
        self.set_reactive(Bar.gradient, gradient)
        self.bar_renderable = bar_renderable

    def _validate_percentage(self, percentage: float | None) -> float | None:
        """Avoid updating the bar, if the percentage increase is too small to render."""
        width = self.size.width * 2
        return (
            None
            if percentage is None
            else (int(percentage * width) / width if width else percentage)
        )

    def watch_percentage(self, percentage: float | None) -> None:
        """Manage the timer that enables the indeterminate bar animation."""
        if percentage is not None:
            self.auto_refresh = None
        else:
            self.auto_refresh = 1 / 15

    def render(self) -> RenderResult:
        """Render the bar with the correct portion filled."""