Skip to content

Commit 6b0f08d

Browse files
authored
Merge pull request #152 from gforcada/improve-tooling
Improve tooling
2 parents 63f32a2 + 3335735 commit 6b0f08d

File tree

11 files changed

+201
-330
lines changed

11 files changed

+201
-330
lines changed

.flake8

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[flake8]
2+
doctests = 1
3+
ignore =
4+
# black takes care of line length
5+
E501,
6+
# black takes care of where to break lines
7+
W503,
8+
# black takes care of spaces within slicing (list[:])
9+
E203,
10+
# black takes care of spaces after commas
11+
E231,
12+
# as one has to use self.XX it should not be a problem
13+
A003,

.github/workflows/tests.yml

Lines changed: 35 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,20 @@
11
name: Testing
22
on:
33
push:
4-
branches: [master]
4+
branches: [main]
55
pull_request:
6-
branches: [master]
6+
branches: [main]
77
env:
88
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99
jobs:
1010
test:
11-
name: py-${{ matrix.python-version }}/isort-${{ matrix.isort }}/flake8-${{ matrix.flake8 }}
12-
runs-on: ubuntu-latest
11+
name: Testing on
12+
runs-on: "ubuntu-latest"
1313
strategy:
1414
matrix:
15-
python-version: ["3.12.0-beta.2", "3.11", "3.10", 3.9, 3.8, pypy-3.9]
16-
isort: [5.11.2]
17-
flake8: [5.0.4]
18-
include:
19-
- python-version: 3.9
20-
isort: 5.11.2
21-
flake8: 4.0.1
22-
qa: 'true'
23-
- python-version: 3.9
24-
isort: 5.11.2
25-
flake8: 3.9.2
26-
- python-version: 3.9
27-
isort: 5.11.2
28-
flake8: 6.0.0
15+
python-version: ["3.12", "3.11", "3.10", 3.9, 3.8, pypy-3.9]
2916
steps:
30-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
3118
- name: Set up Python
3219
uses: actions/setup-python@v4
3320
with:
@@ -36,52 +23,36 @@ jobs:
3623
uses: actions/cache@v3
3724
with:
3825
path: ~/.cache/pip
39-
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
26+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('tox.ini') }}
4027
restore-keys: |
4128
${{ runner.os }}-pip-${{ matrix.python-version }}-
42-
- name: pip version
43-
run: pip --version
4429
- name: Install dependencies
45-
if: matrix.qa != 'true'
46-
run: |
47-
python -m pip install -r requirements.txt
48-
pip install 'isort==${{ matrix.isort }}' 'flake8==${{ matrix.flake8 }}'
49-
- name: Install dependencies
50-
if: matrix.qa == 'true'
51-
run: |
52-
python -m pip install -r requirements-lint.txt
53-
pip install 'isort==${{ matrix.isort }}' 'flake8==${{ matrix.flake8 }}'
54-
# isort 4.x requires `toml` to be able to read pyproject.toml, so install it...
55-
- name: Install toml if required
56-
run: pip install toml
57-
if: matrix.isort == '4.3.21'
58-
# formatters
59-
- name: Run pyupgrade
60-
if: matrix.qa == 'true'
61-
run: pyupgrade --py37-plus *.py
62-
- name: Run isort
63-
if: matrix.qa == 'true'
64-
run: isort --check-only *.py
65-
- name: Run black
66-
if: matrix.qa == 'true'
67-
run: black --check --skip-string-normalization *.py
68-
# linters
69-
- name: Lint with bandit
70-
if: matrix.qa == 'true'
71-
run: bandit --skip B101 *.py # B101 is assert statements
72-
- name: Lint with codespell
73-
if: matrix.qa == 'true'
74-
run: codespell *.rst *.py
75-
- name: Lint with flake8
76-
if: matrix.qa == 'true'
77-
run: flake8 *.py --count --max-complexity=18 --max-line-length=88 --show-source --statistics
78-
- name: Lint with mypy
79-
if: matrix.qa == 'true'
80-
run: |
81-
mkdir --parents --verbose .mypy_cache
82-
mypy --ignore-missing-imports --install-types --non-interactive *.py || true
83-
# tests and coverage
30+
run: python -m pip install tox
8431
- name: Test
85-
run: pytest run_tests.py --cov --cov-report term-missing
86-
- name: Coverage
87-
run: coveralls --service=github
32+
run: tox -e test
33+
34+
lint:
35+
name: Lint code
36+
runs-on: "ubuntu-latest"
37+
strategy:
38+
matrix:
39+
python-version: [3.8]
40+
steps:
41+
- uses: actions/checkout@v4
42+
- name: Set up Python
43+
uses: actions/setup-python@v4
44+
with:
45+
python-version: ${{ matrix.python-version }}
46+
- name: Cache packages
47+
uses: actions/cache@v3
48+
with:
49+
path: |
50+
~/.cache/pre-commit
51+
~/.cache/pip
52+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('tox.ini') }}
53+
restore-keys: |
54+
${{ runner.os }}-pip-${{ matrix.python-version }}-
55+
- name: Install dependencies
56+
run: python -m pip install tox
57+
- name: Run linting
58+
run: tox -e lint

