Skip to content

Commit

Permalink
Merge pull request #6 from tjquillan/pep440_fix
Browse files Browse the repository at this point in the history
Fix PEP440 Exceptions
  • Loading branch information
tjquillan authored Sep 25, 2024
2 parents 28dae35 + c667d4e commit 94884b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
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

0 comments on commit 94884b9

Please sign in to comment.