Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PEP440 Exceptions #6

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
- os: Ubuntu
image: ubuntu-latest
- os: Windows
image: windows-2022
image: windows-latest
- os: macOS
image: macos-11
image: macos-latest
fail-fast: false
defaults:
run:
Expand Down
19 changes: 8 additions & 11 deletions poetry_plugin_pyenv/pyenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,7 @@


if TYPE_CHECKING:
from re import Match
from re import Pattern
from subprocess import CompletedProcess
from typing import Iterator


# See: https://regex101.com/r/Bz2g17/1
PYTHON_VERSION_REGEX: Pattern[str] = re.compile(
r"^\s*(\d+\S*)\s*$", re.IGNORECASE | re.MULTILINE
)


def is_installed(version: Version) -> bool:
Expand Down Expand Up @@ -59,5 +50,11 @@ def get_remote_versions() -> list[Version]:
["pyenv", "install", "--list"], check=True, capture_output=True
)
output: str = result.stdout.decode("utf-8")
matched_versions: Iterator[Match[str]] = re.finditer(PYTHON_VERSION_REGEX, output)
return [Version.parse(v.group(1)) for v in matched_versions]

versions: list[Version] = []
for line in output.splitlines():
try:
versions.append(Version.parse(line.strip()))
except:
pass
return versions
Loading