diff --git a/.github/workflows/flake8_py_version_check.yml b/.github/workflows/flake8_py_version_check.yml new file mode 100644 index 0000000..de0d248 --- /dev/null +++ b/.github/workflows/flake8_py_version_check.yml @@ -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 diff --git a/scripts/flake8_py_version_check.py b/scripts/flake8_py_version_check.py new file mode 100644 index 0000000..2fd0e9a --- /dev/null +++ b/scripts/flake8_py_version_check.py @@ -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()