• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 24055979590

06 Apr 2026 11:17PM UTC coverage: 52.37% (-40.5%) from 92.908%
24055979590

Pull #23225

github

web-flow
Merge 67474653c into 542ca048d
Pull Request #23225: Add --test-show-all-batch-targets to expose all targets in batched pytest

6 of 17 new or added lines in 2 files covered. (35.29%)

23030 existing lines in 605 files now uncovered.

31643 of 60422 relevant lines covered (52.37%)

1.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/python/pants/backend/python/subsystems/twine.py
1
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

UNCOV
4
from __future__ import annotations
×
5

UNCOV
6
from pants.backend.python.subsystems.python_tool_base import PythonToolBase
×
UNCOV
7
from pants.backend.python.target_types import ConsoleScript
×
UNCOV
8
from pants.core.goals.resolves import ExportableTool
×
UNCOV
9
from pants.core.util_rules.config_files import ConfigFilesRequest
×
UNCOV
10
from pants.engine.fs import CreateDigest
×
UNCOV
11
from pants.engine.rules import collect_rules
×
UNCOV
12
from pants.engine.unions import UnionRule
×
UNCOV
13
from pants.option.global_options import ca_certs_path_to_file_content
×
UNCOV
14
from pants.option.option_types import ArgsListOption, BoolOption, FileOption, SkipOption, StrOption
×
UNCOV
15
from pants.util.docutil import doc_url
×
UNCOV
16
from pants.util.strutil import softwrap
×
17

18
# pants: infer-dep(twine.lock*)
19

20

UNCOV
21
class TwineSubsystem(PythonToolBase):
×
UNCOV
22
    options_scope = "twine"
×
UNCOV
23
    name = "Twine"
×
UNCOV
24
    help_short = (
×
25
        "The utility for publishing Python distributions to PyPI and other Python repositories."
26
    )
27

UNCOV
28
    default_version = "twine>=4,<5"
×
UNCOV
29
    default_main = ConsoleScript("twine")
×
30

UNCOV
31
    default_requirements = [
×
32
        "twine>=3.7.1,<5",
33
        # This explicit dependency resolves a weird behavior in poetry, where it would include a
34
        # sys platform constraint on "Windows" when this was included transitively from the twine
35
        # requirements.
36
        # See: https://github.com/pantsbuild/pants/pull/13594#issuecomment-968154931
37
        "colorama>=0.4.3",
38
        # Remove this constraint once on twine > 5. See:
39
        # https://github.com/pypa/twine/issues/977
40
        # https://github.com/pypa/twine/issues/1125
41
        "importlib-metadata<8",
42
    ]
43

UNCOV
44
    register_interpreter_constraints = True
×
45

UNCOV
46
    default_lockfile_resource = ("pants.backend.python.subsystems", "twine.lock")
×
47

UNCOV
48
    skip = SkipOption("publish")
×
UNCOV
49
    args = ArgsListOption(example="--skip-existing")
×
UNCOV
50
    config = FileOption(
×
51
        default=None,
52
        advanced=True,
53
        help=lambda cls: softwrap(
54
            f"""
55
            Path to a .pypirc config file to use.
56
            (https://packaging.python.org/specifications/pypirc/)
57

58
            Setting this option will disable `[{cls.options_scope}].config_discovery`. Use
59
            this option if the config is located in a non-standard location.
60
            """
61
        ),
62
    )
UNCOV
63
    config_discovery = BoolOption(
×
64
        default=True,
65
        advanced=True,
66
        help=lambda cls: softwrap(
67
            f"""
68
            If true, Pants will include all relevant config files during runs (`.pypirc`).
69

70
            Use `[{cls.options_scope}].config` instead if your config is in a non-standard location.
71
            """
72
        ),
73
    )
74

UNCOV
75
    ca_certs_path = StrOption(
×
76
        advanced=True,
77
        default="<inherit>",
78
        help=softwrap(
79
            f"""
80
            Path to a file containing PEM-format CA certificates used for verifying secure
81
            connections when publishing python distributions.
82

83
            Uses the value from `[GLOBAL].ca_certs_path` by default. Set to `"<none>"` to
84
            not use any certificates.
85

86
            Even when using the `docker_environment` and `remote_environment` targets, this path
87
            will be read from the local host, and those certs will be used in the environment.
88

89
            This option cannot be overridden via environment targets, so if you need a different
90
            value than what the rest of your organization is using, override the value via an
91
            environment variable, CLI argument, or `.pants.rc` file. See {doc_url("docs/using-pants/key-concepts/options")}.
92
            """
93
        ),
94
    )
95

UNCOV
96
    def config_request(self) -> ConfigFilesRequest:
×
97
        # Refer to https://twine.readthedocs.io/en/latest/#configuration for how config files are
98
        # discovered.
UNCOV
99
        return ConfigFilesRequest(
×
100
            specified=self.config,
101
            specified_option_name=f"[{self.options_scope}].config",
102
            discovery=self.config_discovery,
103
            check_existence=[".pypirc"],
104
        )
105

UNCOV
106
    def ca_certs_digest_request(self, default_ca_certs_path: str | None) -> CreateDigest | None:
×
UNCOV
107
        path = default_ca_certs_path if self.ca_certs_path == "<inherit>" else self.ca_certs_path
×
UNCOV
108
        if not path or path == "<none>":
×
UNCOV
109
            return None
×
UNCOV
110
        return CreateDigest((ca_certs_path_to_file_content(path),))
×
111

112

UNCOV
113
def rules():
×
114
    return [
×
115
        *collect_rules(),
116
        UnionRule(ExportableTool, TwineSubsystem),
117
    ]
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc