diff --git a/.bumpversion.cfg b/.bumpversion.cfg index dc409b8..68d6abb 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -5,8 +5,13 @@ tag = True [bumpversion:file:repo_helper.yml] -[bumpversion:file:__pkginfo__.py] - [bumpversion:file:README.rst] [bumpversion:file:flake8_github_actions/__init__.py] + +search = : str = "{current_version}" +replace = : str = "{new_version}" + +[bumpversion:file:pyproject.toml] +search = version = "{current_version}" +replace = version = "{new_version}" diff --git a/.dependabot/config.yml b/.dependabot/config.yml deleted file mode 100644 index 4584924..0000000 --- a/.dependabot/config.yml +++ /dev/null @@ -1,9 +0,0 @@ -# This file is managed by 'repo_helper'. Don't edit it directly. ---- -version: 1 -update_configs: -- package_manager: python - directory: / - update_schedule: weekly - default_reviewers: - - domdfcoding diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 68a2fcb..5551752 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -17,7 +17,10 @@ THE ISSUE WILL BE CLOSED IF INSUFFICIENT INFORMATION IS PROVIDED. ## Steps to Reproduce - + 1. 2. @@ -41,7 +44,7 @@ THE ISSUE WILL BE CLOSED IF INSUFFICIENT INFORMATION IS PROVIDED. * flake8-github-actions: ## Installation source - + ## Other Additional Information: diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e769ad3..454225a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,5 +6,6 @@ updates: directory: / schedule: interval: weekly + open-pull-requests-limit: 0 reviewers: - domdfcoding diff --git a/.github/milestones.py b/.github/milestones.py new file mode 100755 index 0000000..5e868dc --- /dev/null +++ b/.github/milestones.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +# stdlib +import os +import sys + +# 3rd party +from github3 import GitHub +from github3.repos import Repository +from packaging.version import InvalidVersion, Version + +latest_tag = os.environ["GITHUB_REF_NAME"] + +try: + current_version = Version(latest_tag) +except InvalidVersion: + sys.exit() + +gh: GitHub = GitHub(token=os.environ["GITHUB_TOKEN"]) +repo: Repository = gh.repository(*os.environ["GITHUB_REPOSITORY"].split('/', 1)) + +for milestone in repo.milestones(state="open"): + try: + milestone_version = Version(milestone.title) + except InvalidVersion: + continue + if milestone_version == current_version: + sys.exit(not milestone.update(state="closed")) diff --git a/.github/stale.yml b/.github/stale.yml index bb7ca3f..bb7fa62 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -7,7 +7,7 @@ daysUntilStale: 180 # Number of days of inactivity before an Issue or Pull Request with the stale label is closed. # Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale. -daysUntilClose: 180 +daysUntilClose: false # Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled) onlyLabels: [] @@ -28,13 +28,13 @@ exemptMilestones: false exemptAssignees: false # Label to use when marking as stale -staleLabel: wontfix +staleLabel: stale # Comment to post when marking as stale. Set to `false` to disable -markComment: > - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. Thank you - for your contributions. +markComment: false +# This issue has been automatically marked as stale because it has not had +# recent activity. It will be closed if no further activity occurs. Thank you +# for your contributions. # Comment to post when removing the stale label. # unmarkComment: > diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml deleted file mode 100644 index 741c0bd..0000000 --- a/.github/workflows/cleanup.yml +++ /dev/null @@ -1,14 +0,0 @@ -# This file is managed by 'repo_helper'. Don't edit it directly. ---- -name: Artefact Cleaner -on: - schedule: - - cron: 0 9 1 * * -jobs: - Clean: - runs-on: ubuntu-latest - steps: - - name: cleanup - uses: glassechidna/artifact-cleaner@v2 - with: - minimumAge: 1000000.0 diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml index 177294b..8296b42 100644 --- a/.github/workflows/flake8.yml +++ b/.github/workflows/flake8.yml @@ -4,29 +4,46 @@ name: Flake8 on: push: + branches-ignore: + - 'repo-helper-update' + - 'pre-commit-ci-update-config' + - 'imgbot' pull_request: - branches: ["master"] jobs: Run: name: "Flake8" - runs-on: "ubuntu-18.04" + permissions: + contents: read + runs-on: "ubuntu-22.04" steps: - name: Checkout 🛎️ - uses: "actions/checkout@v2" + uses: "actions/checkout@v6" + + - name: Check for changed files + uses: dorny/paths-filter@v2 + id: changes + with: + list-files: "json" + filters: | + code: + - '!(doc-source/**|CONTRIBUTING.rst|.imgbotconfig|.pre-commit-config.yaml|.pylintrc|.readthedocs.yml)' - name: Setup Python 🐍 - uses: "actions/setup-python@v2" + if: steps.changes.outputs.code == 'true' + uses: "actions/setup-python@v6" with: - python-version: "3.8" + python-version: "3.9" - name: Install dependencies 🔧 + if: steps.changes.outputs.code == 'true' run: | python -VV python -m site python -m pip install --upgrade pip setuptools wheel - python -m pip install tox + python -m pip install tox~=3.0 - name: "Run Flake8" - run: "python -m tox -e lint -- --format github" + if: steps.changes.outputs.code == 'true' + run: "python -m tox -e lint -s false -- --format github" diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index afee01e..4b27c5d 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -4,34 +4,50 @@ name: mypy on: push: + branches-ignore: + - 'repo-helper-update' + - 'pre-commit-ci-update-config' + - 'imgbot' pull_request: - branches: ["master"] jobs: Run: + permissions: + contents: read name: "mypy / ${{ matrix.os }}" runs-on: ${{ matrix.os }} strategy: matrix: - os: ['windows-2019', 'macos-latest', 'ubuntu-20.04'] + os: ['ubuntu-22.04', 'windows-2022'] fail-fast: false steps: - name: Checkout 🛎️ - uses: "actions/checkout@v2" + uses: "actions/checkout@v6" + + - name: Check for changed files + uses: dorny/paths-filter@v2 + id: changes + with: + list-files: "json" + filters: | + code: + - '!(doc-source/**|CONTRIBUTING.rst|.imgbotconfig|.pre-commit-config.yaml|.pylintrc|.readthedocs.yml)' - name: Setup Python 🐍 - uses: "actions/setup-python@v2" + if: steps.changes.outputs.code == 'true' + uses: "actions/setup-python@v6" with: - python-version: "3.6" + python-version: "3.9" - name: Install dependencies 🔧 run: | python -VV python -m site python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade tox virtualenv + python -m pip install --upgrade tox~=3.0 virtualenv!=20.16.0 - name: "Run mypy" - run: "python -m tox -e mypy" + if: steps.changes.outputs.code == 'true' + run: "python -m tox -e mypy -s false" diff --git a/.github/workflows/octocheese.yml b/.github/workflows/octocheese.yml index 155d407..bdb7c2c 100644 --- a/.github/workflows/octocheese.yml +++ b/.github/workflows/octocheese.yml @@ -3,13 +3,13 @@ name: "GitHub Releases" on: - push: - branches: ["master"] schedule: - - cron: 0 12 * * 2,4,6 + - cron: 0 12 * * * jobs: Run: + permissions: + contents: write runs-on: ubuntu-latest steps: - uses: domdfcoding/octocheese@master diff --git a/.github/workflows/python_ci.yml b/.github/workflows/python_ci.yml index 841c930..989b421 100644 --- a/.github/workflows/python_ci.yml +++ b/.github/workflows/python_ci.yml @@ -4,43 +4,76 @@ name: Windows on: push: + branches-ignore: + - 'repo-helper-update' + - 'pre-commit-ci-update-config' + - 'imgbot' + pull_request: - branches: ["master"] jobs: tests: - name: "windows-2019 / Python ${{ matrix.config.python-version }}" - runs-on: "windows-2019" + permissions: + actions: write + contents: read + name: "windows-2022 / Python ${{ matrix.config.python-version }}" + runs-on: "windows-2022" continue-on-error: ${{ matrix.config.experimental }} env: - USING_COVERAGE: '3.6,3.7,3.8,3.9,3.10.0-alpha.5,pypy-3.6' + USING_COVERAGE: '3.7,3.8,3.9,3.10,3.11,3.12,3.13,pypy-3.7,pypy-3.8,pypy-3.9' strategy: fail-fast: False matrix: config: - - {python-version: "3.6", testenvs: "py36,build", experimental: False} - - {python-version: "3.7", testenvs: "py37,build", experimental: False} - - {python-version: "3.8", testenvs: "py38,build", experimental: False} - - {python-version: "3.9", testenvs: "py39,build", experimental: False} - - {python-version: "3.10.0-alpha.5", testenvs: "py310-dev,build", experimental: True} - - {python-version: "pypy-3.6", testenvs: "pypy3,build", experimental: False} + - {python-version: "3.7", testenvs: "py37-flake8{4,5},build", experimental: False} + - {python-version: "3.8", testenvs: "py38-flake8{4,5,6,7},build", experimental: False} + - {python-version: "3.9", testenvs: "py39-flake8{4,5,6,7},build", experimental: False} + - {python-version: "3.10", testenvs: "py310-flake8{4,5,6,7},build", experimental: False} + - {python-version: "3.11", testenvs: "py311-flake8{4,5,6,7},build", experimental: False} + - {python-version: "3.12", testenvs: "py312-flake8{6,7},build", experimental: False} + - {python-version: "3.13", testenvs: "py313-flake8{6,7},build", experimental: False} + - {python-version: "pypy-3.7", testenvs: "pypy37-flake8{4,5},build", experimental: False} + - {python-version: "pypy-3.8", testenvs: "pypy38-flake8{4,5,6,7}", experimental: False} + - {python-version: "pypy-3.9-v7.3.16", testenvs: "pypy39-flake8{4,5,6,7}", experimental: True} steps: - name: Checkout 🛎️ - uses: "actions/checkout@v2" + uses: "actions/checkout@v6" + + - name: Check for changed files + if: startsWith(github.ref, 'refs/tags/') != true + uses: dorny/paths-filter@v2 + id: changes + with: + list-files: "json" + filters: | + code: + - '!(doc-source/**|CONTRIBUTING.rst|.imgbotconfig|.pre-commit-config.yaml|.pylintrc|.readthedocs.yml)' - name: Setup Python 🐍 - uses: "actions/setup-python@v2" + id: setup-python + if: ${{ steps.changes.outputs.code == 'true' || steps.changes.outcome == 'skipped' }} + uses: "actions/setup-python@v6" with: python-version: "${{ matrix.config.python-version }}" - name: Install dependencies 🔧 + if: steps.setup-python.outcome == 'success' run: | python -VV python -m site python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade tox virtualenv + python -m pip install --upgrade tox~=3.0 virtualenv!=20.16.0 - name: "Run Tests for Python ${{ matrix.config.python-version }}" - run: python -m tox -e "${{ matrix.config.testenvs }}" + if: steps.setup-python.outcome == 'success' + run: python -m tox -e "${{ matrix.config.testenvs }}" -s false + + - name: "Upload Coverage 🚀" + uses: actions/upload-artifact@v4 + if: ${{ always() && steps.setup-python.outcome == 'success' }} + with: + name: "coverage-${{ matrix.config.python-version }}" + path: .coverage + include-hidden-files: true diff --git a/.github/workflows/python_ci_linux.yml b/.github/workflows/python_ci_linux.yml index 212ca69..754c733 100644 --- a/.github/workflows/python_ci_linux.yml +++ b/.github/workflows/python_ci_linux.yml @@ -4,80 +4,177 @@ name: Linux on: push: + branches-ignore: + - 'repo-helper-update' + - 'pre-commit-ci-update-config' + - 'imgbot' + tags: + - '*' pull_request: - branches: ["master"] jobs: tests: - name: "ubuntu-20.04 / Python ${{ matrix.config.python-version }}" - runs-on: "ubuntu-20.04" + permissions: + actions: write + contents: read + name: "ubuntu-22.04 / Python ${{ matrix.config.python-version }}" + runs-on: "ubuntu-22.04" continue-on-error: ${{ matrix.config.experimental }} env: - USING_COVERAGE: '3.6,3.7,3.8,3.9,3.10.0-alpha.5,pypy-3.6' + USING_COVERAGE: '3.7,3.8,3.9,3.10,3.11,3.12,3.13,pypy-3.7,pypy-3.8,pypy-3.9' strategy: fail-fast: False matrix: config: - - {python-version: "3.6", testenvs: "py36,build", experimental: False} - - {python-version: "3.7", testenvs: "py37,build", experimental: False} - - {python-version: "3.8", testenvs: "py38,build", experimental: False} - - {python-version: "3.9", testenvs: "py39,build", experimental: False} - - {python-version: "3.10.0-alpha.5", testenvs: "py310-dev,build", experimental: True} - - {python-version: "pypy-3.6", testenvs: "pypy3,build", experimental: False} + - {python-version: "3.7", testenvs: "py37-flake8{4,5},build", experimental: False} + - {python-version: "3.8", testenvs: "py38-flake8{4,5,6,7},build", experimental: False} + - {python-version: "3.9", testenvs: "py39-flake8{4,5,6,7},build", experimental: False} + - {python-version: "3.10", testenvs: "py310-flake8{4,5,6,7},build", experimental: False} + - {python-version: "3.11", testenvs: "py311-flake8{4,5,6,7},build", experimental: False} + - {python-version: "3.12", testenvs: "py312-flake8{6,7},build", experimental: False} + - {python-version: "3.13", testenvs: "py313-flake8{6,7},build", experimental: False} + - {python-version: "pypy-3.7", testenvs: "pypy37-flake8{4,5},build", experimental: False} + - {python-version: "pypy-3.8", testenvs: "pypy38-flake8{4,5,6,7},build", experimental: False} + - {python-version: "pypy-3.9", testenvs: "pypy39-flake8{4,5,6,7}", experimental: True} steps: - name: Checkout 🛎️ - uses: "actions/checkout@v2" + uses: "actions/checkout@v6" + + - name: Check for changed files + if: startsWith(github.ref, 'refs/tags/') != true + uses: dorny/paths-filter@v2 + id: changes + with: + list-files: "json" + filters: | + code: + - '!(doc-source/**|CONTRIBUTING.rst|.imgbotconfig|.pre-commit-config.yaml|.pylintrc|.readthedocs.yml)' - name: Setup Python 🐍 - uses: "actions/setup-python@v2" + id: setup-python + if: ${{ steps.changes.outputs.code == 'true' || steps.changes.outcome == 'skipped' }} + uses: "actions/setup-python@v6" with: python-version: "${{ matrix.config.python-version }}" - name: Install dependencies 🔧 + if: steps.setup-python.outcome == 'success' run: | python -VV python -m site python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade tox virtualenv + python -m pip install --upgrade tox~=3.0 virtualenv!=20.16.0 + python -m pip install --upgrade coverage_pyver_pragma - name: "Run Tests for Python ${{ matrix.config.python-version }}" - run: python -m tox -e "${{ matrix.config.testenvs }}" + if: steps.setup-python.outcome == 'success' + run: python -m tox -e "${{ matrix.config.testenvs }}" -s false + - name: "Upload Coverage 🚀" + uses: actions/upload-artifact@v4 + if: ${{ always() && steps.setup-python.outcome == 'success' }} + with: + name: "coverage-${{ matrix.config.python-version }}" + path: .coverage + include-hidden-files: true - Deploy: + Coverage: needs: tests + permissions: + actions: write + contents: read + runs-on: "ubuntu-22.04" + steps: + - name: Checkout 🛎️ + uses: "actions/checkout@v6" + + - name: Setup Python 🐍 + uses: "actions/setup-python@v6" + with: + python-version: 3.8 + + - name: Install dependencies 🔧 + run: | + python -m pip install --upgrade pip setuptools wheel + python -m pip install --upgrade "coveralls>=3.0.0" coverage_pyver_pragma + + - name: "Download Coverage 🪂" + uses: actions/download-artifact@v4 + with: + path: coverage + + - name: Display structure of downloaded files + id: show + run: ls -R + working-directory: coverage + continue-on-error: true - runs-on: "ubuntu-20.04" + - name: Combine Coverage 👷 + if: ${{ steps.show.outcome != 'failure' }} + run: | + shopt -s globstar + python -m coverage combine coverage/**/.coverage + + - name: "Upload Combined Coverage Artefact 🚀" + if: ${{ steps.show.outcome != 'failure' }} + uses: actions/upload-artifact@v4 + with: + name: "combined-coverage" + path: .coverage + include-hidden-files: true + + - name: "Upload Combined Coverage to Coveralls" + if: ${{ steps.show.outcome != 'failure' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + coveralls --service=github + + Deploy: + needs: tests + permissions: + actions: write + issues: write + contents: read + runs-on: "ubuntu-22.04" steps: - name: Checkout 🛎️ - uses: "actions/checkout@v2" + uses: "actions/checkout@v6" if: startsWith(github.ref, 'refs/tags/') - name: Setup Python 🐍 - uses: "actions/setup-python@v2" + uses: "actions/setup-python@v6" + if: startsWith(github.ref, 'refs/tags/') with: python-version: 3.8 - if: startsWith(github.ref, 'refs/tags/') - name: Install dependencies 🔧 + if: startsWith(github.ref, 'refs/tags/') run: | python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade tox - if: startsWith(github.ref, 'refs/tags/') + python -m pip install --upgrade tox~=3.0 - name: Build distributions 📦 + if: startsWith(github.ref, 'refs/tags/') run: | tox -e build - if: startsWith(github.ref, 'refs/tags/') - name: Upload distribution to PyPI 🚀 if: startsWith(github.ref, 'refs/tags/') - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@v1.13.0 with: user: __token__ password: ${{ secrets.PYPI_TOKEN }} - skip_existing: true + skip-existing: true + + - name: Close milestone 🚪 + if: startsWith(github.ref, 'refs/tags/') + run: | + python -m pip install --upgrade github3.py packaging + python .github/milestones.py + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/python_ci_macos.yml b/.github/workflows/python_ci_macos.yml index de589e6..b3ee7f2 100644 --- a/.github/workflows/python_ci_macos.yml +++ b/.github/workflows/python_ci_macos.yml @@ -4,43 +4,76 @@ name: macOS on: push: + branches-ignore: + - 'repo-helper-update' + - 'pre-commit-ci-update-config' + - 'imgbot' + pull_request: - branches: ["master"] jobs: tests: - name: "macos-latest / Python ${{ matrix.config.python-version }}" - runs-on: "macos-latest" + permissions: + actions: write + contents: read + name: "macos-${{ matrix.config.os-ver }} / Python ${{ matrix.config.python-version }}" + runs-on: "macos-${{ matrix.config.os-ver }}" continue-on-error: ${{ matrix.config.experimental }} env: - USING_COVERAGE: '3.6,3.7,3.8,3.9,3.10.0-alpha.5,pypy-3.6' + USING_COVERAGE: '3.7,3.8,3.9,3.10,3.11,3.12,3.13,pypy-3.7,pypy-3.8,pypy-3.9' strategy: fail-fast: False matrix: config: - - {python-version: "3.6", testenvs: "py36,build", experimental: False} - - {python-version: "3.7", testenvs: "py37,build", experimental: False} - - {python-version: "3.8", testenvs: "py38,build", experimental: False} - - {python-version: "3.9", testenvs: "py39,build", experimental: False} - - {python-version: "3.10.0-alpha.5", testenvs: "py310-dev,build", experimental: True} - - {python-version: "pypy-3.6", testenvs: "pypy3,build", experimental: False} + - {python-version: "3.7", os-ver: "15-intel", testenvs: "py37-flake8{4,5},build", experimental: False} + - {python-version: "3.8", os-ver: "14", testenvs: "py38-flake8{4,5,6,7},build", experimental: False} + - {python-version: "3.9", os-ver: "14", testenvs: "py39-flake8{4,5,6,7},build", experimental: False} + - {python-version: "3.10", os-ver: "14", testenvs: "py310-flake8{4,5,6,7},build", experimental: False} + - {python-version: "3.11", os-ver: "14", testenvs: "py311-flake8{4,5,6,7},build", experimental: False} + - {python-version: "3.12", os-ver: "14", testenvs: "py312-flake8{6,7},build", experimental: False} + - {python-version: "3.13", os-ver: "14", testenvs: "py313-flake8{6,7},build", experimental: False} + - {python-version: "pypy-3.7", os-ver: "15-intel", testenvs: "pypy37-flake8{4,5},build", experimental: False} + - {python-version: "pypy-3.8", os-ver: "14", testenvs: "pypy38-flake8{4,5,6,7},build", experimental: False} + - {python-version: "pypy-3.9", os-ver: "14", testenvs: "pypy39-flake8{4,5,6,7}", experimental: True} steps: - name: Checkout 🛎️ - uses: "actions/checkout@v2" + uses: "actions/checkout@v6" + + - name: Check for changed files + if: startsWith(github.ref, 'refs/tags/') != true + uses: dorny/paths-filter@v2 + id: changes + with: + list-files: "json" + filters: | + code: + - '!(doc-source/**|CONTRIBUTING.rst|.imgbotconfig|.pre-commit-config.yaml|.pylintrc|.readthedocs.yml)' - name: Setup Python 🐍 - uses: "actions/setup-python@v2" + id: setup-python + if: ${{ steps.changes.outputs.code == 'true' || steps.changes.outcome == 'skipped' }} + uses: "actions/setup-python@v6" with: python-version: "${{ matrix.config.python-version }}" - name: Install dependencies 🔧 + if: steps.setup-python.outcome == 'success' run: | python -VV python -m site python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade tox virtualenv + python -m pip install --upgrade tox~=3.0 virtualenv!=20.16.0 - name: "Run Tests for Python ${{ matrix.config.python-version }}" - run: python -m tox -e "${{ matrix.config.testenvs }}" + if: steps.setup-python.outcome == 'success' + run: python -m tox -e "${{ matrix.config.testenvs }}" -s false + + - name: "Upload Coverage 🚀" + uses: actions/upload-artifact@v4 + if: ${{ always() && steps.setup-python.outcome == 'success' }} + with: + name: "coverage-${{ matrix.config.python-version }}" + path: .coverage + include-hidden-files: true diff --git a/.gitignore b/.gitignore index 33998d0..8d01871 100644 --- a/.gitignore +++ b/.gitignore @@ -47,7 +47,6 @@ docs/_build/ doc/build target/ .ipynb_checkpoints -.python-version celerybeat-schedule celerybeat.pid *.sage.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 43a1b94..3c860bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,20 +1,27 @@ # This file is managed by 'repo_helper'. Don't edit it directly. --- -exclude: ^$ +exclude: ^tests/bad_code.py$ + +ci: + autoupdate_schedule: quarterly + skip: [taplo-lint] repos: + - repo: https://github.com/repo-helper/pyproject-parser + rev: v0.14.0 + hooks: + - id: reformat-pyproject + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.4.0 hooks: - id: check-added-large-files - id: check-ast - id: fix-byte-order-marker - - id: check-byte-order-marker - id: check-case-conflict - id: check-executables-have-shebangs - id: check-json - - id: check-toml - id: check-yaml - id: check-merge-conflict - id: check-symlinks @@ -24,37 +31,46 @@ repos: - id: mixed-line-ending - id: end-of-file-fixer + - repo: https://github.com/domdfcoding/taplo-pre-commit + rev: v0.10.0 + hooks: + - id: taplo-lint + args: [] + - repo: https://github.com/domdfcoding/pre-commit-hooks - rev: v0.2.0 + rev: v0.7.0 hooks: - id: requirements-txt-sorter args: - --allow-git - id: check-docstring-first - exclude: ^(doc-source/conf|__pkginfo__|make_conda_recipe|setup|tests/.*)\.py$ + exclude: ^(doc-source/conf|__pkginfo__|setup|tests/.*)\.py$ - id: bind-requirements + args: + - --python-min + - '3.7' - - repo: https://github.com/domdfcoding/flake8-dunder-all - rev: v0.1.5 + - repo: https://github.com/python-formate/flake8-dunder-all + rev: v0.5.0 hooks: - id: ensure-dunder-all files: ^flake8_github_actions/.*\.py$ - repo: https://github.com/domdfcoding/flake2lint - rev: v0.3.0 + rev: v0.4.3 hooks: - id: flake2lint - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.7.1 + rev: v1.10.0 hooks: - id: python-no-eval - id: rst-backticks - id: rst-directive-colons - id: rst-inline-touching-normal - - repo: https://github.com/asottile/pyupgrade - rev: v2.10.0 + - repo: https://github.com/python-formate/pyupgrade + rev: bbe3007 hooks: - id: pyupgrade args: @@ -62,19 +78,29 @@ repos: - --keep-runtime-typing - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.1.9 + rev: v1.5.1 hooks: - id: remove-crlf - id: forbid-crlf - - repo: https://github.com/repo-helper/formate - rev: v0.4.2 + - repo: https://github.com/python-formate/snippet-fmt + rev: v0.1.5 + hooks: + - id: snippet-fmt + + - repo: https://github.com/python-formate/formate + rev: v1.2.1 hooks: - id: formate - exclude: ^(doc-source/conf|__pkginfo__|make_conda_recipe|setup)\.(_)?py$ + exclude: ^(doc-source/conf|__pkginfo__|setup)\.(_)?py$ + additional_dependencies: + - formate-trailing-commas>=0.1.1 + types_or: + - python + - pyi - - repo: https://github.com/domdfcoding/dep_checker - rev: v0.4.1 + - repo: https://github.com/python-coincidence/dep_checker + rev: v0.9.0 hooks: - id: dep_checker args: diff --git a/.pylintrc b/.pylintrc index a21206a..81ecba0 100644 --- a/.pylintrc +++ b/.pylintrc @@ -66,7 +66,7 @@ confidence= # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" disable=all -enable=assert-on-tuple,astroid-error,bad-except-order,bad-inline-option,bad-option-value,bad-reversed-sequence,bare-except,binary-op-exception,boolean-datetime,catching-non-exception,cell-var-from-loop,confusing-with-statement,consider-merging-isinstance,consider-using-enumerate,consider-using-ternary,continue-in-finally,cyclic-import,deprecated-pragma,django-not-available,duplicate-except,duplicate-key,eval-used,exec-used,expression-not-assigned,fatal,file-ignored,fixme,global-at-module-level,global-statement,global-variable-not-assigned,global-variable-undefined,http-response-with-content-type-json,http-response-with-json-dumps,invalid-all-object,invalid-characters-in-docstring,len-as-condition,literal-comparison,locally-disabled,locally-enabled,lost-exception,lowercase-l-suffix,misplaced-bare-raise,missing-kwoa,mixed-line-endings,model-has-unicode,model-missing-unicode,model-no-explicit-unicode,model-unicode-not-callable,multiple-imports,new-db-field-with-default,non-ascii-bytes-literals,nonexistent-operator,not-in-loop,notimplemented-raised,overlapping-except,parse-error,pointless-statement,pointless-string-statement,raising-bad-type,raising-non-exception,raw-checker-failed,redefine-in-handler,redefined-argument-from-local,redefined-builtin,redundant-content-type-for-json-response,reimported,relative-import,return-outside-function,simplifiable-if-statement,singleton-comparison,syntax-error,trailing-comma-tuple,trailing-newlines,unbalanced-tuple-unpacking,undefined-all-variable,undefined-loop-variable,unexpected-line-ending-format,unidiomatic-typecheck,unnecessary-lambda,unnecessary-pass,unnecessary-semicolon,unneeded-not,unpacking-non-sequence,unreachable,unrecognized-inline-option,used-before-assignment,useless-else-on-loop,using-constant-test,wildcard-import,yield-outside-function,useless-return +enable=assert-on-tuple,astroid-error,bad-except-order,bad-inline-option,bad-option-value,bad-reversed-sequence,bare-except,binary-op-exception,boolean-datetime,catching-non-exception,cell-var-from-loop,confusing-with-statement,consider-merging-isinstance,consider-using-enumerate,consider-using-ternary,continue-in-finally,deprecated-pragma,django-not-available,duplicate-except,duplicate-key,eval-used,exec-used,expression-not-assigned,fatal,file-ignored,fixme,global-at-module-level,global-statement,global-variable-not-assigned,global-variable-undefined,http-response-with-content-type-json,http-response-with-json-dumps,invalid-all-object,invalid-characters-in-docstring,len-as-condition,literal-comparison,locally-disabled,locally-enabled,lost-exception,lowercase-l-suffix,misplaced-bare-raise,missing-kwoa,mixed-line-endings,model-has-unicode,model-missing-unicode,model-no-explicit-unicode,model-unicode-not-callable,multiple-imports,new-db-field-with-default,non-ascii-bytes-literals,nonexistent-operator,not-in-loop,notimplemented-raised,overlapping-except,parse-error,pointless-statement,pointless-string-statement,raising-bad-type,raising-non-exception,raw-checker-failed,redefine-in-handler,redefined-argument-from-local,redefined-builtin,redundant-content-type-for-json-response,reimported,relative-import,return-outside-function,simplifiable-if-statement,singleton-comparison,syntax-error,trailing-comma-tuple,trailing-newlines,unbalanced-tuple-unpacking,undefined-all-variable,undefined-loop-variable,unexpected-line-ending-format,unidiomatic-typecheck,unnecessary-lambda,unnecessary-pass,unnecessary-semicolon,unneeded-not,unpacking-non-sequence,unreachable,unrecognized-inline-option,used-before-assignment,useless-else-on-loop,using-constant-test,wildcard-import,yield-outside-function,useless-return [REPORTS] diff --git a/.style.yapf b/.style.yapf index e64be7c..9378f04 100644 --- a/.style.yapf +++ b/.style.yapf @@ -312,7 +312,7 @@ split_before_dict_set_generator=True # # foo = ('This is a really long string: {}, {}, {}, {}' # .format(a, b, c, d)) -split_before_dot=False +split_before_dot=True # Split after the opening paren which surrounds an expression if it doesn't # fit on a single line. diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 98e5ffa..81ce059 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -38,11 +38,11 @@ Automated tests ------------------- Tests are run with ``tox`` and ``pytest``. -To run tests for a specific Python version, such as Python 3.6: +To run tests for a specific Python version, such as Python 3.10: .. code-block:: bash - $ tox -e py36 + $ tox -e py310 To run tests for all Python versions, simply run: diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 51376c6..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -include __pkginfo__.py -include LICENSE -include requirements.txt -prune **/__pycache__ -recursive-include flake8_github_actions *.pyi -include flake8_github_actions/py.typed diff --git a/README.rst b/README.rst index cfff325..626ca0f 100644 --- a/README.rst +++ b/README.rst @@ -16,42 +16,46 @@ flake8-github-actions :widths: 10 90 * - Tests - - |actions_linux| |actions_windows| |actions_macos| + - |actions_linux| |actions_windows| |actions_macos| |coveralls| * - PyPI - |pypi-version| |supported-versions| |supported-implementations| |wheel| * - Activity - |commits-latest| |commits-since| |maintained| |pypi-downloads| * - QA - - |codefactor| |actions_flake8| |actions_mypy| |pre_commit_ci| + - |codefactor| |actions_flake8| |actions_mypy| * - Other - |license| |language| |requires| -.. |actions_linux| image:: https://github.com/domdfcoding/flake8-github-actions/workflows/Linux/badge.svg - :target: https://github.com/domdfcoding/flake8-github-actions/actions?query=workflow%3A%22Linux%22 +.. |actions_linux| image:: https://github.com/python-formate/flake8-github-actions/workflows/Linux/badge.svg + :target: https://github.com/python-formate/flake8-github-actions/actions?query=workflow%3A%22Linux%22 :alt: Linux Test Status -.. |actions_windows| image:: https://github.com/domdfcoding/flake8-github-actions/workflows/Windows/badge.svg - :target: https://github.com/domdfcoding/flake8-github-actions/actions?query=workflow%3A%22Windows%22 +.. |actions_windows| image:: https://github.com/python-formate/flake8-github-actions/workflows/Windows/badge.svg + :target: https://github.com/python-formate/flake8-github-actions/actions?query=workflow%3A%22Windows%22 :alt: Windows Test Status -.. |actions_macos| image:: https://github.com/domdfcoding/flake8-github-actions/workflows/macOS/badge.svg - :target: https://github.com/domdfcoding/flake8-github-actions/actions?query=workflow%3A%22macOS%22 +.. |actions_macos| image:: https://github.com/python-formate/flake8-github-actions/workflows/macOS/badge.svg + :target: https://github.com/python-formate/flake8-github-actions/actions?query=workflow%3A%22macOS%22 :alt: macOS Test Status -.. |actions_flake8| image:: https://github.com/domdfcoding/flake8-github-actions/workflows/Flake8/badge.svg - :target: https://github.com/domdfcoding/flake8-github-actions/actions?query=workflow%3A%22Flake8%22 +.. |actions_flake8| image:: https://github.com/python-formate/flake8-github-actions/workflows/Flake8/badge.svg + :target: https://github.com/python-formate/flake8-github-actions/actions?query=workflow%3A%22Flake8%22 :alt: Flake8 Status -.. |actions_mypy| image:: https://github.com/domdfcoding/flake8-github-actions/workflows/mypy/badge.svg - :target: https://github.com/domdfcoding/flake8-github-actions/actions?query=workflow%3A%22mypy%22 +.. |actions_mypy| image:: https://github.com/python-formate/flake8-github-actions/workflows/mypy/badge.svg + :target: https://github.com/python-formate/flake8-github-actions/actions?query=workflow%3A%22mypy%22 :alt: mypy status -.. |requires| image:: https://requires.io/github/domdfcoding/flake8-github-actions/requirements.svg?branch=master - :target: https://requires.io/github/domdfcoding/flake8-github-actions/requirements/?branch=master +.. |requires| image:: https://dependency-dash.repo-helper.uk/github/python-formate/flake8-github-actions/badge.svg + :target: https://dependency-dash.repo-helper.uk/github/python-formate/flake8-github-actions/ :alt: Requirements Status -.. |codefactor| image:: https://img.shields.io/codefactor/grade/github/domdfcoding/flake8-github-actions?logo=codefactor - :target: https://www.codefactor.io/repository/github/domdfcoding/flake8-github-actions +.. |coveralls| image:: https://img.shields.io/coveralls/github/python-formate/flake8-github-actions/master?logo=coveralls + :target: https://coveralls.io/github/python-formate/flake8-github-actions?branch=master + :alt: Coverage + +.. |codefactor| image:: https://img.shields.io/codefactor/grade/github/python-formate/flake8-github-actions?logo=codefactor + :target: https://www.codefactor.io/repository/github/python-formate/flake8-github-actions :alt: CodeFactor Grade .. |pypi-version| image:: https://img.shields.io/pypi/v/flake8-github-actions @@ -70,32 +74,28 @@ flake8-github-actions :target: https://pypi.org/project/flake8-github-actions/ :alt: PyPI - Wheel -.. |license| image:: https://img.shields.io/github/license/domdfcoding/flake8-github-actions - :target: https://github.com/domdfcoding/flake8-github-actions/blob/master/LICENSE +.. |license| image:: https://img.shields.io/github/license/python-formate/flake8-github-actions + :target: https://github.com/python-formate/flake8-github-actions/blob/master/LICENSE :alt: License -.. |language| image:: https://img.shields.io/github/languages/top/domdfcoding/flake8-github-actions +.. |language| image:: https://img.shields.io/github/languages/top/python-formate/flake8-github-actions :alt: GitHub top language -.. |commits-since| image:: https://img.shields.io/github/commits-since/domdfcoding/flake8-github-actions/v0.1.1 - :target: https://github.com/domdfcoding/flake8-github-actions/pulse +.. |commits-since| image:: https://img.shields.io/github/commits-since/python-formate/flake8-github-actions/v0.1.1 + :target: https://github.com/python-formate/flake8-github-actions/pulse :alt: GitHub commits since tagged version -.. |commits-latest| image:: https://img.shields.io/github/last-commit/domdfcoding/flake8-github-actions - :target: https://github.com/domdfcoding/flake8-github-actions/commit/master +.. |commits-latest| image:: https://img.shields.io/github/last-commit/python-formate/flake8-github-actions + :target: https://github.com/python-formate/flake8-github-actions/commit/master :alt: GitHub last commit -.. |maintained| image:: https://img.shields.io/maintenance/yes/2021 +.. |maintained| image:: https://img.shields.io/maintenance/yes/2026 :alt: Maintenance .. |pypi-downloads| image:: https://img.shields.io/pypi/dm/flake8-github-actions - :target: https://pypi.org/project/flake8-github-actions/ + :target: https://pypistats.org/packages/flake8-github-actions :alt: PyPI - Downloads -.. |pre_commit_ci| image:: https://results.pre-commit.ci/badge/github/domdfcoding/flake8-github-actions/master.svg - :target: https://results.pre-commit.ci/latest/github/domdfcoding/flake8-github-actions/master - :alt: pre-commit.ci status - .. end shields Installation @@ -153,3 +153,8 @@ Example workflow: - name: "Run Flake8" run: "flake8 --format github" + + +The annotations will look something like: + +.. image:: https://raw.githubusercontent.com/domdfcoding/flake8-github-actions/master/example_annotations.png diff --git a/__pkginfo__.py b/__pkginfo__.py deleted file mode 100644 index dfbcb37..0000000 --- a/__pkginfo__.py +++ /dev/null @@ -1,33 +0,0 @@ -# This file is managed by 'repo_helper'. Don't edit it directly. -# Copyright © 2020 Dominic Davis-Foster -# -# This file is distributed under the same license terms as the program it came with. -# There will probably be a file called LICEN[S/C]E in the same directory as this file. -# -# In any case, this program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# -# This script based on https://github.com/rocky/python-uncompyle6/blob/master/__pkginfo__.py -# - -# stdlib -import pathlib - -__all__ = [ - "__copyright__", - "__version__", - "repo_root", - "install_requires", - "extras_require", - ] - -__copyright__ = """ -2020 Dominic Davis-Foster -""" - -__version__ = "0.1.1" - -repo_root = pathlib.Path(__file__).parent -install_requires = (repo_root / "requirements.txt").read_text(encoding="utf-8").split('\n') -extras_require = {"all": []} diff --git a/example_annotations.png b/example_annotations.png new file mode 100644 index 0000000..50d3f0d Binary files /dev/null and b/example_annotations.png differ diff --git a/flake8_github_actions/__init__.py b/flake8_github_actions/__init__.py index 537b78d..4ffb815 100644 --- a/flake8_github_actions/__init__.py +++ b/flake8_github_actions/__init__.py @@ -5,7 +5,7 @@ GitHub Actions integration for flake8. """ # -# Copyright © 2020 Dominic Davis-Foster +# Copyright © 2020-2021 Dominic Davis-Foster # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -26,20 +26,23 @@ # OR OTHER DEALINGS IN THE SOFTWARE. # +# stdlib +from typing import TYPE_CHECKING, Any + # 3rd party -from domdf_python_tools.words import Plural -from flake8.formatting.base import BaseFormatter # type: ignore +from flake8.formatting.base import BaseFormatter + +if TYPE_CHECKING: + # 3rd party + from flake8.violation import Violation __author__: str = "Dominic Davis-Foster" -__copyright__: str = "2020 Dominic Davis-Foster" +__copyright__: str = "2020-2021 Dominic Davis-Foster" __license__: str = "MIT License" __version__: str = "0.1.1" __email__: str = "dominic@davis-foster.co.uk" -__all__ = ["GitHubFormatter"] - -_error = Plural("error", "errors") -_file = Plural("file", "files") +__all__ = ("GitHubFormatter", ) class GitHubFormatter(BaseFormatter): @@ -47,31 +50,34 @@ class GitHubFormatter(BaseFormatter): Custom Flake8 formatter for GitHub actions. """ - def write_line(self, line): + reported_errors_count: int + + def write_line(self, line: str) -> None: # noqa: PRM002 """ Override write for convenience. """ + self.write(line, None) - def start(self): # noqa: D102 + def start(self) -> None: # noqa: D102 super().start() self.files_reported_count = 0 - def beginning(self, filename): + def beginning(self, filename: Any) -> None: # noqa: PRM002 """ We're starting a new file. """ self.reported_errors_count = 0 - def finished(self, filename): + def finished(self, filename: Any) -> None: # noqa: PRM002 """ We've finished processing a file. """ self.files_reported_count += 1 - def format(self, violation): # noqa: A003 # pylint: disable=redefined-builtin + def format(self, violation: "Violation") -> None: # noqa: PRM002,A003 # pylint: disable=redefined-builtin """ Format a violation. """ diff --git a/formate.toml b/formate.toml index be02f67..3b9461a 100644 --- a/formate.toml +++ b/formate.toml @@ -5,22 +5,25 @@ reformat-generics = 40 noqa-reformat = 60 ellipsis-reformat = 70 squish_stubs = 80 - -[config] -indent = "\t" -line_length = 115 +newline_after_equals = 90 [hooks.yapf] priority = 30 -[hooks.isort] -priority = 50 - [hooks.yapf.kwargs] yapf_style = ".style.yapf" +[hooks.trailing_commas] +priority = 21 + +[hooks.trailing_commas.kwargs] +format_ImportFrom = false + +[hooks.isort] +priority = 50 + [hooks.isort.kwargs] -indent = "\t\t" +indent = " " multi_line_output = 8 import_heading_stdlib = "stdlib" import_heading_thirdparty = "3rd party" @@ -31,19 +34,8 @@ lines_between_types = 0 use_parentheses = true remove_redundant_aliases = true default_section = "THIRDPARTY" -known_third_party = [ - "apeye", - "attrs", - "click", - "consolekit", - "domdf_python_tools", - "dulwich", - "flake8", - "flake8_json", - "flake8_prettycount", - "github", - "github3_py", - "requests", - "typing_extensions", -] -known_first_party = "flake8_github_actions" +known_first_party = [ "flake8_github_actions",] + +[config] +indent = " " +line_length = 115 diff --git a/justfile b/justfile new file mode 100644 index 0000000..9cd8b78 --- /dev/null +++ b/justfile @@ -0,0 +1,25 @@ +default: lint + +pdf-docs: latex-docs + make -C doc-source/build/latex/ + +latex-docs: + SPHINX_BUILDER=latex tox -e docs + +unused-imports: + tox -e lint -- --select F401 + +incomplete-defs: + tox -e lint -- --select MAN + +commas: + tox -e lint -- --select C810,C812,C813,C814,C815,C816 + +vdiff: + git diff $(repo-helper show version -q)..HEAD + +bare-ignore: + greppy '# type:? *ignore(?!\[|\w)' -s + +lint: unused-imports incomplete-defs bare-ignore + tox -n qa diff --git a/pyproject.toml b/pyproject.toml index 969c374..c9edc28 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,28 +1,72 @@ [build-system] -requires = [ "setuptools>=40.6.0", "wheel>=0.34.2",] -build-backend = "setuptools.build_meta" +requires = [ "whey",] +build-backend = "whey" [project] name = "flake8-github-actions" -version = "0.1.0" +version = "0.1.1" description = "GitHub Actions integration for flake8." readme = "README.rst" +requires-python = ">=3.6" keywords = [ "flake8", "github", "github-actions",] -dynamic = [ "requires-python", "classifiers", "dependencies",] -[[project.authors]] -email = "dominic@davis-foster.co.uk" -name = "Dominic Davis-Foster" - -[tool.importcheck] -always = [ "flake8_github_actions",] +dynamic = [ "classifiers", "dependencies",] [project.license] file = "LICENSE" +[[project.authors]] +name = "Dominic Davis-Foster" +email = "dominic@davis-foster.co.uk" + [project.urls] -Homepage = "https://github.com/domdfcoding/flake8-github-actions" -"Issue Tracker" = "https://github.com/domdfcoding/flake8-github-actions/issues" -"Source Code" = "https://github.com/domdfcoding/flake8-github-actions" +Homepage = "https://github.com/python-formate/flake8-github-actions" +"Issue Tracker" = "https://github.com/python-formate/flake8-github-actions/issues" +"Source Code" = "https://github.com/python-formate/flake8-github-actions" [project.entry-points."flake8.report"] github = "flake8_github_actions:GitHubFormatter" + +[tool.whey] +base-classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Console", + "Framework :: Flake8", + "Intended Audience :: Developers", + "Typing :: Typed", +] +python-versions = [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13",] +python-implementations = [ "CPython", "PyPy",] +platforms = [ "Windows", "macOS", "Linux",] +license-key = "MIT" +package = "flake8_github_actions" + +[tool.mypy] +python_version = "3.9" +namespace_packages = true +check_untyped_defs = true +warn_unused_ignores = true +no_implicit_optional = true +show_error_codes = true + +[tool.snippet-fmt] +directives = [ "code-block",] + +[tool.snippet-fmt.languages.python] +reformat = true + +[tool.snippet-fmt.languages.TOML] +reformat = true + +[tool.snippet-fmt.languages.ini] + +[tool.snippet-fmt.languages.json] + +[tool.dep_checker] +allowed_unused = [ "flake8",] + +[tool.dependency-dash."requirements.txt"] +order = 10 + +[tool.dependency-dash."tests/requirements.txt"] +order = 20 +include = false diff --git a/repo_helper.yml b/repo_helper.yml index 735ca85..75afad5 100644 --- a/repo_helper.yml +++ b/repo_helper.yml @@ -4,22 +4,48 @@ modname: 'flake8-github-actions' copyright_years: '2020' author: 'Dominic Davis-Foster' email: 'dominic@davis-foster.co.uk' -username: 'domdfcoding' +username: "python-formate" +assignee: "domdfcoding" version: '0.1.1' license: 'MIT' short_desc: 'GitHub Actions integration for flake8.' +min_coverage: 100 enable_conda: false -enable_tests: false enable_docs: false +requires_python: 3.6 +pre_commit_exclude: "^tests/bad_code.py$" +use_whey: true +mypy_version: 1.16 +python_deploy_version: 3.9 python_versions: - - '3.6' - - '3.7' - - '3.8' - - '3.9' - - 3.10-dev - - pypy3 + 3.7: + matrix_exclude: + flake8: + - 6 + - 7 + 3.8: + 3.9: + "3.10": + 3.11: + 3.12: + matrix_exclude: + flake8: + - 4 + - 5 + 3.13: + matrix_exclude: + flake8: + - 4 + - 5 + pypy37: + matrix_exclude: + flake8: + - 6 + - 7 + pypy38: + pypy39: additional_ignore: - action.py @@ -34,8 +60,17 @@ entry_points: - github = flake8_github_actions:GitHubFormatter classifiers: + - 'Development Status :: 4 - Beta' - 'Environment :: Console' - 'Framework :: Flake8' - 'Intended Audience :: Developers' -requires_python: 3.6 +tox_unmanaged: + - "testenv:lint" + +third_party_version_matrix: + flake8: + - 4 + - 5 + - 6 + - 7 diff --git a/requirements.txt b/requirements.txt index 575ad80..4163a01 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ -domdf-python-tools>=2.0.0 flake8>=3.8.4 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 293e1bc..0000000 --- a/setup.cfg +++ /dev/null @@ -1,57 +0,0 @@ -# This file is managed by 'repo_helper'. -# You may add new sections, but any changes made to the following sections will be lost: -# * metadata -# * options -# * options.packages.find -# * mypy -# * options.entry_points - -[metadata] -name = flake8-github-actions -author = Dominic Davis-Foster -author_email = dominic@davis-foster.co.uk -license = MIT License -keywords = flake8, github, github-actions -long_description = file: README.rst -long_description_content_type = text/x-rst -platforms = Windows, macOS, Linux -url = https://github.com/domdfcoding/flake8-github-actions -project_urls = - Issue Tracker = https://github.com/domdfcoding/flake8-github-actions/issues - Source Code = https://github.com/domdfcoding/flake8-github-actions -classifiers = - Environment :: Console - Framework :: Flake8 - Intended Audience :: Developers - License :: OSI Approved :: MIT License - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: Implementation :: CPython - Programming Language :: Python :: Implementation :: PyPy - Typing :: Typed - -[options] -python_requires = >=3.6 -zip_safe = False -include_package_data = True -packages = find: - -[options.packages.find] -exclude = - doc-source - tests - tests.* - -[mypy] -python_version = 3.6 -namespace_packages = True -check_untyped_defs = True -warn_unused_ignores = True - -[options.entry_points] -flake8.report = github = flake8_github_actions:GitHubFormatter diff --git a/setup.py b/setup.py deleted file mode 100644 index 762f9ac..0000000 --- a/setup.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python -# This file is managed by 'repo_helper'. Don't edit it directly. - -# stdlib -import shutil -import sys - -# 3rd party -from setuptools import setup - -sys.path.append('.') - -# this package -from __pkginfo__ import * # pylint: disable=wildcard-import - -setup( - description="GitHub Actions integration for flake8.", - extras_require=extras_require, - install_requires=install_requires, - py_modules=[], - version=__version__, - ) - -shutil.rmtree("flake8_github_actions.egg-info", ignore_errors=True) diff --git a/stubs.txt b/stubs.txt new file mode 100644 index 0000000..846f672 --- /dev/null +++ b/stubs.txt @@ -0,0 +1 @@ +types-flake8 diff --git a/tests/bad_code.py b/tests/bad_code.py new file mode 100644 index 0000000..ba3f389 --- /dev/null +++ b/tests/bad_code.py @@ -0,0 +1,13 @@ +# type: ignore +import warnings + + +from __future__ import annotations + + + + + +print(name) + +break \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..81ca008 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1 @@ +pytest_plugins = ("coincidence", ) diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 0000000..ee69d13 --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1,10 @@ +coincidence>=0.2.0 +coverage>=5.1 +coverage-pyver-pragma>=0.2.1 +domdf-python-tools[testing]>=2.0.1 +importlib-metadata>=3.6.0 +iniconfig!=1.1.0,>=1.0.1 +pytest>=6.0.0 +pytest-cov>=2.8.1 +pytest-randomly>=3.7.0 +pytest-timeout>=1.4.2 diff --git a/tests/test_output.py b/tests/test_output.py new file mode 100644 index 0000000..372a1fd --- /dev/null +++ b/tests/test_output.py @@ -0,0 +1,23 @@ +# 3rd party +import pytest +from coincidence.regressions import FileRegressionFixture, check_file_regression +from domdf_python_tools.compat import importlib_metadata +from domdf_python_tools.paths import PathPlus +from flake8.main import cli + +bad_code = PathPlus(__file__).parent / "bad_code.py" + + +def test_output(file_regression: FileRegressionFixture, capsys): + args = [str(bad_code), "--select", "F401,F404,F821,F701,E303", "--format", "github"] + + if int(importlib_metadata.version("flake8").split('.')[0]) >= 5: + cli.main(args) + + else: + with pytest.raises(SystemExit): + cli.main(args) + + stdout = capsys.readouterr().out.replace(str(bad_code), "bad_code.py") + check_file_regression(stdout, file_regression) + assert not capsys.readouterr().err diff --git a/tests/test_output_/test_output.txt b/tests/test_output_/test_output.txt new file mode 100644 index 0000000..e8450c4 --- /dev/null +++ b/tests/test_output_/test_output.txt @@ -0,0 +1,7 @@ +bad_code.py +::warning file=bad_code.py,line=2,col=1::F401: 'warnings' imported but unused +::warning file=bad_code.py,line=5,col=1::F404: from __future__ imports must occur at the beginning of the file +::warning file=bad_code.py,line=11,col=1::E303: too many blank lines (5) +::warning file=bad_code.py,line=11,col=7::F821: undefined name 'name' +::warning file=bad_code.py,line=13,col=1::F701: 'break' outside loop +5 diff --git a/tox.ini b/tox.ini index fe2f060..b09e188 100644 --- a/tox.ini +++ b/tox.ini @@ -3,135 +3,247 @@ # * tox # * envlists # * testenv +# * testenv:.package +# * testenv:py313-dev +# * testenv:py313 +# * testenv:py312-dev +# * testenv:py312 # * testenv:docs # * testenv:build -# * testenv:lint +# * testenv:perflint # * testenv:mypy # * testenv:pyup +# * testenv:coverage # * flake8 +# * coverage:run +# * coverage:report # * check-wheel-contents # * pytest [tox] -envlist = py36, py37, py38, py39, py310-dev, pypy3, mypy, build +envlist = + py37-flake8{4,5} + py38-flake8{4,5,6,7} + py39-flake8{4,5,6,7} + py310-flake8{4,5,6,7} + py311-flake8{4,5,6,7} + py312-flake8{6,7} + py313-flake8{6,7} + pypy37-flake8{4,5} + pypy38-flake8{4,5,6,7} + pypy39-flake8{4,5,6,7} + mypy + build skip_missing_interpreters = True isolated_build = True requires = - pip>=20.3.3 + pip>=21,!=22.2 tox-envlist>=0.2.1 - tox-pip-version>=0.0.7 + tox~=3.0 + virtualenv!=20.16.0,<20.39 [envlists] -test = py36, py37, py38, py39, py310-dev, pypy3 +test = + py37-flake8{4,5} + py38-flake8{4,5,6,7} + py39-flake8{4,5,6,7} + py310-flake8{4,5,6,7} + py311-flake8{4,5,6,7} + py312-flake8{6,7} + py313-flake8{6,7} + pypy37-flake8{4,5} + pypy38-flake8{4,5,6,7} + pypy39-flake8{4,5,6,7} qa = mypy, lint +cov = py39-flake84, coverage [testenv] -setenv = PYTHONDEVMODE = 1 -deps = importcheck>=0.1.0 +setenv = + PYTHONDEVMODE=1 + PIP_DISABLE_PIP_VERSION_CHECK=1 + SETUPTOOLS_USE_DISTUTILS=stdlib +download = True +deps = + -r{toxinidir}/tests/requirements.txt + flake84: flake8~=4.0 + flake85: flake8~=5.0 + flake86: flake8~=6.0 + flake87: flake8~=7.0 commands = python --version - python -m importcheck {posargs} + python -m pytest --cov=flake8_github_actions -r aR tests/ {posargs} + +[testenv:.package] +setenv = + PYTHONDEVMODE=1 + PIP_DISABLE_PIP_VERSION_CHECK=1 + +[testenv:py313] +setenv = + PYTHONDEVMODE=1 + PIP_DISABLE_PIP_VERSION_CHECK=1 + +[testenv:py312] +setenv = + PYTHONDEVMODE=1 + PIP_DISABLE_PIP_VERSION_CHECK=1 [testenv:build] +setenv = + PYTHONDEVMODE=1 + PIP_DISABLE_PIP_VERSION_CHECK=1 + PIP_PREFER_BINARY=1 + UNSAFE_PYO3_SKIP_VERSION_CHECK=1 skip_install = True changedir = {toxinidir} deps = - twine>=3.2.0 - pep517>=0.9.1 + build[virtualenv]>=0.3.1 check-wheel-contents>=0.1.0 + twine>=3.2.0 + cryptography<40; implementation_name == "pypy" and python_version <= "3.7" commands = - python -m pep517.build --source --binary "{toxinidir}" + python -m build --sdist --wheel "{toxinidir}" twine check dist/*.tar.gz dist/*.whl check-wheel-contents dist/ -[testenv:lint] -basepython = python3.6 +[testenv:perflint] +basepython = python3.9 changedir = {toxinidir} ignore_errors = True -skip_install = False -deps = - flake8 >=3.8.2 - flake8-2020 >= 1.6.0 - flake8-builtins>=1.5.3 - flake8-docstrings>=1.5.0 - flake8-dunder-all>=0.1.1 - flake8-github-actions>=0.1.0 - flake8-pyi>=20.10.0 - flake8-pytest-style>=1.3.0 - flake8-sphinx-links>=0.0.4 - flake8-strftime>=0.1.1 - flake8-typing-imports>=1.10.0 - flake8-encodings>=0.1.0 - flake8-slots>=0.1.0 - git+https://github.com/PyCQA/pydocstyle@5118faa7173b0e5bbc230c4adf628758e13605bf - git+https://github.com/domdfcoding/flake8-quotes.git - git+https://github.com/domdfcoding/flake8-rst-docstrings.git - git+https://github.com/domdfcoding/flake8-rst-docstrings-sphinx.git - pygments>=2.7.1 -commands = python3 -m flake8_rst_docstrings_sphinx flake8_github_actions --allow-toolbox {posargs} +skip_install = True +deps = perflint +commands = python3 -m perflint flake8_github_actions {posargs} [testenv:mypy] -basepython = python3.6 +basepython = python3.9 ignore_errors = True changedir = {toxinidir} -deps = mypy==0.800 -commands = mypy flake8_github_actions {posargs} +deps = + mypy==1.16 + -r{toxinidir}/tests/requirements.txt + -r{toxinidir}/stubs.txt +commands = mypy flake8_github_actions tests {posargs} [testenv:pyup] -basepython = python3.6 +basepython = python3.9 skip_install = True ignore_errors = True changedir = {toxinidir} deps = pyupgrade-directories -commands = pyup_dirs flake8_github_actions --py36-plus --recursive +commands = pyup_dirs flake8_github_actions tests --py36-plus --recursive + +[testenv:coverage] +basepython = python3.9 +skip_install = True +ignore_errors = True +whitelist_externals = /bin/bash +passenv = + COV_PYTHON_VERSION + COV_PLATFORM + COV_PYTHON_IMPLEMENTATION + * +changedir = {toxinidir} +deps = + coverage>=5 + coverage_pyver_pragma>=0.2.1 +commands = + /bin/bash -c "rm -rf htmlcov" + coverage html + /bin/bash -c "DISPLAY=:0 firefox 'htmlcov/index.html'" [flake8] max-line-length = 120 -select = E111 E112 E113 E121 E122 E125 E127 E128 E129 E131 E133 E201 E202 E203 E211 E222 E223 E224 E225 E225 E226 E227 E228 E231 E241 E242 E251 E261 E262 E265 E271 E272 E303 E304 E306 E402 E502 E703 E711 E712 E713 E714 E721 W291 W292 W293 W391 W504 YTT101 YTT102 YTT103 YTT201 YTT202 YTT203 YTT204 YTT301 YTT302 YTT303 STRFTIME001 STRFTIME002 SXL001 PT001 PT002 PT003 PT005 PT006 PT007 PT008 PT009 PT010 PT011 PT012 PT013 PT014 PT015 PT016 PT017 PT018 PT019 PT020 PT021 RST201 RST202 RST203 RST204 RST205 RST206 RST207 RST208 RST210 RST211 RST212 RST213 RST214 RST215 RST216 RST217 RST218 RST219 RST299 RST301 RST302 RST303 RST304 RST305 RST306 RST399 RST401 RST499 RST900 RST901 RST902 RST903 Q001 Q002 Q003 A001 A002 A003 TYP001 TYP002 TYP003 TYP004 TYP005 TYP006 ENC001 ENC002 ENC003 ENC004 Y001,Y002 Y003 Y004 Y005 Y006 Y007 Y008 Y009 Y010 Y011 Y012 Y013 Y014 Y015 Y090 Y091 E301 E302 E305 D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DALL000 SLOT000 SLOT001 SLOT002 SLOT003 -exclude = doc-source,.git,__pycache__,old,build,dist,__pkginfo__.py,setup.py,.tox,venv +select = E111 E112 E113 E121 E122 E125 E127 E128 E129 E131 E133 E201 E202 E203 E211 E222 E223 E224 E225 E225 E226 E227 E228 E231 E241 E242 E251 E261 E262 E265 E271 E272 E303 E304 E306 E402 E502 E703 E711 E712 E713 E714 E721 W291 W292 W293 W391 W504 YTT101 YTT102 YTT103 YTT201 YTT202 YTT203 YTT204 YTT301 YTT302 YTT303 STRFTIME001 STRFTIME002 SXL001 NUF001 PT001 PT002 PT003 PT006 PT007 PT008 PT009 PT010 PT011 PT012 PT013 PT014 PT015 PT016 PT017 PT018 PT019 PT020 PT021 RST201 RST202 RST203 RST204 RST205 RST206 RST207 RST208 RST210 RST211 RST212 RST213 RST214 RST215 RST216 RST217 RST218 RST219 RST299 RST301 RST302 RST303 RST304 RST305 RST306 RST399 RST401 RST499 RST900 RST901 RST902 RST903 Q001 Q002 Q003 A001 A002 TYP001 TYP002 TYP003 TYP004 TYP005 TYP006 ENC001 ENC002 ENC003 ENC004 ENC011 ENC012 ENC021 ENC022 ENC023 ENC024 ENC025 ENC026 Y001,Y002 Y003 Y004 Y005 Y006 Y007 Y008 Y009 Y010 Y011 Y012 Y013 Y014 Y015 Y090 Y091 NQA001 NQA002 NQA003 NQA004 NQA005 NQA102 NQA103 C818 C819 E301 E302 E305 D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DALL000 SLOT000 SLOT001 SLOT002 PRM001 PRM002 PRM003 +extend-exclude = doc-source,old,build,dist,__pkginfo__.py,setup.py,venv rst-directives = TODO envvar extras-require + license + license-info +rst-roles = choosealicense per-file-ignores = - tests/*: D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DALL000 SLOT000 SLOT001 SLOT002 SLOT003 - */*.pyi: E301 E302 E305 D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DALL000 SLOT000 SLOT001 SLOT002 SLOT003 + tests/*: D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DALL000 SLOT000 SLOT001 SLOT002 PRM001 PRM002 PRM003 + */*.pyi: E301 E302 E305 D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DALL000 SLOT000 SLOT001 SLOT002 PRM001 PRM002 PRM003 pytest-parametrize-names-type = csv inline-quotes = " multiline-quotes = """ docstring-quotes = """ count = True - -[check-wheel-contents] -ignore = W002 -toplevel = flake8_github_actions -package = flake8_github_actions - -[pytest] -addopts = --color yes --durations 25 -timeout = 300 +min_python_version = 3.6 +unused-arguments-ignore-abstract-functions = True +unused-arguments-ignore-overload-functions = True +unused-arguments-ignore-magic-methods = True +unused-arguments-ignore-variadic-names = True [coverage:run] plugins = coverage_pyver_pragma [coverage:report] +fail_under = 100 +show_missing = True exclude_lines = raise AssertionError raise NotImplementedError if 0: if False: - if TYPE_CHECKING: - if typing.TYPE_CHECKING: + if TYPE_CHECKING + if typing.TYPE_CHECKING if __name__ == .__main__.: - \.\.\. - -[gh-actions] -python = - 3.6: py36, build, mypy - 3.7: py37, build - 3.8: py38, build - 3.9: py39, build - -[dep_checker] -allowed_unused = - flake8 + +[check-wheel-contents] +ignore = W002 +toplevel = flake8_github_actions +package = flake8_github_actions + +[pytest] +addopts = --color yes --durations 25 +timeout = 300 +filterwarnings = + error + ignore:SelectableGroups dict interface is deprecated. Use select.:DeprecationWarning:flake8 + ignore:can't resolve package from __spec__ or __package__, falling back on __name__ and __path__:ImportWarning + ignore:ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead:DeprecationWarning + +[testenv:py312-flake8{4,5,6,7}] +setenv = + PYTHONDEVMODE=1 + PIP_DISABLE_PIP_VERSION_CHECK=1 + +[testenv:py313-flake8{4,5,6,7}] +setenv = + PYTHONDEVMODE=1 + PIP_DISABLE_PIP_VERSION_CHECK=1 + +[testenv:lint] +basepython = python3.9 +changedir = {toxinidir} +ignore_errors = True +skip_install = False +deps = + flake8>=3.8.2,<5 + flake8-2020>=1.6.0 + flake8-builtins>=1.5.3 + flake8-docstrings>=1.5.0 + flake8-dunder-all>=0.1.1 + flake8-encodings>=0.1.0 + flake8-github-actions>=0.1.0 + git+https://github.com/python-formate/flake8-noqa.git@v1.2.2-python-formate.0 + flake8-pyi>=20.10.0,<=22.8.0 + flake8-pytest-style>=1.3.0,<2 + flake8-quotes>=3.3.0 + flake8-slots>=0.1.0 + flake8-sphinx-links>=0.0.4 + flake8-strftime>=0.1.1 + flake8-typing-imports>=1.10.0 + flake8-params>=0.1.0 + flake8-unused-fstrings>=2.0.0 + git+https://github.com/python-formate/flake8-commas.git@4.0.0-python-formate.0 + git+https://github.com/domdfcoding/restructuredtext-lint.git@fix-deprecations + git+https://github.com/domdfcoding/flake8-rst-docstrings-sphinx.git + git+https://github.com/domdfcoding/flake8-rst-docstrings.git + git+https://github.com/python-formate/flake8-unused-arguments.git@magic-methods + git+https://github.com/python-formate/flake8-missing-annotations.git + git+https://github.com/domdfcoding/pydocstyle.git@stub-functions + pygments>=2.7.1 +commands = python3 -m flake8_rst_docstrings_sphinx flake8_github_actions tests --allow-toolbox --extend-exclude bad_code.py {posargs}