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

pantsbuild / pants / 19015773527

02 Nov 2025 05:33PM UTC coverage: 17.872% (-62.4%) from 80.3%
19015773527

Pull #22816

github

web-flow
Merge a12d75757 into 6c024e162
Pull Request #22816: Update Pants internal Python to 3.14

4 of 5 new or added lines in 3 files covered. (80.0%)

28452 existing lines in 683 files now uncovered.

9831 of 55007 relevant lines covered (17.87%)

0.18 hits per line

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

0.0
/src/python/pants/backend/nfpm/fields/version.py
1
# Copyright 2023 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 typing import ClassVar
×
7

UNCOV
8
from pants.engine.target import IntField, StringField
×
UNCOV
9
from pants.util.strutil import help_text
×
10

11

UNCOV
12
class NfpmVersionField(StringField):
×
UNCOV
13
    nfpm_alias = "version"
×
UNCOV
14
    alias: ClassVar[str] = nfpm_alias
×
UNCOV
15
    required = True
×
UNCOV
16
    help = help_text(
×
17
        # Based in part on the docs from:
18
        # https://nfpm.goreleaser.com/configuration/#reference
19
        lambda: f"""
20
        The package version (preferably following semver).
21

22
        If '{NfpmVersionSchemaField.alias}' is not 'semver', then this
23
        should not be prefixed with a 'v' because some package managers,
24
        like deb, require the version start with a digit.
25

26
        See the '{NfpmVersionSchemaField.alias}' field's help for more
27
        details about how this field gets parsed by nFPM when it is 'semver'.
28
        """
29
    )
30

31

UNCOV
32
class NfpmVersionSchemaField(StringField):
×
UNCOV
33
    nfpm_alias = "version_schema"
×
UNCOV
34
    alias: ClassVar[str] = nfpm_alias
×
UNCOV
35
    default = "semver"
×
UNCOV
36
    valid_choices = ("none", "semver")
×
UNCOV
37
    help = help_text(
×
38
        # Based in part on the docs from:
39
        # https://nfpm.goreleaser.com/configuration/#reference
40
        lambda: f"""
41
        Which schema the '{NfpmVersionField.alias}' field follows.
42

43
        nFPM only supports two schemas for now: semver, none
44

45
        If this is "none", then nFPM will use '{NfpmVersionField.alias}' as-is.
46

47
        If this is "semver", then nFPM will parse '{NfpmVersionField.alias}'
48
        into its constituent parts using a lenient algorithm: It will strip
49
        a `v` prefix and will accept versions with fewer than 3 components,
50
        like `v1.2`. If parsing fails, then the version is used as-is.
51
        If parsing succeeds, nFPM replaces config options with the parsed
52
        components.
53

54
        The '{NfpmVersionField.alias}' field always gets replaced with a dotted
55
        3 part version (Major.Minor.Patch).
56

57
        The '{NfpmVersionPrereleaseField.alias}' field is only updated if not set.
58
        It gets the "dev", "alpha", "rc", or similar parsed prerelease indicator.
59

60
        The '{NfpmVersionMetadataField.alias}' field is only updated if not set.
61
        This will be set with "git" when the version contains "+git" and similar
62
        metadata tags.
63

64
        The '{NfpmVersionReleaseField.alias}' and '{NfpmVersionEpochField.alias}' fields are NOT
65
        replaced by components parsed from '{NfpmVersionField.alias}'.
66

67
        N.B.: Some of these fields are not available for all package types.
68

69
        This field is named "{NfpmVersionField.alias}" because that is the term
70
        used by nFPM. Though deb and rpm packaging also use "version", this is
71
        known as "pkgver" in apk and archlinux packaging.
72
        """
73
    )
74

75

UNCOV
76
class NfpmVersionPrereleaseField(StringField):
×
UNCOV
77
    nfpm_alias = "prerelease"
