Skip to content

Commit

Permalink
Merge pull request #37 from gforcada/improve-tooling
Browse files Browse the repository at this point in the history
Improve tooling
  • Loading branch information
gforcada committed Nov 2, 2023
2 parents cafadbb + ad224ff commit 0328b99
Show file tree
Hide file tree
Showing 13 changed files with 226 additions and 318 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
51 changes: 51 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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-pep3101
- 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]

1.5.0 (2022-10-09)
Expand Down
1 change: 0 additions & 1 deletion flake8_plone_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from collections import defaultdict

from flake8 import utils as stdin_utils


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

[project]
name = "flake8-plone-api"
version = "1.5.1.dev0"
authors = [
{ name="Gil Forcada Codinachs", email="gil.gnome@gmail.com" },
]
description = "Checks for code usages that can be replaced with Plone API method calls"
keywords = ["pep8", "flake8", "python", "plone" ]
license = {file = "LICENSE"}
readme = "README.rst"
requires-python = ">=3.8"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Framework :: Flake8",
'Framework :: Plone',
"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-plone-api"
"Bug Tracker" = "https://github.com/gforcada/flake8-plone-api/issues"
"Changelog" = "https://github.com/gforcada/flake8-plone-api/blob/main/CHANGES.rst"

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

[project.entry-points."flake8.extension"]
P001 = "flake8_plone_api:PloneAPIChecker"

[tool.isort]
profile = "plone"

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

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

This file was deleted.

0 comments on commit 0328b99

Please sign in to comment.