summaryrefslogtreecommitdiff
path: root/coverage/version.py
blob: 516d00c15301ad84e82350f11d5cc7180a64ddfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt

"""The version and URL for coverage.py"""
# This file is exec'ed in setup.py, don't import anything!

from __future__ import annotations

# version_info: same semantics as sys.version_info.
# _dev: the .devN suffix if any.
version_info = (7, 2, 5, "final", 0)
_dev = 0


def _make_version(
    major: int,
    minor: int,
    micro: int,
    releaselevel: str = "final",
    serial: int = 0,
    dev: int = 0,
) -> str:
    """Create a readable version string from version_info tuple components."""
    assert releaselevel in ["alpha", "beta", "candidate", "final"]
    version = "%d.%d.%d" % (major, minor, micro)
    if releaselevel != "final":
        short = {"alpha": "a", "beta": "b", "candidate": "rc"}[releaselevel]
        version += f"{short}{serial}"
    if dev != 0:
        version += f".dev{dev}"
    return version


def _make_url(
    major: int,
    minor: int,
    micro: int,
    releaselevel: str,
    serial: int = 0,
    dev: int = 0,
) -> str:
    """Make the URL people should start at for this version of coverage.py."""
    return (
        "https://coverage.readthedocs.io/en/"
        + _make_version(major, minor, micro, releaselevel, serial, dev)
    )


__version__ = _make_version(*version_info, _dev)
__url__ = _make_url(*version_info, _dev)