Skip to content

Commit

Permalink
add flake8 python version check script and CI check (#431)
Browse files Browse the repository at this point in the history
* add flake8 python version check script and CI check

* fix black violations

* fixes from PR review

* set up latest python
  • Loading branch information
r-downing authored Nov 30, 2023
1 parent eef0ee7 commit 09f44c3
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/flake8_py_version_check.yml
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
31 changes: 31 additions & 0 deletions scripts/flake8_py_version_check.py
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()

0 comments on commit 09f44c3

Please sign in to comment.