Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Python 3.10 errors #11

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions zmk/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from collections.abc import Iterable, Mapping, Sequence
from dataclasses import asdict, dataclass, field
from pathlib import Path
from typing import Any, Self, TypeVar, cast, overload
from typing import Any, TypeVar, cast, overload

import dacite

Expand Down Expand Up @@ -57,7 +57,7 @@ class BuildMatrix:
_data: dict[str, Any] | None

@classmethod
def from_repo(cls, repo: Repo) -> Self:
def from_repo(cls, repo: Repo) -> "BuildMatrix":
"""Get the build matrix for a repo"""
return cls(repo.build_matrix_path)

Expand Down
7 changes: 5 additions & 2 deletions zmk/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from dataclasses import dataclass, field
from functools import reduce
from pathlib import Path
from typing import Any, Literal, Self, TypeAlias, TypeGuard
from typing import Any, Literal, Type, TypeAlias, TypeGuard, TypeVar

import dacite

Expand All @@ -22,6 +22,9 @@
# TODO: dict should match { id: str, features: list[Feature] }
Variant: TypeAlias = str | dict[str, str]

# TODO: replace with typing.Self once minimum Python version is >= 3.11
_Self = TypeVar("_Self", bound="Hardware")


@dataclass
class Hardware:
Expand All @@ -47,7 +50,7 @@ def __rich__(self) -> Any:
return f"{self.id} [dim]{self.name}"

@classmethod
def from_dict(cls, data) -> Self:
def from_dict(cls: "Type[_Self]", data) -> _Self:
"""Read a hardware description from a dict"""
return dacite.from_dict(cls, data)

Expand Down