Skip to content

Commit

Permalink
Try to fix typing for Python 3.12
Browse files Browse the repository at this point in the history
It seems mypy is expecting the comments for ignoring specific typing
errors at different locations depending on the used Python version.
  • Loading branch information
bjoernricks committed Oct 11, 2023
1 parent 3ebc073 commit b734a69
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions pontos/version/schemes/_pep440.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ def from_version(cls, version: "Version") -> "PEP440Version":
)
elif version.is_pre_release:
new_version = cls.from_string(
f"{version.major}." # type: ignore[index]
f"{version.major}."
f"{version.minor}."
f"{version.patch}"
f"-{version.pre[0]}{version.pre[1]}"
f"-{version.pre[0]}{version.pre[1]}" # type: ignore[index]
f"{version_local}"
)
else:
Expand Down Expand Up @@ -251,19 +251,19 @@ def next_dev_version(cls, current_version: Version) -> Version:
f"{current_version.major}." # type: ignore[operator]
f"{current_version.minor}."
f"{current_version.patch}"
f"-{current_version.pre[0]}{current_version.pre[1]}"
f".dev{current_version.dev + 1}"
f"-{current_version.pre[0]}{current_version.pre[1]}" # type: ignore[index] # noqa: E501
f".dev{current_version.dev + 1}" # type: ignore[operator]
)
return cls.version_from_string(
f"{current_version.major}." # type: ignore[operator]
f"{current_version.minor}."
f"{current_version.patch}"
f".dev{current_version.dev + 1}"
f".dev{current_version.dev + 1}" # type: ignore[operator]
)

if current_version.is_pre_release:
return cls.version_from_string(
f"{current_version.major}." # type: ignore[index]
f"{current_version.major}."
f"{current_version.minor}."
f"{current_version.patch}"
f"{current_version.pre[0]}{current_version.pre[1] + 1}.dev1" # type: ignore[index] # noqa: E501
Expand Down
8 changes: 4 additions & 4 deletions pontos/version/schemes/_semantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,10 @@ def from_version(cls, version: "Version") -> "SemanticVersion":
)
elif version.is_pre_release:
new_version = cls.from_string(
f"{version.major}." # type: ignore[index]
f"{version.major}."
f"{version.minor}."
f"{version.patch}"
f"-{version.pre[0]}{version.pre[1]}"
f"-{version.pre[0]}{version.pre[1]}" # type: ignore[index]
f"{version_local}"
)
else:
Expand All @@ -331,13 +331,13 @@ def next_dev_version(cls, current_version: Version) -> Version:
f"{current_version.minor}."
f"{current_version.patch}"
f"-{current_version.pre[0]}{current_version.pre[1]}"
f"-dev{current_version.dev + 1}"
f"-dev{current_version.dev + 1}" # type: ignore[operator]
)
return cls.version_from_string(
f"{current_version.major}." # type: ignore[operator]
f"{current_version.minor}."
f"{current_version.patch}"
f"-dev{current_version.dev + 1}"
f"-dev{current_version.dev + 1}" # type: ignore[operator]
)

if current_version.is_pre_release:
Expand Down
6 changes: 3 additions & 3 deletions pontos/version/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Callable, Optional, Tuple
from typing import Any, Callable, Optional


class Version(ABC):
Expand Down Expand Up @@ -68,7 +68,7 @@ def patch(self) -> int:

@property
@abstractmethod
def pre(self) -> Optional[Tuple[str, int]]:
def pre(self) -> Optional[tuple[str, int]]:
"""The pre-release segment of the version."""

@property
Expand All @@ -78,7 +78,7 @@ def dev(self) -> Optional[int]:

@property
@abstractmethod
def local(self) -> Optional[Tuple[str, int]]:
def local(self) -> Optional[tuple[str, int]]:
"""The local version segment of the version."""

@property
Expand Down

0 comments on commit b734a69

Please sign in to comment.