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)
information regarding copyright ownership.
"""
-from typing import Optional
-
import abc
import dns.name
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: