From 0f700b68c3dbca7a271d4afd82f06b76cdc0507a Mon Sep 17 00:00:00 2001 From: Seth Morton Date: Mon, 23 Dec 2024 13:43:10 -0800 Subject: [PATCH] Account for Python 3.9 when defining unions The union for _Match is not defined as part of a function annotation, so the "annotations" import from __future__ does not take effect and thus results in a syntax error on Python < 3.10. To fix, the Union annotation is used for this one type definition. --- path/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/path/__init__.py b/path/__init__.py index ef33c5b..61f8ed4 100644 --- a/path/__init__.py +++ b/path/__init__.py @@ -72,7 +72,7 @@ ) if TYPE_CHECKING: - from typing_extensions import Literal, Never, Self + from typing_extensions import Literal, Never, Self, Union from _typeshed import ( OpenBinaryMode, OpenBinaryModeReading, @@ -82,7 +82,7 @@ ExcInfo, ) - _Match = str | Callable[[str], bool] | None + _Match = Union[str, Callable[[str], bool], None] _CopyFn = Callable[[str, str], object] _IgnoreFn = Callable[[str, list[str]], Iterable[str]] _OnErrorCallback = Callable[[Callable[..., Any], str, ExcInfo], object]