]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Remove annotations import from __future__
authorJoerg Behrmann <behrmann@physik.fu-berlin.de>
Wed, 11 Jan 2023 09:32:33 +0000 (10:32 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 11 Jan 2023 10:51:24 +0000 (11:51 +0100)
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

mkosi/__init__.py
mkosi/backend.py

index 10bb15db15af9a3d3a9102f699816d4045e31491..0e8a5d8bb571f49245346e14477a9e551d020975 100644 (file)
@@ -1,7 +1,5 @@
 # SPDX-License-Identifier: LGPL-2.1+
 
-from __future__ import annotations
-
 import argparse
 import configparser
 import contextlib
index 43b1b7650f66c432527f2c9fc2ae6bb4a31185e4..a3679fbb362b44be865c65a7a6a02b5fa7344a0f 100644 (file)
@@ -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."""