Skip to content

Functions

parse_version(string: str, version_type: Type[Version] = Version) -> Version

Parses a string into a version of version_type.

Parameters:

Name Type Description Default
string str

The string to parse.

required
version_type Type[Version]

The version type to use in conversion.

Version

Returns:

Type Description
Version

The newly parsed Version.

Source code in versions/functions.py
28
29
30
31
32
33
34
35
36
37
38
39
@cache
def parse_version(string: str, version_type: Type[Version] = Version) -> Version:
    """Parses a `string` into a version of `version_type`.

    Arguments:
        string: The string to parse.
        version_type: The version type to use in conversion.

    Returns:
        The newly parsed [`Version`][versions.version.Version].
    """
    return VersionParser(version_type).parse(string)

parse_specifier(string: str, version_type: Type[Version] = Version) -> Specifier

Parses a string into a version specifier with versions of version_type.

Parameters:

Name Type Description Default
string str

The string to parse.

required
version_type Type[Version]

The version type to use in conversion.

Version

Returns:

Type Description
Specifier

The newly parsed Specifier.

Source code in versions/functions.py
42
43
44
45
46
47
48
49
50
51
52
53
@cache
def parse_specifier(string: str, version_type: Type[Version] = Version) -> Specifier:
    """Parses a `string` into a version specifier with versions of `version_type`.

    Arguments:
        string: The string to parse.
        version_type: The version type to use in conversion.

    Returns:
        The newly parsed [`Specifier`][versions.specifiers.Specifier].
    """
    return SpecifierParser(VersionParser(version_type)).parse(string)

parse_version_set(string: str, version_type: Type[Version] = Version) -> VersionSet

Parses a string into a version set with versions of version_type.

Parameters:

Name Type Description Default
string str

The string to parse.

required
version_type Type[Version]

The version type to use in conversion.

Version

Returns:

Type Description
VersionSet

The newly parsed VersionSet.

Source code in versions/functions.py
56
57
58
59
60
61
62
63
64
65
66
67
@cache
def parse_version_set(string: str, version_type: Type[Version] = Version) -> VersionSet:
    """Parses a `string` into a version set with versions of `version_type`.

    Arguments:
        string: The string to parse.
        version_type: The version type to use in conversion.

    Returns:
        The newly parsed [`VersionSet`][versions.version_sets.VersionSet].
    """
    return VersionSetParser(SpecifierParser(VersionParser(version_type))).parse(string)