.pre-commit-config.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
ci:
2+
autofix_prs: false
3+
autoupdate_schedule: monthly
4+
5+
repos:
6+
- repo: https://github.com/asottile/pyupgrade
7+
rev: v3.14.0
8+
hooks:
9+
- id: pyupgrade
10+
args: [--py38-plus]
11+
- repo: https://github.com/pycqa/isort
12+
rev: 5.12.0
13+
hooks:
14+
- id: isort
15+
- repo: https://github.com/psf/black
16+
rev: 23.9.1
17+
hooks:
18+
- id: black
19+
- repo: https://github.com/PyCQA/flake8
20+
rev: 6.1.0
21+
hooks:
22+
- id: flake8
23+
additional_dependencies:
24+
- flake8-bugbear
25+
- flake8-builtins
26+
- flake8-comprehensions
27+
- flake8-debugger
28+
- flake8-deprecated
29+
- flake8-isort
30+
- flake8-pep3101
31+
- flake8-print
32+
- flake8-quotes
33+
34+
- repo: https://github.com/codespell-project/codespell
35+
rev: v2.2.6
36+
hooks:
37+
- id: codespell
38+
additional_dependencies:
39+
- tomli
40+
- repo: https://github.com/mgedmin/check-manifest
41+
rev: "0.49"
42+
hooks:
43+
- id: check-manifest
44+
- repo: https://github.com/regebro/pyroma
45+
rev: "4.2"
46+
hooks:
47+
- id: pyroma
48+
- repo: https://github.com/mgedmin/check-python-versions
49+
rev: "0.21.3"
50+
hooks:
51+
- id: check-python-versions

CHANGES.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@ Changelog
66
6.1.1 (unreleased)
77
------------------
88

9-
- Nothing changed yet.
9+
- Switch from `setup.cfg` to `setup.py`.
10+
[deronnax]
11+
12+
- Switch from `setuptools` to `hatchling`.
13+
[gforcada]
1014

15+
- Switch to `main` branch.
16+
[gforcada]
17+
18+
- Use `tox` and `pre-commit` to ease project maintenance.
19+
[gforcada]
1120

1221
6.1.0 (2023-09-15)
1322
------------------

flake8_isort.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import warnings
21
from contextlib import redirect_stdout
32
from difflib import unified_diff
4-
from importlib.metadata import PackageNotFoundError, version
3+
from importlib.metadata import PackageNotFoundError
4+
from importlib.metadata import version
55
from io import StringIO
66
from pathlib import Path
77

88
import isort
9+
import warnings
910

1011

1112
def _version():

pyproject.toml

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,61 @@
11
[build-system]
2-
requires = ["setuptools>=61.2"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
44

55
[project]
66
name = "flake8-isort"
77
version = "6.1.1.dev0"
8-
authors = [{ name = "Gil Forcada", email = "gil.gnome@gmail.com" }]
9-
license = { text = "GPL version 2" }
10-
description = "flake8 plugin that integrates isort ."
8+
authors = [
9+
{ name="Gil Forcada Codinachs", email="gil.gnome@gmail.com" },
10+
]
11+
description = "flake8 plugin that integrates isort"
1112
keywords = ["pep8", "flake8", "python", "isort", "imports"]
13+
license = {file = "LICENSE"}
1214
readme = "README.rst"
15+
requires-python = ">=3.8"
1316
classifiers = [
14-
"Development Status :: 5 - Production/Stable",
15-
"Environment :: Console",
16-
"Framework :: Flake8",
17-
"Intended Audience :: Developers",
18-
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
19-
"Operating System :: OS Independent",
20-
"Programming Language :: Python",
21-
"Programming Language :: Python :: 3",
22-
"Programming Language :: Python :: 3 :: Only",
23-
"Programming Language :: Python :: 3.8",
24-
"Programming Language :: Python :: 3.9",
25-
"Programming Language :: Python :: 3.10",
26-
"Programming Language :: Python :: 3.11",
27-
"Programming Language :: Python :: Implementation :: CPython",
28-
"Programming Language :: Python :: Implementation :: PyPy",
29-
"Topic :: Software Development",
30-
"Topic :: Software Development :: Quality Assurance",
17+
"Development Status :: 5 - Production/Stable",
18+
"Environment :: Console",
19+
"Framework :: Flake8",
20+
'Framework :: Plone',
21+
"Intended Audience :: Developers",
22+
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
23+
"Operating System :: OS Independent",
24+
"Programming Language :: Python",
25+
"Programming Language :: Python :: 3",
26+
"Programming Language :: Python :: 3 :: Only",
27+
"Programming Language :: Python :: 3.8",
28+
"Programming Language :: Python :: 3.9",
29+
"Programming Language :: Python :: 3.10",
30+
"Programming Language :: Python :: 3.11",
31+
"Programming Language :: Python :: 3.12",
32+
"Programming Language :: Python :: Implementation :: CPython",
33+
"Programming Language :: Python :: Implementation :: PyPy",
34+
"Topic :: Software Development",
35+
"Topic :: Software Development :: Quality Assurance",
3136
]
32-
urls = { Homepage = "https://github.com/gforcada/flake8-isort" }
33-
requires-python = ">=3.8"
3437
dependencies = ["flake8", "isort >= 5.0.0, <6"]
3538

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

3944
[project.optional-dependencies]
4045
test = ["pytest"]
4146

42-
[tool.setuptools]
43-
py-modules = ["flake8_isort"]
44-
zip-safe = false
45-
include-package-data = true
47+
[project.entry-points."flake8.extension"]
48+
I00 = "flake8_isort:Flake8Isort"
49+
50+
[tool.isort]
51+
profile = "plone"
4652

47-
[tool."zest.releaser"]
48-
create-wheel = "yes"
53+
[tool.black]
54+
target-version = ["py38"]
55+
skip-string-normalization = true
4956

5057
[tool.check-manifest]
51-
ignore = """
52-
.installed.cfg"""
53-
54-
[tool.isort]
55-
profile = "black"
58+
ignore = [
59+
".vscode/*",
60+
"venv/*",
61+
]

requirements-lint.in

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)