-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔀 Merge pull request #6 from ThatXliner/requires-python
✨ Second implementation of respecting Python version
- Loading branch information
Showing
10 changed files
with
155 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"""Resolve Python versions.""" | ||
|
||
from __future__ import annotations | ||
|
||
import findpython # type: ignore[import] | ||
from packaging.specifiers import SpecifierSet | ||
|
||
|
||
def get_python(version: str) -> findpython.PythonVersion | None: | ||
"""Resolve the version string.""" | ||
# Order from latest version to earliest | ||
pythons = {python.version: python for python in findpython.find_all()} | ||
target = SpecifierSet(version) | ||
for python_version, python in pythons.items(): | ||
if python_version in target: | ||
return python | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env idae | ||
# /// pyproject | ||
# [run] | ||
# requires-python = ">=69420" | ||
# dependencies = [ | ||
# "requests<3", | ||
# "rich", | ||
# ] | ||
# /// | ||
|
||
import requests | ||
from rich.pretty import pprint | ||
|
||
resp = requests.get("https://peps.python.org/api/peps.json") # noqa: | ||
data = resp.json() | ||
pprint([(k, v["title"]) for k, v in data.items()][:10]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters