Skip to content

Commit

Permalink
Account for Python 3.9 when defining unions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SethMMorton committed Dec 23, 2024
1 parent 77b8af3 commit 0f700b6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions path/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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]
Expand Down

0 comments on commit 0f700b6

Please sign in to comment.