From e87e449191d80bd1fd1a3101b237760a562c22ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Tue, 10 Oct 2023 16:19:25 +0200 Subject: [PATCH] Try to fix typing for Python 3.12 It seems mypy is expecting the comments for ignoring specific typing errors at different locations depending on the used Python version. --- pontos/version/schemes/_pep440.py | 12 ++++++------ pontos/version/schemes/_semantic.py | 8 ++++---- pontos/version/version.py | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pontos/version/schemes/_pep440.py b/pontos/version/schemes/_pep440.py index 255d0d8cc..0b61c076b 100644 --- a/pontos/version/schemes/_pep440.py +++ b/pontos/version/schemes/_pep440.py @@ -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: @@ -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 diff --git a/pontos/version/schemes/_semantic.py b/pontos/version/schemes/_semantic.py index 9110c5c74..666cc1d71 100644 --- a/pontos/version/schemes/_semantic.py +++ b/pontos/version/schemes/_semantic.py @@ -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: @@ -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: diff --git a/pontos/version/version.py b/pontos/version/version.py index 7934c4f2a..cac7caf2b 100644 --- a/pontos/version/version.py +++ b/pontos/version/version.py @@ -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): @@ -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 @@ -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