twine.settings module

Module containing logic for handling settings.

class twine.settings.Settings[source]

Object that manages the configuration for Twine.

This object can only be instantiated with keyword arguments.

For example,

Settings(True, username='fakeusername')

Will raise a TypeError. Instead, you would want

Settings(sign=True, username='fakeusername')
__init__(*, attestations: bool = False, sign: bool = False, sign_with: str = 'gpg', identity: str | None = None, username: str | None = None, password: str | None = None, non_interactive: bool = False, comment: str | None = None, config_file: str = utils.DEFAULT_CONFIG_FILE, skip_existing: bool = False, cacert: str | None = None, client_cert: str | None = None, repository_name: str = 'pypi', repository_url: str | None = None, verbose: bool = False, disable_progress_bar: bool = False, **ignored_kwargs: Any) None[source]

Initialize our settings instance.

Parameters:
  • attestations – Whether the package file should be uploaded with attestations.

  • sign – Configure whether the package file should be signed.

  • sign_with – The name of the executable used to sign the package with.

  • identity – The GPG identity that should be used to sign the package file.

  • username – The username used to authenticate to the repository (package index).

  • password – The password used to authenticate to the repository (package index).

  • non_interactive – Do not interactively prompt for username/password if the required credentials are missing.

  • comment – The comment to include with each distribution file.

  • config_file – The path to the configuration file to use.

  • skip_existing – Specify whether twine should continue uploading files if one of them already exists. This primarily supports PyPI. Other package indexes may not be supported.

  • cacert – The path to the bundle of certificates used to verify the TLS connection to the package index.

  • client_cert – The path to the client certificate used to perform authentication to the index. This must be a single file that contains both the private key and the PEM-encoded certificate.

  • repository_name – The name of the repository (package index) to interact with. This should correspond to a section in the config file.

  • repository_url – The URL of the repository (package index) to interact with. This will override the settings inferred from repository_name.

  • verbose – Show verbose output.

  • disable_progress_bar – Disable the progress bar.

property username: str | None
property password: str | None
_allow_noninteractive() AbstractContextManager[None][source]

Bypass NonInteractive error when client cert is present.

property verbose: bool
static register_argparse_arguments(parser: ArgumentParser) None[source]

Register the arguments for argparse.

classmethod from_argparse(args: Namespace) Settings[source]

Generate the Settings from parsed arguments.

_handle_package_signing(sign: bool, sign_with: str, identity: str | None) None[source]
_handle_repository_options(repository_name: str, repository_url: str | None) None[source]
_handle_certificates(cacert: str | None, client_cert: str | None) None[source]
check_repository_url() None[source]

Verify we are not using legacy PyPI.

Raises:

twine.exceptions.UploadToDeprecatedPyPIDetected – The configured repository URL is for legacy PyPI.

create_repository() Repository[source]

Create a new repository for uploading.