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)
This commit is contained in:
Štěpán Balážik 2026-02-20 15:03:16 +01:00
parent fe38515ad0
commit 1d5924c82f

View 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: