From: Joerg Behrmann Date: Wed, 11 Jan 2023 09:32:33 +0000 (+0100) Subject: Remove annotations import from __future__ X-Git-Tag: v15~371 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f4cf718a14107cb91cd2b22917281bcd88e8d91;p=thirdparty%2Fmkosi.git Remove annotations import from __future__ PEP 563 is a PEP that stringifies type annotations. The feature was made available as opt in. It is still very much in flux or under consideration upstream and has fallen so much out of favour that the Python steering council added the note [1] PEP 563 Postponed Evaluation of Annotations (the from __future__ import annotations future statement) that was originally planned for release in Python 3.10 has been put on hold indefinitely. See this message from the Steering Council for more information. in the release notes of CPython 3.11 after punting on accepting the PEP for two releases. The import does a lot more, but we only use the type stringification. There is little gain from using this, but with one of the main features of the import indefinitely on hold, it seems prudent not to use it. With Python 3.11 the PEP 673 Self type was introduced [2], that will solve this problem for us, once we move on to 3.11. [1] https://docs.python.org/3.11/whatsnew/3.11.html#pep-563-may-not-be-the-future [2] https://docs.python.org/3.11/whatsnew/3.11.html#whatsnew311-pep673 --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 10bb15db1..0e8a5d8bb 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -1,7 +1,5 @@ # SPDX-License-Identifier: LGPL-2.1+ -from __future__ import annotations - import argparse import configparser import contextlib diff --git a/mkosi/backend.py b/mkosi/backend.py index 43b1b7650..a3679fbb3 100644 --- a/mkosi/backend.py +++ b/mkosi/backend.py @@ -1,7 +1,5 @@ # SPDX-License-Identifier: LGPL-2.1+ -from __future__ import annotations - import argparse import ast import collections @@ -283,7 +281,7 @@ class SourceFileTransfer(enum.Enum): return self.value @classmethod - def doc(cls) -> Dict[SourceFileTransfer, str]: + def doc(cls) -> Dict["SourceFileTransfer", str]: return { cls.copy_all: "normal file copy", cls.copy_git_cached: "use git ls-files --cached, ignoring any file that git itself ignores", @@ -326,11 +324,6 @@ def strip_suffixes(path: Path) -> Path: return path -def build_auxiliary_output_path(args: Union[argparse.Namespace, MkosiConfig], suffix: str) -> Path: - output = strip_suffixes(args.output) - return output.with_name(f"{output.name}{suffix}") - - @dataclasses.dataclass(frozen=True) class MkosiConfig: """Type-hinted storage for command line arguments. @@ -507,6 +500,11 @@ class MkosiConfig: ) +def build_auxiliary_output_path(args: Union[argparse.Namespace, MkosiConfig], suffix: str) -> Path: + output = strip_suffixes(args.output) + return output.with_name(f"{output.name}{suffix}") + + @dataclasses.dataclass class MkosiState: """State related properties."""