How to use the poetry.semver.version.Version function in poetry

To help you get started, we’ve selected a few poetry examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-poetry / poetry / poetry / semver / version.py View on Github external
def next_patch(self):  # type: () -> Version
        if self.is_prerelease():
            return Version(self.major, self.minor, self.patch)

        return self._increment_patch()
github python-poetry / poetry / poetry / semver / __init__.py View on Github external
m = TILDE_PEP440_CONSTRAINT.match(constraint)
    if m:
        precision = 1
        if m.group(3):
            precision += 1

            if m.group(4):
                precision += 1

        version = Version.parse(m.group(1))

        if precision == 2:
            low = version
            high = version.stable.next_major
        else:
            low = Version(version.major, version.minor, version.patch)
            high = version.stable.next_minor

        return VersionRange(
            low, high, include_min=True, always_include_max_prerelease=True
        )

    # Caret range
    m = CARET_CONSTRAINT.match(constraint)
    if m:
        version = Version.parse(m.group(1))

        return VersionRange(
            version,
            version.next_breaking,
            include_min=True,
            always_include_max_prerelease=True,
github python-poetry / poetry / poetry / semver / version.py View on Github external
def next_minor(self):  # type: () -> Version
        if self.is_prerelease() and self.patch == 0:
            return Version(self.major, self.minor, self.patch)

        return self._increment_minor()
github python-poetry / poetry / poetry / semver / version_range.py View on Github external
def allows_any(self, other):  # type: (VersionConstraint) -> bool
        from .version import Version

        if other.is_empty():
            return False

        if isinstance(other, Version):
            return self.allows(other)

        if isinstance(other, VersionUnion):
            return any([self.allows_any(constraint) for constraint in other.ranges])

        if isinstance(other, VersionRange):
            return not other.is_strictly_lower(self) and not other.is_strictly_higher(
                self
            )

        raise ValueError("Unknown VersionConstraint type {}.".format(other))
github python-poetry / poetry / poetry / semver / version.py View on Github external
def _increment_patch(self):  # type: () -> Version
        return Version(
            self.major, self.minor, self.patch + 1, precision=self._precision
        )
github python-poetry / poetry / poetry / semver / version.py View on Github external
def _increment_major(self):  # type: () -> Version
        return Version(self.major + 1, 0, 0, precision=self._precision)
github python-poetry / poetry / poetry / semver / version.py View on Github external
def next_major(self):  # type: () -> Version
        if self.is_prerelease() and self.minor == 0 and self.patch == 0:
            return Version(self.major, self.minor, self.patch)

        return self._increment_major()
github python-poetry / poetry / poetry / semver / version.py View on Github external
def _increment_minor(self):  # type: () -> Version
        return Version(self.major, self.minor + 1, 0, precision=self._precision)
github python-poetry / poetry / poetry / utils / env.py View on Github external
return venv

                    if current_env["minor"] == venv_minor:
                        del envs[base_env_name]
                        envs_file.write(envs)

                    self.remove_venv(str(venv.path))

                    return venv

            raise ValueError(
                'Environment "{}" does not exist.'.format(python)
            )

        try:
            python_version = Version.parse(python)
            python = "python{}".format(python_version.major)
            if python_version.precision > 1:
                python += ".{}".format(python_version.minor)
        except ValueError:
            # Executable in PATH or full executable path
            pass

        try:
            python_version = decode(
                subprocess.check_output(
                    list_to_shell_command(
                        [
                            python,
                            "-c",
                            "\"import sys; print('.'.join([str(s) for s in sys.version_info[:3]]))\"",
                        ]
github python-poetry / poetry / poetry / semver / __init__.py View on Github external
op = m.group(1)
        major = int(m.group(2))
        minor = m.group(3)

        if minor is not None:
            version = Version(major, int(minor), 0)

            result = VersionRange(
                version,
                version.next_minor,
                include_min=True,
                always_include_max_prerelease=True,
            )
        else:
            if major == 0:
                result = VersionRange(max=Version(1, 0, 0))
            else:
                version = Version(major, 0, 0)

                result = VersionRange(
                    version,
                    version.next_major,
                    include_min=True,
                    always_include_max_prerelease=True,
                )

        if op == "!=":
            result = VersionRange().difference(result)

        return result

    # Basic comparator