Skip to content

Commit 81e120a

Browse files
authored
Merge pull request #126 from Cadair/setuptools_scm
Adopt setuptools_scm and pre-commit
2 parents 94d732c + c193e6c commit 81e120a

File tree

9 files changed

+130
-24
lines changed

9 files changed

+130
-24
lines changed

.github/workflows/python-package.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ jobs:
1919
python-version: 3.6
2020
toxenv: py36-test-mpl20
2121
- os: macos-latest
22-
python-version: 3.8
23-
toxenv: py38-test-mpl31
22+
python-version: "3.10"
23+
toxenv: py310-test-mpl35
2424
- os: windows-latest
2525
python-version: 3.6
2626
toxenv: py36-test-mpl20
2727
- os: windows-latest
28-
python-version: 3.8
29-
toxenv: py38-test-mpl31
28+
python-version: "3.10"
29+
toxenv: py310-test-mpl35
3030
# Test all configurations on Linux
3131
- os: ubuntu-latest
3232
python-version: 3.6
@@ -41,21 +41,25 @@ jobs:
4141
python-version: 3.7
4242
toxenv: py37-test-mpl30
4343
- os: ubuntu-latest
44-
python-version: 3.8
45-
toxenv: py38-test-mpl31
44+
python-version: 3.7
45+
toxenv: py37-test-mpl31
4646
- os: ubuntu-latest
4747
python-version: 3.7
4848
toxenv: py37-test-mpl32
4949
- os: ubuntu-latest
5050
python-version: 3.8
5151
toxenv: py38-test-mpl33
52-
# Code style checks
5352
- os: ubuntu-latest
54-
python-version: 3.8
55-
toxenv: codestyle
53+
python-version: 3.9
54+
toxenv: py39-test-mpl34
55+
- os: ubuntu-latest
56+
python-version: "3.10"
57+
toxenv: py310-test-mpl35
5658

5759
steps:
5860
- uses: actions/checkout@v2
61+
with:
62+
fetch-depth: 0
5963
- name: Set up Python ${{ matrix.python-version }}
6064
uses: actions/setup-python@v2
6165
with:
@@ -64,6 +68,3 @@ jobs:
6468
run: python -m pip install tox
6569
- name: Run tox
6670
run: python -m tox -e ${{ matrix.toxenv }}
67-
68-
69-

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
1618
- name: Set up Python
1719
uses: actions/setup-python@v2
1820
with:
@@ -42,6 +44,8 @@ jobs:
4244
runs-on: ubuntu-latest
4345
steps:
4446
- uses: actions/checkout@v2
47+
with:
48+
fetch-depth: 0
4549
- name: Set up Python
4650
uses: actions/setup-python@v2
4751
with:
@@ -76,6 +80,8 @@ jobs:
7680
- build_sdist
7781
steps:
7882
- uses: actions/checkout@v2
83+
with:
84+
fetch-depth: 0
7985
- name: Set up Python
8086
uses: actions/setup-python@v2
8187
with:

.pre-commit-config.yaml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
repos:
2+
# The warnings/errors we check for here are:
3+
# E101 - mix of tabs and spaces
4+
# E11 - Fix indentation.
5+
# E111 - 4 spaces per indentation level
6+
# E112 - 4 spaces per indentation level
7+
# E113 - 4 spaces per indentation level
8+
# E121 - Fix indentation to be a multiple of four.
9+
# E122 - Add absent indentation for hanging indentation.
10+
# E123 - Align closing bracket to match opening bracket.
11+
# E124 - Align closing bracket to match visual indentation.
12+
# E125 - Indent to distinguish line from next logical line.
13+
# E126 - Fix over-indented hanging indentation.
14+
# E127 - Fix visual indentation.
15+
# E128 - Fix visual indentation.
16+
# E129 - Fix visual indentation.
17+
# E131 - Fix hanging indent for unaligned continuation line.
18+
# E133 - Fix missing indentation for closing bracket.
19+
# E20 - Remove extraneous whitespace.
20+
# E211 - Remove extraneous whitespace.
21+
# E231 - Add missing whitespace.
22+
# E241 - Fix extraneous whitespace around keywords.
23+
# E242 - Remove extraneous whitespace around operator.
24+
# E251 - Remove whitespace around parameter '=' sign.
25+
# E252 - Missing whitespace around parameter equals.
26+
# E26 - Fix spacing after comment hash for inline comments.
27+
# E265 - Fix spacing after comment hash for block comments.
28+
# E266 - Fix too many leading '#' for block comments.
29+
# E27 - Fix extraneous whitespace around keywords.
30+
# E301 - Add missing blank line.
31+
# E302 - Add missing 2 blank lines.
32+
# E303 - Remove extra blank lines.
33+
# E304 - Remove blank line following function decorator.
34+
# E305 - expected 2 blank lines after class or function definition
35+
# E305 - Expected 2 blank lines after end of function or class.
36+
# E306 - expected 1 blank line before a nested definition
37+
# E306 - Expected 1 blank line before a nested definition.
38+
# E401 - Put imports on separate lines.
39+
# E402 - Fix module level import not at top of file
40+
# E502 - Remove extraneous escape of newline.
41+
# E701 - Put colon-separated compound statement on separate lines.
42+
# E711 - Fix comparison with None.
43+
# E712 - Fix comparison with boolean.
44+
# E713 - Use 'not in' for test for membership.
45+
# E714 - Use 'is not' test for object identity.
46+
# E722 - Fix bare except.
47+
# E731 - Use a def when use do not assign a lambda expression.
48+
# E901 - SyntaxError or IndentationError
49+
# E902 - IOError
50+
# F822 - undefined name in __all__
51+
# F823 - local variable name referenced before assignment
52+
# W291 - Remove trailing whitespace.
53+
# W292 - Add a single newline at the end of the file.
54+
# W293 - Remove trailing whitespace on blank line.
55+
# W391 - Remove trailing blank lines.
56+
# W601 - Use "in" rather than "has_key()".
57+
# W602 - Fix deprecated form of raising exception.
58+
# W603 - Use "!=" instead of "<>"
59+
# W604 - Use "repr()" instead of backticks.
60+
# W605 - Fix invalid escape sequence 'x'.
61+
# W690 - Fix various deprecated code (via lib2to3).
62+
- repo: https://github.com/PyCQA/flake8
63+
rev: 4.0.1
64+
hooks:
65+
- id: flake8
66+
args:
67+
[
68+
"--count",
69+
"--select",
70+
"E101,E11,E111,E112,E113,E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E133,E20,E211,E231,E241,E242,E251,E252,E26,E265,E266,E27,E301,E302,E303,E304,E305,E306,E401,E402,E502,E701,E711,E712,E713,E714,E722,E731,E901,E902,F822,F823,W191,W291,W292,W293,W391,W601,W602,W603,W604,W605,W690",
71+
]
72+
- repo: https://github.com/PyCQA/isort
73+
rev: 5.10.1
74+
hooks:
75+
- id: isort
76+
args: ["--sp", "setup.cfg"]
77+
- repo: https://github.com/pre-commit/pre-commit-hooks
78+
rev: v4.0.1
79+
hooks:
80+
- id: check-ast
81+
- id: check-case-conflict
82+
- id: trailing-whitespace
83+
- id: check-yaml
84+
- id: debug-statements
85+
- id: check-added-large-files
86+
- id: end-of-file-fixer
87+
- id: mixed-line-ending
88+
89+
ci:
90+
autofix_prs: false

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Installing
1818

