diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 5404847..74bf5b9 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -33,8 +33,8 @@ jobs: run: uv run ruff format homeassistant_api - name: Run Ruff linting run: uv run ruff check homeassistant_api - - name: Run Zuban - run: uv run zuban check homeassistant_api + - name: Run ty + run: uv run ty check homeassistant_api code_functionality: name: "Code Functionality" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0eea4ab..3eb18ee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,9 +1,9 @@ repos: - repo: local hooks: - - id: zuban - name: zuban - entry: uv run zuban check homeassistant_api + - id: ty + name: ty + entry: uv run ty check homeassistant_api language: system types: [python] pass_filenames: false diff --git a/docs/CONTRIBUTING.rst b/docs/CONTRIBUTING.rst index 5f63961..c27f5bb 100644 --- a/docs/CONTRIBUTING.rst +++ b/docs/CONTRIBUTING.rst @@ -136,7 +136,7 @@ Code Styling Guidelines In order to make sure that our code is easy to read, and navigate as well as to stop stupid mistakes like typos, undefined variables, etc, we enforce code standards. -Using the tools, :code:`ruff`, :code:`zuban`, and :code:`pytest`, we make sure that our code quality is top notch and that changes work everywhere. +Using the tools, :code:`ruff`, :code:`ty`, and :code:`pytest`, we make sure that our code quality is top notch and that changes work everywhere. You can run those tools manually yourself, but they also run automatically when you open a Pull Request on :resource:`GitHub `. diff --git a/homeassistant_api/models/entity.py b/homeassistant_api/models/entity.py index 3efbaa8..c8ac167 100644 --- a/homeassistant_api/models/entity.py +++ b/homeassistant_api/models/entity.py @@ -96,7 +96,12 @@ class BaseEntity(BaseModel): slug: str state: State - group: "BaseGroup" = Field(exclude=True, repr=False) + + if TYPE_CHECKING: + # Subclasses declare the concrete ``group`` field. It is read-only here + # so they can narrow its type without an unsound mutable override. + @property + def group(self) -> BaseGroup: ... @property def entity_id(self) -> str: diff --git a/pyproject.toml b/pyproject.toml index 6ba9028..fbd5714 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,6 @@ dev = [ "types-docutils>=0.22", "types-simplejson>=3.20", "types-toml>=0.10", - "zuban>=0.7", "ruff>=0.15", "pytest-asyncio>=1", "pytest-cov>=7", @@ -44,6 +43,7 @@ dev = [ "prek>=0.3.8", "pre-commit>=4.5.1", "nimax", + "ty>=1", ] [tool.nimax] @@ -110,10 +110,6 @@ ignore = [ [tool.ruff.lint.isort] force-single-line = true -[tool.zuban] -exclude = ["^docs/"] -untyped_function_return_mode = "inferred" - [tool.hatch.build.targets.wheel] packages = ["homeassistant_api"]