Skip to content

Adopt setuptools_scm and pre-commit #126

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

Merged
merged 5 commits into from
Jan 5, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ jobs:
python-version: 3.6
toxenv: py36-test-mpl20
- os: macos-latest
python-version: 3.8
toxenv: py38-test-mpl31
python-version: "3.10"
toxenv: py310-test-mpl35
- os: windows-latest
python-version: 3.6
toxenv: py36-test-mpl20
- os: windows-latest
python-version: 3.8
toxenv: py38-test-mpl31
python-version: "3.10"
toxenv: py310-test-mpl35
# Test all configurations on Linux
- os: ubuntu-latest
python-version: 3.6
Expand All @@ -41,21 +41,25 @@ jobs:
python-version: 3.7
toxenv: py37-test-mpl30
- os: ubuntu-latest
python-version: 3.8
toxenv: py38-test-mpl31
python-version: 3.7
toxenv: py37-test-mpl31
- os: ubuntu-latest
python-version: 3.7
toxenv: py37-test-mpl32
- os: ubuntu-latest
python-version: 3.8
toxenv: py38-test-mpl33
# Code style checks
- os: ubuntu-latest
python-version: 3.8
toxenv: codestyle
python-version: 3.9
toxenv: py39-test-mpl34
- os: ubuntu-latest
python-version: "3.10"
toxenv: py310-test-mpl35

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand All @@ -64,6 +68,3 @@ jobs:
run: python -m pip install tox
- name: Run tox
run: python -m tox -e ${{ matrix.toxenv }}



6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -42,6 +44,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -76,6 +80,8 @@ jobs:
- build_sdist
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
Expand Down
90 changes: 90 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
repos:
# The warnings/errors we check for here are:
# E101 - mix of tabs and spaces
# E11 - Fix indentation.
# E111 - 4 spaces per indentation level
# E112 - 4 spaces per indentation level
# E113 - 4 spaces per indentation level
# E121 - Fix indentation to be a multiple of four.
# E122 - Add absent indentation for hanging indentation.
# E123 - Align closing bracket to match opening bracket.
# E124 - Align closing bracket to match visual indentation.
# E125 - Indent to distinguish line from next logical line.
# E126 - Fix over-indented hanging indentation.
# E127 - Fix visual indentation.
# E128 - Fix visual indentation.
# E129 - Fix visual indentation.
# E131 - Fix hanging indent for unaligned continuation line.
# E133 - Fix missing indentation for closing bracket.
# E20 - Remove extraneous whitespace.
# E211 - Remove extraneous whitespace.
# E231 - Add missing whitespace.
# E241 - Fix extraneous whitespace around keywords.
# E242 - Remove extraneous whitespace around operator.
# E251 - Remove whitespace around parameter '=' sign.
# E252 - Missing whitespace around parameter equals.
# E26 - Fix spacing after comment hash for inline comments.
# E265 - Fix spacing after comment hash for block comments.
# E266 - Fix too many leading '#' for block comments.
# E27 - Fix extraneous whitespace around keywords.
# E301 - Add missing blank line.
# E302 - Add missing 2 blank lines.
# E303 - Remove extra blank lines.
# E304 - Remove blank line following function decorator.
# E305 - expected 2 blank lines after class or function definition
# E305 - Expected 2 blank lines after end of function or class.
# E306 - expected 1 blank line before a nested definition
# E306 - Expected 1 blank line before a nested definition.
# E401 - Put imports on separate lines.
# E402 - Fix module level import not at top of file
# E502 - Remove extraneous escape of newline.
# E701 - Put colon-separated compound statement on separate lines.
# E711 - Fix comparison with None.
# E712 - Fix comparison with boolean.
# E713 - Use 'not in' for test for membership.
# E714 - Use 'is not' test for object identity.
# E722 - Fix bare except.
# E731 - Use a def when use do not assign a lambda expression.
# E901 - SyntaxError or IndentationError
# E902 - IOError
# F822 - undefined name in __all__
# F823 - local variable name referenced before assignment
# W291 - Remove trailing whitespace.
# W292 - Add a single newline at the end of the file.
# W293 - Remove trailing whitespace on blank line.
# W391 - Remove trailing blank lines.
# W601 - Use "in" rather than "has_key()".
# W602 - Fix deprecated form of raising exception.
# W603 - Use "!=" instead of "<>"
# W604 - Use "repr()" instead of backticks.
# W605 - Fix invalid escape sequence 'x'.
# W690 - Fix various deprecated code (via lib2to3).
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
args:
[
"--count",
"--select",
"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",
]
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
args: ["--sp", "setup.cfg"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-ast
- id: check-case-conflict
- id: trailing-whitespace
- id: check-yaml
- id: debug-statements
- id: check-added-large-files
- id: end-of-file-fixer
- id: mixed-line-ending

ci:
autofix_prs: false
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Installing

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

To install, you can do::

Expand Down
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
To make a new release of pytest-mpl follow the following steps:

* Update the chanelog with the date of the release, and ensure that all relevant PRs have changelog entries.
* Update the version number in setup.cfg
* Push the chanelog to master (via a PR)
* Ensure the sdist and wheel GitHub Actions jobs succeeded on master after the merge of the changelog.
* Also ensure that the tarball built has an autogenerated version number from setuptools_scm.
* Tag the new release, using the format `vX.Y.X`.
* Push the tag with `git push upstream master --follow-tags`
* Watch as GitHub actions builds the sdist and universal wheel and pushes them to PyPI for you.
Expand Down
10 changes: 9 additions & 1 deletion pytest_mpl/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
__version__ = '0.12.dev0'
try:
from importlib.metadata import PackageNotFoundError, version
except ImportError:
from importlib_metadata import PackageNotFoundError, version

try:
__version__ = version("pytest_mpl")
except PackageNotFoundError:
__version__ = "unknown"
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[metadata]
license_file = LICENSE
name = pytest-mpl
version = 0.13
url = https://github.com/matplotlib/pytest-mpl
author = Thomas Robitaille
author_email = [email protected]
Expand All @@ -28,6 +27,8 @@ python_requires = >=3.6
install_requires =
pytest
matplotlib
importlib_resources;python_version<'3.8'
packaging

[options.entry_points]
pytest11 =
Expand Down
4 changes: 2 additions & 2 deletions tests/test_pytest_mpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import sys
import json
import subprocess
from packaging.version import Version
from pathlib import Path

import pytest
import matplotlib
import matplotlib.ft2font
import matplotlib.pyplot as plt
import pytest
from packaging.version import Version

MPL_VERSION = Version(matplotlib.__version__)

Expand Down
12 changes: 6 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[tox]
envlist =
py{37,38}-test-mpldev
py{36,37,38}-test-mpl{31,32,33}
py37-test-mpl30
py{36,310}-test-mpldev
py{36,37,38,39,310}-test-mpl{34,35}
py37-test-mpl{30,31,32,33}
py36-test-mpl{20,21,22,30}
codestyle
requires =
setuptools >= 30.3.0
pip >= 19.3.1
isolated_build = true

[testenv]
passenv = DISPLAY WINDIR
Expand Down Expand Up @@ -37,7 +38,6 @@ commands =
skip_install = true
changedir = .
description = check code style, e.g. with flake8
deps = flake8
deps = pre-commit
commands =
flake8 pytest_mpl tests --count --max-line-length=100
python setup.py check --restructuredtext
pre-commit run --all-files