Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tooling #152

Merged
merged 8 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,
99 changes: 35 additions & 64 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,33 +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: py-${{ matrix.python-version }}/isort-${{ matrix.isort }}/flake8-${{ matrix.flake8 }}
runs-on: ubuntu-latest
name: Testing on
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.12.0-beta.2", "3.11", "3.10", 3.9, 3.8, pypy-3.9]
isort: [5.11.2]
flake8: [5.0.4]
include:
- python-version: 3.9
isort: 5.11.2
flake8: 4.0.1
qa: 'true'
- python-version: 3.9
isort: 5.11.2
flake8: 3.9.2
- python-version: 3.9
isort: 5.11.2
flake8: 6.0.0
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 @@ -36,52 +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.qa != 'true'
run: |
python -m pip install -r requirements.txt
pip install 'isort==${{ matrix.isort }}' 'flake8==${{ matrix.flake8 }}'
- name: Install dependencies
if: matrix.qa == 'true'
run: |
python -m pip install -r requirements-lint.txt
pip install 'isort==${{ matrix.isort }}' 'flake8==${{ matrix.flake8 }}'
# isort 4.x requires `toml` to be able to read pyproject.toml, so install it...
- name: Install toml if required
run: pip install toml
if: matrix.isort == '4.3.21'
# formatters
- name: Run pyupgrade
if: matrix.qa == 'true'
run: pyupgrade --py37-plus *.py
- name: Run isort
if: matrix.qa == 'true'
run: isort --check-only *.py
- name: Run black
if: matrix.qa == 'true'
run: black --check --skip-string-normalization *.py
# linters
- name: Lint with bandit
if: matrix.qa == 'true'
run: bandit --skip B101 *.py # B101 is assert statements
- name: Lint with codespell
if: matrix.qa == 'true'
run: codespell *.rst *.py
- name: Lint with flake8
if: matrix.qa == 'true'
run: flake8 *.py --count --max-complexity=18 --max-line-length=88 --show-source --statistics
- name: Lint with mypy
if: matrix.qa == 'true'
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
11 changes: 10 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@ Changelog
6.1.1 (unreleased)
------------------

- Nothing changed yet.
- Switch from `setup.cfg` to `setup.py`.
[deronnax]

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

- Switch to `main` branch.
[gforcada]

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

6.1.0 (2023-09-15)
------------------
Expand Down
5 changes: 3 additions & 2 deletions flake8_isort.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import warnings
from contextlib import redirect_stdout
from difflib import unified_diff
from importlib.metadata import PackageNotFoundError, version
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version
from io import StringIO
from pathlib import Path

import isort
import warnings


def _version():
Expand Down
80 changes: 43 additions & 37 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,55 +1,61 @@
[build-system]
requires = ["setuptools>=61.2"]
build-backend = "setuptools.build_meta"
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "flake8-isort"
version = "6.1.1.dev0"
authors = [{ name = "Gil Forcada", email = "gil.gnome@gmail.com" }]
license = { text = "GPL version 2" }
description = "flake8 plugin that integrates isort ."
authors = [
{ name="Gil Forcada Codinachs", email="gil.gnome@gmail.com" },
]
description = "flake8 plugin that integrates isort"
keywords = ["pep8", "flake8", "python", "isort", "imports"]
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 :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development",
"Topic :: Software Development :: Quality Assurance",
"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",
]
urls = { Homepage = "https://github.com/gforcada/flake8-isort" }
requires-python = ">=3.8"
dependencies = ["flake8", "isort >= 5.0.0, <6"]

[project.entry-points]
"flake8.extension" = { I00 = "flake8_isort:Flake8Isort" }
[project.urls]
"Homepage" = "https://github.com/gforcada/flake8-isort"
"Bug Tracker" = "https://github.com/gforcada/flake8-isort/issues"
"Changelog" = "https://github.com/gforcada/flake8-isort/blob/main/CHANGES.rst"

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

[tool.setuptools]
py-modules = ["flake8_isort"]
zip-safe = false
include-package-data = true
[project.entry-points."flake8.extension"]
I00 = "flake8_isort:Flake8Isort"

[tool.isort]
profile = "plone"

[tool."zest.releaser"]
create-wheel = "yes"
[tool.black]
target-version = ["py38"]
skip-string-normalization = true

[tool.check-manifest]
ignore = """
.installed.cfg"""

[tool.isort]
profile = "black"
ignore = [
".vscode/*",
"venv/*",
]
22 changes: 0 additions & 22 deletions requirements-lint.in

This file was deleted.