1919
This plugin is compatible with Python 2.7, and 3.6 and later, and
2020
requires `pytest <http://pytest.org>`__ and
21-
`matplotlib <http://www.matplotlib.org>` to be installed.
21+
`matplotlib <http://www.matplotlib.org>`__ to be installed.
2222

2323
To install, you can do::
2424

RELEASING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
To make a new release of pytest-mpl follow the following steps:
44

55
* Update the chanelog with the date of the release, and ensure that all relevant PRs have changelog entries.
6-
* Update the version number in setup.cfg
76
* Push the chanelog to master (via a PR)
87
* Ensure the sdist and wheel GitHub Actions jobs succeeded on master after the merge of the changelog.
8+
* Also ensure that the tarball built has an autogenerated version number from setuptools_scm.
99
* Tag the new release, using the format `vX.Y.X`.
1010
* Push the tag with `git push upstream master --follow-tags`
1111
* Watch as GitHub actions builds the sdist and universal wheel and pushes them to PyPI for you.

pytest_mpl/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
__version__ = '0.12.dev0'
1+
try:
2+
from importlib.metadata import PackageNotFoundError, version
3+
except ImportError:
4+
from importlib_metadata import PackageNotFoundError, version
5+
6+
try:
7+
__version__ = version("pytest_mpl")
8+
except PackageNotFoundError:
9+
__version__ = "unknown"

setup.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[metadata]
22
license_file = LICENSE
33
name = pytest-mpl
4-
version = 0.13
54
url = https://github.com/matplotlib/pytest-mpl
65
author = Thomas Robitaille
76
author_email = [email protected]
@@ -28,6 +27,8 @@ python_requires = >=3.6
2827
install_requires =
2928
pytest
3029
matplotlib
30+
importlib_resources;python_version<'3.8'
31+
packaging
3132

3233
[options.entry_points]
3334
pytest11 =

tests/test_pytest_mpl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import sys
33
import json
44
import subprocess
5-
from packaging.version import Version
65
from pathlib import Path
76

8-
import pytest
97
import matplotlib
108
import matplotlib.ft2font
119
import matplotlib.pyplot as plt
10+
import pytest
11+
from packaging.version import Version
1212

1313
MPL_VERSION = Version(matplotlib.__version__)
1414

tox.ini

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
[tox]
22
envlist =
3-
py{37,38}-test-mpldev
4-
py{36,37,38}-test-mpl{31,32,33}
5-
py37-test-mpl30
3+
py{36,310}-test-mpldev
4+
py{36,37,38,39,310}-test-mpl{34,35}
5+
py37-test-mpl{30,31,32,33}
66
py36-test-mpl{20,21,22,30}
77
codestyle
88
requires =
99
setuptools >= 30.3.0
1010
pip >= 19.3.1
11+
isolated_build = true
1112

1213
[testenv]
1314
passenv = DISPLAY WINDIR
@@ -37,7 +38,6 @@ commands =
3738
skip_install = true
3839
changedir = .
3940
description = check code style, e.g. with flake8
40-
deps = flake8
41+
deps = pre-commit
4142
commands =
42-
flake8 pytest_mpl tests --count --max-line-length=100
43-
python setup.py check --restructuredtext
43+
pre-commit run --all-files

0 commit comments

Comments
 (0)