88import base64
99import json
1010from enum import Enum
11- from typing import TYPE_CHECKING , Annotated , Any , Literal , NewType , Optional , Union , get_args
11+ from typing import TYPE_CHECKING , Annotated , Any , Literal , NewType
1212
1313import packaging
1414import packaging .tags
@@ -238,7 +238,7 @@ def verify(
238238 * ,
239239 staging : bool = False ,
240240 offline : bool = False ,
241- ) -> tuple [str , Optional [ dict [str , Any ]] ]:
241+ ) -> tuple [str , dict [str , Any ] | None ]:
242242 """Verify against an existing Python distribution.
243243
244244 The `identity` can be an object confirming to
@@ -257,8 +257,7 @@ def verify(
257257 # NOTE: Can't do `isinstance` with `Publisher` since it's
258258 # a `_GenericAlias`; instead we punch through to the inner
259259 # `_Publisher` union.
260- # Use of typing.get_args is needed for Python < 3.10
261- if isinstance (identity , get_args (_Publisher )):
260+ if isinstance (identity , _Publisher ):
262261 policy = identity ._as_policy () # noqa: SLF001
263262 else :
264263 policy = identity
@@ -412,7 +411,7 @@ def _der_decode_utf8string(der: bytes) -> str:
412411 packaging .utils .BuildTag ,
413412 frozenset [packaging .tags .Tag ],
414413]
415- _DistName = Union [ _SdistName , _BdistName ]
414+ _DistName = _SdistName | _BdistName
416415
417416
418417def _check_dist_filename (dist : str ) -> _DistName :
@@ -544,7 +543,7 @@ class GitHubPublisher(_PublisherBase):
544543 action.
545544 """
546545
547- environment : Optional [ str ] = None
546+ environment : str | None = None
548547 """
549548 The optional name GitHub Actions environment that the publishing
550549 action was performed from.
@@ -637,7 +636,7 @@ class GitLabPublisher(_PublisherBase):
637636 but can be customized.
638637 """
639638
640- environment : Optional [ str ] = None
639+ environment : str | None = None
641640 """
642641 The optional environment that the publishing action was performed from.
643642 """
@@ -661,7 +660,7 @@ def _as_policy(self) -> VerificationPolicy:
661660 return policy .Identity (identity = self .email , issuer = "https://accounts.google.com" )
662661
663662
664- _Publisher = Union [ GitHubPublisher , GitLabPublisher , GooglePublisher ]
663+ _Publisher = GitHubPublisher | GitLabPublisher | GooglePublisher
665664Publisher = Annotated [_Publisher , Field (discriminator = "kind" )]
666665
667666
0 commit comments