Skip to content

Commit

Permalink
Merge pull request #48 from gforcada/improve-tooling
Browse files Browse the repository at this point in the history
Improve tooling
  • Loading branch information
gforcada authored Nov 2, 2023
2 parents 3c924d2 + f8ab5ff commit 288f823
Show file tree
Hide file tree
Showing 13 changed files with 226 additions and 320 deletions.
13 changes: 13 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[flake8]
doctests = 1
ignore =
# black takes care of line length
E501,
# black takes care of where to break lines
W503,
# black takes care of spaces within slicing (list[:])
E203,
# black takes care of spaces after commas
E231,
# as one has to use self.XX it should not be a problem
A003,
76 changes: 34 additions & 42 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
name: Testing
on:
push:
branches: [master]
branches: [main]
pull_request:
branches: [master]
branches: [main]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
test:
name: Testing on
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.12.0-beta.2", "3.11", "3.10", 3.9, 3.8, pypy-3.9]
python-version: ["3.12", "3.11", "3.10", 3.9, 3.8, pypy-3.9]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand All @@ -23,44 +23,36 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('tox.ini') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
- name: pip version
run: pip --version
- name: Install dependencies
if: matrix.python-version != '3.9'
run: python -m pip install -r requirements.txt
- name: Install dependencies
if: matrix.python-version == '3.9'
run: python -m pip install -r requirements-lint.txt
# formatters
- name: Run pyupgrade
if: matrix.python-version == '3.9'
run: pyupgrade --py37-plus *.py
- name: Run isort
if: matrix.python-version == '3.9'
run: isort --check-only *.py
- name: Run black
if: matrix.python-version == '3.9'
run: black --check --skip-string-normalization *.py
# linters
- name: Lint with bandit
if: matrix.python-version == '3.9'
run: bandit --skip B101 *.py # B101 is assert statements
- name: Lint with codespell
if: matrix.python-version == '3.9'
run: codespell *.rst *.py
- name: Lint with flake8
if: matrix.python-version == '3.9'
run: flake8 *.py --count --max-complexity=18 --max-line-length=88 --show-source --statistics
- name: Lint with mypy
if: matrix.python-version == '3.9'
run: |
mkdir --parents --verbose .mypy_cache
mypy --ignore-missing-imports --install-types --non-interactive *.py || true
# tests and coverage
run: python -m pip install tox
- name: Test
run: pytest run_tests.py --cov --cov-report term-missing
- name: Coverage
run: coveralls --service=github
run: tox -e test

lint:
name: Lint code
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: [3.8]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache packages
uses: actions/cache@v3
with:
path: |
~/.cache/pre-commit
~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('tox.ini') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
- name: Install dependencies
run: python -m pip install tox
- name: Run linting
run: tox -e lint
50 changes: 50 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
ci:
autofix_prs: false
autoupdate_schedule: monthly

repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.14.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- flake8-builtins
- flake8-comprehensions
- flake8-debugger
- flake8-deprecated
- flake8-isort
- flake8-print
- flake8-quotes

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
additional_dependencies:
- tomli
- repo: https://github.com/mgedmin/check-manifest
rev: "0.49"
hooks:
- id: check-manifest
- repo: https://github.com/regebro/pyroma
rev: "4.2"
hooks:
- id: pyroma
- repo: https://github.com/mgedmin/check-python-versions
rev: "0.21.3"
hooks:
- id: check-python-versions
14 changes: 13 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@ Changelog
- Drop python 3.7 support.
[gforcada]

- Test against python 3.12 pre-release.
- Test against python 3.12.
[gforcada]

- Use `pyproject.toml` rather than `setup.py`.
[gforcada]

- Switch from `setuptools` to `hatchling`.
[gforcada]

- Switch to `main` branch.
[gforcada]

- Use `tox` and `pre-commit` to ease project maintenance.
[gforcada]

2.0.0 (2022-10-08)
Expand Down
4 changes: 2 additions & 2 deletions flake8_pep3101.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ast

from flake8 import utils as stdin_utils

import ast


class Flake8Pep3101:
name = 'flake8_pep3101'
Expand Down
60 changes: 60 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "flake8-pep3101"
version = "2.0.1.dev0"
authors = [
{ name="Gil Forcada Codinachs", email="[email protected]" },
]
description = "Checks for old string formatting"
keywords = ["pep8", "flake8", "python", "pycodestyle", "string formatting"]
license = {file = "LICENSE"}
readme = "README.rst"
requires-python = ">=3.8"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Framework :: Flake8",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development",
"Topic :: Software Development :: Quality Assurance",
]
dependencies = ["flake8"]

[project.urls]
"Homepage" = "https://github.com/gforcada/flake8-pep3101"
"Bug Tracker" = "https://github.com/gforcada/flake8-pep3101/issues"
"Changelog" = "https://github.com/gforcada/flake8-pep3101/blob/main/CHANGES.rst"

[project.optional-dependencies]
test = ["pytest"]

[project.entry-points."flake8.extension"]
S001 = "flake8_pep3101:Flake8Pep3101"

[tool.isort]
profile = "plone"

[tool.black]
target-version = ["py38"]
skip-string-normalization = true

[tool.check-manifest]
ignore = [
".vscode/*",
"venv/*",
]
20 changes: 0 additions & 20 deletions requirements-lint.in

This file was deleted.

Loading

0 comments on commit 288f823

Please sign in to comment.