×
78
    # nFPM calls this "prerelease", but we prefix with "version_" to
79
    # highlight this field's relationship with the other version_ fields.
UNCOV
80
    alias: ClassVar[str] = "version_prerelease"
×
UNCOV
81
    help = help_text(
×
82
        lambda: f"""
83
        This is a pre-release indicator like "alpha" or "beta" and often includes
84
        a numeric component like "rc1" and "rc2".
85

86
        For apk and archlinux, version and prerelease are merely concatenated.
87
        For deb and rpm, prerelease is typically prefixed with a "~" in the version.
88

89
        nFPM extracts the default for this from '{NfpmVersionField.alias}'
90
        if it is semver compatible. If you set '{NfpmVersionPrereleaseField.alias}',
91
        then any prerelease component of '{NfpmVersionField.alias}' gets discarded.
92
        """
93
    )
94

95

UNCOV
96
class NfpmVersionMetadataField(StringField):
×
UNCOV
97
    nfpm_alias = "version_metadata"
×
UNCOV
98
    alias: ClassVar[str] = nfpm_alias
×
UNCOV
99
    help = help_text(
×
100
        lambda: f"""
101
        This is package-manager specific metadata for the version.
102

103
        This is typically prefixed with a "+" in the version. If the version
104
        contains "+git", then the '{NfpmVersionMetadataField.alias}' is "git".
105
        Debian has various conventions for this metadata, including things like
106
        "+b", "+nmu", "+really", and "+deb10u1". See:
107
        https://www.debian.org/doc/debian-policy/ch-controlfields.html#special-version-conventions
108

109
        nFPM extracts the default for this from '{NfpmVersionField.alias}'
110
        if it is semver compatible. If you set '{NfpmVersionMetadataField.alias}',
111
        then any metadata component of '{NfpmVersionField.alias}' gets discarded.
112
        """
113
    )
114

115

UNCOV
116
class NfpmVersionReleaseField(IntField):
×
UNCOV
117
    nfpm_alias = "release"
×
118
    # nFPM calls this "release", but we prefix with "version_" to
119
    # highlight this field's relationship with the other version_ fields.
UNCOV
120
    alias: ClassVar[str] = "version_release"
×
UNCOV
121
    default = 1
×
UNCOV
122
    help = help_text(
×
123
        lambda: f"""
124
        The release or revision number for a given package version.
125

126
        Increment the release each time you release the same version of the
127
        package. Often, these releases allow for correcting metadata about
128
        a package or to rebuild something that was broken in a previous release
129
        of that version.
130

131
        Reset this to 1 whenever you bump the '{NfpmVersionField.alias}' field.
132

133
        N.B.: nFPM does NOT parse this from the '{NfpmVersionField.alias}' field.
134
        """
135
    )
136

137

UNCOV
138
class NfpmVersionEpochField(IntField):
×
UNCOV
139
    nfpm_alias = "epoch"
×
140
    # nFPM calls this "epoch", but we prefix with "version_" to
141
    # highlight this field's relationship with the other version_ fields.
UNCOV
142
    alias: ClassVar[str] = "version_epoch"
×
UNCOV
143
    help = help_text(
×
144
        lambda: f"""
145
        A package with a higher version epoch will always be considered newer.
146
        This is primarily useful when the version numbering scheme has changed.
147

148
        Debian and RPM documentation warn against using epoch in most cases:
149
        https://www.debian.org/doc/debian-policy/ch-controlfields.html#epochs-should-be-used-sparingly
150
        https://rpm-packaging-guide.github.io/#epoch
151

152
        When this field is None (the default) nFPM will use "" for deb packages,
153
        and "0" for rpm packages.
154

155
        N.B.: The nFPM documentation incorrectly notes that nFPM can parse this
156
        from the '{NfpmVersionField.alias}' field; the nFPM code actually does
157
        not replace or update this.
158
        """
159
    )
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

© 2025 Coveralls, Inc