-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add flake8 python version check script and CI check (#431)
* add flake8 python version check script and CI check * fix black violations * fixes from PR review * set up latest python
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: flake8_py_version_check | ||
on: | ||
workflow_dispatch: {} | ||
schedule: | ||
# every Sunday at midnight | ||
- cron: "0 0 * * 0" | ||
jobs: | ||
check-versions: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.12 | ||
allow-prereleases: true | ||
- name: run script | ||
run: python scripts/flake8_py_version_check.py |
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,31 @@ | ||
import json | ||
import subprocess | ||
import tomllib | ||
|
||
|
||
def main(): | ||
with open("pyproject.toml", "rb") as fp: | ||
toml_data = tomllib.load(fp) | ||
flake8_bugbear_requires = toml_data["project"]["requires-python"] | ||
|
||
# get pypi data for flake8 as json | ||
curl_output = subprocess.getoutput( | ||
"curl -L -s --header 'Accept: application/vnd.pypi.simple.latest+json'" | ||
" https://pypi.org/simple/flake8" | ||
) | ||
flake8_pypi_data = json.loads(curl_output) | ||
|
||
# find latest non-yanked flake8 file data | ||
latest_file_data = next( | ||
file for file in reversed(flake8_pypi_data["files"]) if not file["yanked"] | ||
) | ||
flake8_requires = latest_file_data["requires-python"] | ||
|
||
assert flake8_requires == flake8_bugbear_requires, ( | ||
f"python version requirements don't match: ({flake8_requires=} !=" | ||
f" {flake8_bugbear_requires=})" | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |