Skip to content

Commit 6587ed0

Browse files
author
goodboy
authored
Merge pull request #169 from nicoddemus/pre-commit-black
Add pre-commit for style checks and use black as formatter
2 parents 962d674 + 9940cf2 commit 6587ed0

34 files changed

+446
-285
lines changed

.pre-commit-config.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
repos:
2+
- repo: https://github.com/ambv/black
3+
rev: 18.6b4
4+
hooks:
5+
- id: black
6+
args: [--safe, --quiet]
7+
language_version: python3.6
8+
- repo: https://github.com/asottile/blacken-docs
9+
rev: v0.2.0
10+
hooks:
11+
- id: blacken-docs
12+
additional_dependencies: [black==18.6b4]
13+
language_version: python3.6
14+
- repo: https://github.com/pre-commit/pre-commit-hooks
15+
rev: v1.3.0
16+
hooks:
17+
- id: trailing-whitespace
18+
- id: end-of-file-fixer
19+
- id: flake8
20+
- repo: local
21+
hooks:
22+
- id: rst
23+
name: rst
24+
entry: rst-lint --encoding utf-8
25+
files: ^(CHANGELOG.rst|HOWTORELEASE.rst|README.rst|changelog/.*)$
26+
language: python
27+
additional_dependencies: [pygments, restructuredtext_lint]
28+
python_version: python3.6
29+
- repo: https://github.com/pre-commit/pygrep-hooks
30+
rev: v1.0.0
31+
hooks:
32+
- id: rst-backticks

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ language: python
44
jobs:
55
include:
66
- python: '3.6'
7-
env: TOXENV=check
7+
env: TOXENV=linting
88
- python: '3.6'
99
env: TOXENV=docs
1010
- python: '2.7'

HOWTORELEASE.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@ Release Procedure
2121
#. Make sure it is `available on PyPI <https://pypi.org/project/pluggy>`_.
2222

2323
#. Merge the PR into ``master``, either manually or using GitHub's web interface.
24-

LICENSE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 holger krekel (rather uses bitbucket/hpk42)
3+
Copyright (c) 2015 holger krekel (rather uses bitbucket/hpk42)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22-

README.rst

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pluggy - A minimalist production ready plugin system
33
====================================================
44

5-
|pypi| |anaconda| |versions| |travis| |appveyor| |gitter|
5+
|pypi| |anaconda| |versions| |travis| |appveyor| |gitter| |black|
66

77
This is the core framework used by the `pytest`_, `tox`_, and `devpi`_ projects.
88

@@ -21,6 +21,7 @@ A definitive example
2121
class MySpec(object):
2222
"""A hook specification namespace.
2323
"""
24+
2425
@hookspec
2526
def myhook(self, arg1, arg2):
2627
"""My special little hook that you can customize.
@@ -30,6 +31,7 @@ A definitive example
3031
class Plugin_1(object):
3132
"""A hook implementation namespace.
3233
"""
34+
3335
@hookimpl
3436
def myhook(self, arg1, arg2):
3537
print("inside Plugin_1.myhook()")
@@ -39,6 +41,7 @@ A definitive example
3941
class Plugin_2(object):
4042
"""A 2nd hook implementation namespace.
4143
"""
44+
4245
@hookimpl
4346
def myhook(self, arg1, arg2):
4447
print("inside Plugin_2.myhook()")
@@ -53,25 +56,34 @@ A definitive example
5356
pm.register(Plugin_1())
5457
pm.register(Plugin_2())
5558
56-
# call our `myhook` hook
59+
# call our ``myhook`` hook
5760
results = pm.hook.myhook(arg1=1, arg2=2)
5861
print(results)
5962
6063
6164
.. badges
65+
6266
.. |pypi| image:: https://img.shields.io/pypi/v/pluggy.svg
6367
:target: https://pypi.org/pypi/pluggy
68+
6469
.. |versions| image:: https://img.shields.io/pypi/pyversions/pluggy.svg
6570
:target: https://pypi.org/pypi/pluggy
71+
6672
.. |travis| image:: https://img.shields.io/travis/pytest-dev/pluggy/master.svg
6773
:target: https://travis-ci.org/pytest-dev/pluggy
74+
6875
.. |appveyor| image:: https://img.shields.io/appveyor/ci/pytestbot/pluggy/master.svg
6976
:target: https://ci.appveyor.com/project/pytestbot/pluggy
77+
7078
.. |anaconda| image:: https://anaconda.org/conda-forge/pluggy/badges/version.svg
71-
:target: https://anaconda.org/conda-forge/pluggy
79+
:target: https://anaconda.org/conda-forge/pluggy
80+
7281
.. |gitter| image:: https://badges.gitter.im/pytest-dev/pluggy.svg
7382
:alt: Join the chat at https://gitter.im/pytest-dev/pluggy
74-
:target: https://gitter.im/pytest-dev/pluggy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
83+
:target: https://gitter.im/pytest-dev/pluggy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
84+
85+
.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
86+
:target: https://github.com/ambv/black
7587

7688
.. links
7789
.. _pytest:

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
environment:
22
matrix:
33
# note: please use "tox --listenvs" to populate the build matrix below
4-
- TOXENV: "check"
4+
- TOXENV: "linting"
55
- TOXENV: "docs"
66
- TOXENV: "py27-pytestrelease"
77
- TOXENV: "py34-pytestrelease"

changelog/165.trivial.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Add changelog in long package description and documentation.
1+
Add changelog in long package description and documentation.

docs/conf.py

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,54 @@
33

44

55
extensions = [
6-
'sphinx.ext.autodoc',
7-
'sphinx.ext.doctest',
8-
'sphinx.ext.intersphinx',
9-
'sphinx.ext.coverage',
10-
'sphinx.ext.viewcode',
6+
"sphinx.ext.autodoc",
7+
"sphinx.ext.doctest",
8+
"sphinx.ext.intersphinx",
9+
"sphinx.ext.coverage",
10+
"sphinx.ext.viewcode",
1111
]
1212

1313
# Add any paths that contain templates here, relative to this directory.
14-
templates_path = ['_templates']
14+
templates_path = ["_templates"]
1515

16-
source_suffix = '.rst'
16+
source_suffix = ".rst"
1717

1818
# The master toctree document.
19-
master_doc = 'index'
19+
master_doc = "index"
2020

2121
# General information about the project.
2222

23-
dist = pkg_resources.get_distribution('pluggy')
23+
dist = pkg_resources.get_distribution("pluggy")
2424
project = dist.project_name
25-
copyright = u'2016, Holger Krekel'
26-
author = 'Holger Krekel'
25+
copyright = u"2016, Holger Krekel"
26+
author = "Holger Krekel"
2727

2828
release = dist.version
2929
# The short X.Y version.
30-
version = u'.'.join(dist.version.split('.')[:2])
30+
version = u".".join(dist.version.split(".")[:2])
3131

3232

3333
language = None
3434

35-
pygments_style = 'sphinx'
36-
html_logo = '_static/img/plug.png'
37-
html_theme = 'alabaster'
35+
pygments_style = "sphinx"
36+
html_logo = "_static/img/plug.png"
37+
html_theme = "alabaster"
3838
html_theme_options = {
3939
# 'logo': 'img/plug.png',
4040
# 'logo_name': 'true',
41-
'description': 'The `pytest` plugin system',
42-
'github_user': 'pytest-dev',
43-
'github_repo': 'pluggy',
44-
'github_button': 'true',
45-
'github_banner': 'true',
46-
'page_width': '1080px',
47-
'fixed_sidebar': 'false',
41+
"description": "The `pytest` plugin system",
42+
"github_user": "pytest-dev",
43+
"github_repo": "pluggy",
44+
"github_button": "true",
45+
"github_banner": "true",
46+
"page_width": "1080px",
47+
"fixed_sidebar": "false",
4848
}
49-
html_static_path = ['_static']
49+
html_static_path = ["_static"]
5050

5151
# One entry per manual page. List of tuples
5252
# (source start file, name, description, authors, manual section).
53-
man_pages = [
54-
(master_doc, 'pluggy', u'pluggy Documentation',
55-
[author], 1)
56-
]
53+
man_pages = [(master_doc, "pluggy", u"pluggy Documentation", [author], 1)]
5754

5855

5956
# -- Options for Texinfo output -------------------------------------------
@@ -62,10 +59,16 @@
6259
# (source start file, target name, title, author,
6360
# dir menu entry, description, category)
6461
texinfo_documents = [
65-
(master_doc, 'pluggy', u'pluggy Documentation',
66-
author, 'pluggy', 'One line description of project.',
67-
'Miscellaneous'),
62+
(
63+
master_doc,
64+
"pluggy",
65+
u"pluggy Documentation",
66+
author,
67+
"pluggy",
68+
"One line description of project.",
69+
"Miscellaneous",
70+
)
6871
]
6972

7073
# Example configuration for intersphinx: refer to the Python standard library.
71-
intersphinx_mapping = {'https://docs.python.org/': None}
74+
intersphinx_mapping = {"https://docs.python.org/": None}

docs/examples/eggsample-spam/eggsample_spam.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import eggsample
22

3+
34
@eggsample.hookimpl
45
def eggsample_add_ingredients(ingredients):
56
"""Here the caller expects us to return a list."""
@@ -9,12 +10,13 @@ def eggsample_add_ingredients(ingredients):
910
spam = ["splendiferous spam", "magnificent spam"]
1011
return spam
1112

13+
1214
@eggsample.hookimpl
1315
def eggsample_prep_condiments(condiments):
1416
"""Here the caller passes a mutable object, so we mess with it directly."""
1517
try:
1618
del condiments["steak sauce"]
1719
except KeyError:
1820
pass
19-
condiments['spam sauce'] = 42
21+
condiments["spam sauce"] = 42
2022
return f"Now this is what I call a condiments tray!"

docs/examples/eggsample-spam/setup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from setuptools import setup
22

3-
setup(name="eggsample-spam", install_requires="eggsample",
4-
entry_points={'eggsample': ['spam = eggsample_spam']},
5-
py_modules=['eggsample_spam'])
3+
setup(
4+
name="eggsample-spam",
5+
install_requires="eggsample",
6+
entry_points={"eggsample": ["spam = eggsample_spam"]},
7+
py_modules=["eggsample_spam"],
8+
)

0 commit comments

Comments
 (0)