From: Štěpán Balážik Date: Fri, 20 Feb 2026 14:03:16 +0000 (+0100) Subject: Replace Optional["T"] with "T | None" X-Git-Tag: v9.21.19~15^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d5924c82fcf8f55d339bbf0a40c31e5f10c635e;p=thirdparty%2Fbind9.git Replace Optional["T"] with "T | None" 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) --- diff --git a/bin/tests/system/bailiwick/bailiwick_ans.py b/bin/tests/system/bailiwick/bailiwick_ans.py index 364cda2746b..109516799fb 100644 --- a/bin/tests/system/bailiwick/bailiwick_ans.py +++ b/bin/tests/system/bailiwick/bailiwick_ans.py @@ -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: