]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Replace Optional["T"] with "T | None"
authorŠtěpán Balážik <stepan@isc.org>
Fri, 20 Feb 2026 14:03:16 +0000 (15:03 +0100)
committerŠtěpán Balážik <stepan@isc.org>
Fri, 20 Feb 2026 14:17:32 +0000 (15:17 +0100)
In Python 3.10 strings don't support the | operator, so ruff doesn't
attempt to fix these. Quote the entire type specification to avoid the
typing.Optional import.

Alternatives I considered:
- leaving it as is (only use of Optional in the code base)
- using `from future import __annotations__` (replacing one import with
  another one)

bin/tests/system/bailiwick/bailiwick_ans.py

index 364cda2746b1e7b4c3e24f1b75fceef5c1a9ab6f..109516799fbca8935c3d20cf773c123186c24365 100644 (file)
@@ -11,8 +11,6 @@ See the COPYRIGHT file distributed with this work for additional
 information regarding copyright ownership.
 """
 
-from typing import Optional
-
 import abc
 
 import dns.name
@@ -37,7 +35,7 @@ class ResponseSpoofer(ResponseHandler, abc.ABC):
         cls.spoofers[mode] = cls
 
     @classmethod
-    def get_spoofer(cls, mode: str) -> Optional["ResponseSpoofer"]:
+    def get_spoofer(cls, mode: str) -> "ResponseSpoofer | None":
         try:
             return cls.spoofers[mode]()
         except KeyError: