Skip to content

Commit 73502f1

Browse files
committed
Adopt setuptools_scm and pre-commit
1 parent 94d732c commit 73502f1

File tree

7 files changed

+106
-15
lines changed

7 files changed

+106
-15
lines changed

.github/workflows/python-package.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ jobs:
4949
- os: ubuntu-latest
5050
python-version: 3.8
5151
toxenv: py38-test-mpl33
52-
# Code style checks
53-
- os: ubuntu-latest
54-
python-version: 3.8
55-
toxenv: codestyle
5652

5753
steps:
5854
- uses: actions/checkout@v2
@@ -64,6 +60,3 @@ jobs:
6460
run: python -m pip install tox
6561
- name: Run tox
6662
run: python -m tox -e ${{ matrix.toxenv }}
67-
68-
69-

.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

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: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ commands =
3737
skip_install = true
3838
changedir = .
3939
description = check code style, e.g. with flake8
40-
deps = flake8
40+
deps = pre-commit
4141
commands =
42-
flake8 pytest_mpl tests --count --max-line-length=100
43-
python setup.py check --restructuredtext
42+
pre-commit run --all-files

0 commit comments

Comments
 (0)