Skip to content

sob.version

Version

Version(
    version_string: str | None = None,
    specification: str = "",
    compatible_with: (
        collections.abc.Sequence[
            str | int | float | decimal.Decimal
        ]
        | None
    ) = None,
    equals: (
        collections.abc.Sequence[
            str | int | float | decimal.Decimal
        ]
        | None
    ) = None,
    exactly_equals: (
        collections.abc.Sequence[
            str | int | float | decimal.Decimal
        ]
        | None
    ) = None,
    not_equals: (
        collections.abc.Sequence[
            str | int | float | decimal.Decimal
        ]
        | None
    ) = None,
    less_than: (
        collections.abc.Sequence[
            str | int | float | decimal.Decimal
        ]
        | None
    ) = None,
    less_than_or_equal_to: (
        collections.abc.Sequence[
            str | int | float | decimal.Decimal
        ]
        | None
    ) = None,
    greater_than: (
        collections.abc.Sequence[
            str | int | float | decimal.Decimal
        ]
        | None
    ) = None,
    greater_than_or_equal_to: (
        collections.abc.Sequence[
            str | int | float | decimal.Decimal
        ]
        | None
    ) = None,
)

Bases: sob.abc.Version

Instances of this class represent specification version compatibility.

An instance of sob.Version can be initialized from a version string formatted similarly to python package dependency specifiers as documented in PEP-440, but instead of representing package version compatibility, it represents compatibility with a specification version.

Attributes:

  • specification

    A specification name/identifier. This can be any string, so long as the same string is used when representing versions in property metadata as when applying the version using sob.version_model.

  • compatible_with

    A sequence of version numbers for which comparisons should be evaluated as described for ~= in PEP-440.

  • equals

    A sequence of version numbers for which comparisons should be evaluated as described for == in PEP-440.

  • exactly_equals

    A sequence of version numbers for which comparisons should be evaluated as described for === in PEP-440.

  • not_equals

    A sequence of version numbers for which comparisons should be evaluated as described for != in PEP-440.

  • less_than

    A sequence of version numbers for which comparisons should be evaluated as described for < in PEP-440.

  • less_than_or_equal_to

    A sequence of version numbers for which comparisons should be evaluated as described for <= in PEP-440.

  • greater_than

    A sequence of version numbers for which comparisons should be evaluated as described for > in PEP-440.

  • greater_than_or_equal_to

    A sequence of version numbers for which comparisons should be evaluated as described for >= in PEP-440.

Parameters:

  • version_string (str | None, default: None ) –

    A version string formatted similarly to python package dependency specifiers as documented in PEP-440.

  • specification (str, default: '' ) –

    A specification name/identifier. This can be any string, so long as the same string is used when representing versions in property metadata as when applying the version using sob.version_model.

  • compatible_with (collections.abc.Sequence[str | int | float | decimal.Decimal] | None, default: None ) –

    A sequence of version numbers for which comparisons should be evaluated as described for ~= in PEP-440.

  • equals (collections.abc.Sequence[str | int | float | decimal.Decimal] | None, default: None ) –

    A sequence of version numbers for which comparisons should be evaluated as described for == in PEP-440.

  • exactly_equals (collections.abc.Sequence[str | int | float | decimal.Decimal] | None, default: None ) –

    A sequence of version numbers for which comparisons should be evaluated as described for === in PEP-440.

  • not_equals (collections.abc.Sequence[str | int | float | decimal.Decimal] | None, default: None ) –

    A sequence of version numbers for which comparisons should be evaluated as described for != in PEP-440.

  • less_than (collections.abc.Sequence[str | int | float | decimal.Decimal] | None, default: None ) –

    A sequence of version numbers for which comparisons should be evaluated as described for < in PEP-440.

  • less_than_or_equal_to (collections.abc.Sequence[str | int | float | decimal.Decimal] | None, default: None ) –

    A sequence of version numbers for which comparisons should be evaluated as described for <= in PEP-440.

  • greater_than (collections.abc.Sequence[str | int | float | decimal.Decimal] | None, default: None ) –

    A sequence of version numbers for which comparisons should be evaluated as described for > in PEP-440.

  • greater_than_or_equal_to (collections.abc.Sequence[str | int | float | decimal.Decimal] | None, default: None ) –

    A sequence of version numbers for which comparisons should be evaluated as described for >= in PEP-440.

Source code in sob/version.py
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
def __init__(
    self,
    version_string: str | None = None,
    specification: str = "",
    compatible_with: Sequence[str | int | float | Decimal] | None = None,
    equals: Sequence[str | int | float | Decimal] | None = None,
    exactly_equals: Sequence[str | int | float | Decimal] | None = None,
    not_equals: Sequence[str | int | float | Decimal] | None = None,
    less_than: Sequence[str | int | float | Decimal] | None = None,
    less_than_or_equal_to: Sequence[str | int | float | Decimal]
    | None = None,
    greater_than: Sequence[str | int | float | Decimal] | None = None,
    greater_than_or_equal_to: Sequence[str | int | float | Decimal]
    | None = None,
) -> None:
    """
    Parameters:
        version_string: A version string formatted similarly to python
            package dependency specifiers as documented in
            [PEP-440](https://www.python.org/dev/peps/pep-0440).
        specification: A specification name/identifier. This can be any
            string, so long as the same string is used when representing
            versions in property metadata as when applying the version
            using `sob.version_model`.
        compatible_with: A sequence of version numbers for which
            comparisons should be evaluated as described for `~=` in
            [PEP-440](https://www.python.org/dev/peps/pep-0440).
        equals: A sequence of version numbers for which comparisons
            should be evaluated as described for `==` in
            [PEP-440](https://www.python.org/dev/peps/pep-0440).
        exactly_equals: A sequence of version numbers for which comparisons
            should be evaluated as described for `===` in
            [PEP-440](https://www.python.org/dev/peps/pep-0440).
        not_equals: A sequence of version numbers for which comparisons
            should be evaluated as described for `!=` in
            [PEP-440](https://www.python.org/dev/peps/pep-0440).
        less_than: A sequence of version numbers for which comparisons
            should be evaluated as described for `<` in
            [PEP-440](https://www.python.org/dev/peps/pep-0440).
        less_than_or_equal_to: A sequence of version numbers for which
            comparisons should be evaluated as described for `<=` in
            [PEP-440](https://www.python.org/dev/peps/pep-0440).
        greater_than: A sequence of version numbers for which
            comparisons should be evaluated as described for `>` in
            [PEP-440](https://www.python.org/dev/peps/pep-0440).
        greater_than_or_equal_to:  A sequence of version numbers for which
            comparisons should be evaluated as described for `>=` in
            [PEP-440](https://www.python.org/dev/peps/pep-0440).
    """
    self.specification = specification
    self.compatible_with = compatible_with
    self.exactly_equals = exactly_equals
    self.equals = equals
    self.not_equals = not_equals
    self.less_than = less_than
    self.less_than_or_equal_to = less_than_or_equal_to
    self.greater_than = greater_than
    self.greater_than_or_equal_to = greater_than_or_equal_to
    if version_string is not None:
        if not isinstance(version_string, str):
            raise TypeError(version_string)
        self._update_version_parameters_from_string(version_string)