From 09e9182d790b74720d631b8f110b050a6c25bc72 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= <hugo@lysator.liu.se>
Date: Wed, 20 Sep 2023 06:32:08 +0200
Subject: [PATCH] Minor cleaonup.

---
 muppet/puppet/format/parser.py | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/muppet/puppet/format/parser.py b/muppet/puppet/format/parser.py
index 552483b..4235792 100644
--- a/muppet/puppet/format/parser.py
+++ b/muppet/puppet/format/parser.py
@@ -85,6 +85,7 @@ from typing import (
 )
 
 from dataclasses import dataclass
+import sys
 
 
 ws = name('ws', tag('ws', many(line_comment('#') | space)))
@@ -92,19 +93,18 @@ ws = name('ws', tag('ws', many(line_comment('#') | space)))
 
 F = TypeVar('F', bound=Callable[..., object])
 
-# TODO replace this decorator with
-# from typing import override
-# once the target python version is changed to 3.12
 
+if sys.version_info >= (3, 12):
+    from typing import override
+else:
+    def override(f: F) -> F:
+        """
+        Return function unchanged.
 
-def override(f: F) -> F:
-    """
-    Return function unchanged.
-
-    Placeholder @override annotator if the actual annotation isn't
-    implemented in the current python version.
-    """
-    return f
+        Placeholder @override annotator if the actual annotation isn't
+        implemented in the current python version.
+        """
+        return f
 
 
 logger = logging.getLogger(__name__)
@@ -318,7 +318,7 @@ class ParserFormatter(Serializer[ParseDirective]):
         Note that the delimiting "${" and "}" should be handled
         outside this procedure.
         """
-        parser = ws
+        parser: ParseDirective = ws
         match item:
             case PuppetAccess(PuppetVar(name), _):
                 parser &= optional(s('$')) & name
-- 
GitLab