Skip to content

Commit

Permalink
Rename oidc -> trusted_publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Dec 4, 2024
1 parent c858c7a commit 6b482f9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ register = "twine.commands.register:main"

[project.optional-dependencies]
keyring = ["keyring >= 15.1"]
oidc = ["id"]
trusted-publishing = ["id"]

[project.scripts]
twine = "twine.__main__:main"
Expand Down
9 changes: 6 additions & 3 deletions twine/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ def __init__(

class Resolver:
def __init__(
self, config: utils.RepositoryConfig, input: CredentialInput, oidc: bool = False
self,
config: utils.RepositoryConfig,
input: CredentialInput,
trusted_publishing: bool = False,
) -> None:
self.config = config
self.input = input
self.oidc = oidc
self.trusted_publishing = trusted_publishing

@classmethod
def choose(cls, interactive: bool) -> Type["Resolver"]:
Expand All @@ -59,7 +62,7 @@ def username(self) -> Optional[str]:
@property
@functools.lru_cache()
def password(self) -> Optional[str]:
if self.oidc:
if self.trusted_publishing:
# Trusted publishing (OpenID Connect): get one token from the CI
# system, and exchange that for a PyPI token.
from id import detect_credential # type: ignore
Expand Down
4 changes: 2 additions & 2 deletions twine/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __init__(
self.auth = auth.Resolver.choose(not non_interactive)(
self.repository_config,
auth.CredentialInput(username, password),
oidc=trusted_publish,
trusted_publishing=trusted_publish,
)

@property
Expand Down Expand Up @@ -231,7 +231,7 @@ def register_argparse_arguments(parser: argparse.ArgumentParser) -> None:
action="store_true",
help="Upload from CI using trusted publishing. Use this without "
"specifying username & password. Requires an optional extra "
"dependency (install twine[oidc]).",
"dependency (install twine[trusted-publishing]).",
)
parser.add_argument(
"--non-interactive",
Expand Down

0 comments on commit 6b482f9

Please sign in to comment.