Skip to content

Commit 9ea9255

Browse files
authored
Add pre-commit and linting configuration (#104)
Add pre-commit and linting configuration
2 parents 719ba65 + 48dc538 commit 9ea9255

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1311
-956
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+
exclude: doc/en/example/py2py3/test_py2.py
2+
repos:
3+
- repo: https://github.com/python/black
4+
rev: 19.3b0
5+
hooks:
6+
- id: black
7+
args: [--safe, --quiet]
8+
- repo: https://github.com/asottile/blacken-docs
9+
rev: v1.0.0
10+
hooks:
11+
- id: blacken-docs
12+
additional_dependencies: [black==19.3b0]
13+
- repo: https://github.com/pre-commit/pre-commit-hooks
14+
rev: v2.2.3
15+
hooks:
16+
- id: trailing-whitespace
17+
- id: end-of-file-fixer
18+
- id: fix-encoding-pragma
19+
- id: check-yaml
20+
- repo: https://github.com/asottile/reorder_python_imports
21+
rev: v1.4.0
22+
hooks:
23+
- id: reorder-python-imports
24+
args: ['--application-directories=execnet']
25+
- repo: local
26+
hooks:
27+
- id: rst
28+
name: rst
29+
entry: rst-lint --encoding utf-8
30+
files: ^(CHANGELOG.rst|HOWTORELEASE.rst|README.rst)$
31+
language: python
32+
additional_dependencies: [pygments, restructuredtext_lint]

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
- stage: baseline
1717
env: TOXENV=docs
1818
python: '3.6'
19+
- env: TOXENV=linting
20+
python: '3.6'
1921
- env: TOXENV=py27
2022
python: '2.7'
2123
- env: TOXENV=py37

ISSUES.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@ The PID identifies the subprocess which is used for further communication.
1919
Client http-exec subprocess
2020

2121
makegw("...") -> POST /popen -> Popen() with bootstrap
22-
(bootstrap)
22+
(bootstrap)
2323
<- PID
2424

2525
c=rexec(...) POST /exec/PID exec source
26-
(source)
26+
(source)
2727

2828
c.send(1) POST /exec/PID x = c.receive()
2929
(1) assert x == 1
3030
c.send(2)
3131

32-
z = c.receive() GET /exec/PID
32+
z = c.receive() GET /exec/PID
3333
<- (2)
3434
assert z == 2
3535

36-
The client connects via "POST /exec/PID"
37-
and pushes data to the remotely-executing code
36+
The client connects via "POST /exec/PID"
37+
and pushes data to the remotely-executing code
3838
in the subprocess.
3939

40-
The client connects via "GET /exec/PID"
40+
The client connects via "GET /exec/PID"
4141
and receives data from the remotely-executing code.
4242

4343
The client constructs a Channel() object which triggers
@@ -48,21 +48,21 @@ The code executing in the http-execserver controled
4848
subprocess is a PopenGateway. It does not know that it
4949
is connected via the http client/server machinery.
5050

51-
The http-execserver proxies data from the subprocess
51+
The http-execserver proxies data from the subprocess
5252
to the client. If there is no active GET request, the
5353
data is queued.
5454

5555
The http-execserver forwards data from the client to the
56-
subprocess, using the PID. If the subprocess is not
56+
subprocess, using the PID. If the subprocess is not
5757
connected, an ERROR code is returned.
5858

5959
Example session:
6060

6161
gw = group.makegateway("http=codespeak.net")
62-
62+
6363
def fun(channel):
6464
return channel.send(channel.receive()+1)
65-
65+
6666
ch = gw.remote_exec(fun)
6767
ch.send(1)
6868
x = ch.receive()
@@ -121,8 +121,8 @@ tags: 1.1 wish
121121

122122
If using channel.setcallback() it currently is not
123123
possible to notice the exact errors that might happen
124-
on the other side. Either introduce an "errback"
125-
or (probably better) optionally allow an extra 'error'
124+
on the other side. Either introduce an "errback"
125+
or (probably better) optionally allow an extra 'error'
126126
parameter to execnet callbacks.
127127

128128
fix rsync between python/jython

LICENSE

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
66
copies of the Software, and to permit persons to whom the Software is
77
furnished to do so, subject to the following conditions:
8-
8+
99
The above copyright notice and this permission notice shall be included in all
1010
copies or substantial portions of the Software.
11-
11+
1212
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1313
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1414
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1515
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1616
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1717
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1818
SOFTWARE.
19-

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ of the pytest-xdist plugin. Do not use in new projects.**
2222
.. image:: https://ci.appveyor.com/api/projects/status/n9qy8df16my4gds9/branch/master?svg=true
2323
:target: https://ci.appveyor.com/project/pytestbot/execnet
2424

25+
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
26+
:target: https://github.com/python/black
27+
2528
.. _execnet: http://codespeak.net/execnet
2629

2730
execnet_ provides carefully tested means to ad-hoc interact with Python

doc/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
# -*- coding: utf-8 -*-
12
#

doc/basics.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,3 @@ For more examples see :ref:`dumps/loads examples`.
246246

247247
.. autofunction:: execnet.dumps(spec)
248248
.. autofunction:: execnet.loads(spec)
249-

doc/conf.py

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,40 @@
1010
#
1111
# All configuration values have a default; values that are commented out
1212
# serve to show the default.
13-
14-
import sys
1513
import os
14+
import sys
15+
1616
# If extensions (or modules to document with autodoc) are in another directory,
1717
# add these directories to sys.path here. If the directory is relative to the
1818
# documentation root, use os.path.abspath to make it absolute, like shown here.
1919
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
2020

21+
from execnet._version import version
22+
23+
release = ".".join(version.split(".")[:2])
24+
2125
# -- General configuration ----------------------------------------------------
2226

2327
# Add any Sphinx extension module names here, as strings.
2428
# They can be extensions
2529
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
26-
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest']
30+
extensions = ["sphinx.ext.autodoc", "sphinx.ext.doctest"]
2731

2832
# Add any paths that contain templates here, relative to this directory.
29-
templates_path = ['_templates']
33+
templates_path = ["_templates"]
3034

3135
# The suffix of source filenames.
32-
source_suffix = '.rst'
36+
source_suffix = ".rst"
3337

3438
# The encoding of source files.
3539
# source_encoding = 'utf-8'
3640

3741
# The master toctree document.
38-
master_doc = 'index'
42+
master_doc = "index"
3943

4044
# General information about the project.
41-
project = 'execnet'
42-
copyright = '2012, holger krekel and others'
43-
44-
# The version info for the project you're documenting, acts as replacement for
45-
# |version| and |release|, also used in various other places throughout the
46-
# built documents.
47-
#
48-
# The short X.Y version.
49-
version = '1.4'
50-
# The full version, inpipcluding alpha/beta/rc tags.
51-
release = '1.4.0.dev1'
45+
project = "execnet"
46+
copyright = "2012, holger krekel and others"
5247

5348
# The language for content autogenerated by Sphinx. Refer to documentation
5449
# for a list of supported languages.
@@ -65,7 +60,7 @@
6560

6661
# List of directories, relative to source directory, that shouldn't be searched
6762
# for source files.
68-
exclude_trees = ['_build']
63+
exclude_trees = ["_build"]
6964

7065
# The reST default role (used for this markup: `text`) to use for all documents
7166
# dfault_role = None
@@ -84,7 +79,7 @@
8479
# show_authors = False
8580

8681
# The name of the Pygments (syntax highlighting) style to use.
87-
pygments_style = 'sphinx'
82+
pygments_style = "sphinx"
8883

8984
# A list of ignored prefixes for module index sorting.
9085
# modindex_common_prefix = []
@@ -94,12 +89,10 @@
9489

9590
# The theme to use for HTML and HTML Help pages. Major themes that come with
9691
# Sphinx are currently 'default' and 'sphinxdoc'.
97-
html_theme = 'sphinxdoc'
92+
html_theme = "sphinxdoc"
9893

9994
# html_index = 'index.html'
100-
html_sidebars = {
101-
'index': ['indexsidebar.html'],
102-
}
95+
html_sidebars = {"index": ["indexsidebar.html"]}
10396
# html_additional_pages = {'index': 'index.html'}
10497

10598
# Theme options are theme-specific and customize the look and feel of a theme
@@ -129,7 +122,7 @@
129122
# Add any paths that contain custom static files (such as style sheets) here,
130123
# relative to this directory. They are copied after the builtin static files,
131124
# so a file named "default.css" will overwrite the builtin "default.css".
132-
html_static_path = ['_static']
125+
html_static_path = ["_static"]
133126

134127
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
135128
# using the given strftime format.
@@ -160,7 +153,7 @@
160153
# html_file_suffix = ''
161154

162155
# Output file base name for HTML help builder.
163-
htmlhelp_basename = 'execnetdoc'
156+
htmlhelp_basename = "execnetdoc"
164157

165158

166159
# -- Options for LaTeX output -------------------------------------------------
@@ -174,8 +167,13 @@
174167
# Grouping the document tree into LaTeX files. List of tuples
175168
# (source start file, target name, title, author, documentclass [howto/manual])
176169
latex_documents = [
177-
('index', 'execnet.tex', 'execnet Documentation',
178-
'holger krekel and others', 'manual'),
170+
(
171+
"index",
172+
"execnet.tex",
173+
"execnet Documentation",
174+
"holger krekel and others",
175+
"manual",
176+
)
179177
]
180178

181179
# The name of an image file (relative to this directory) to place at the top of

doc/example/conftest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
# -*- coding: utf-8 -*-
2+
import sys
13

2-
import py, sys
4+
import py
35

46
# make execnet and example code importable
57
cand = py.path.local(__file__).dirpath().dirpath().dirpath()
@@ -10,4 +12,4 @@
1012
if str(cand) not in sys.path:
1113
sys.path.insert(0, str(cand))
1214

13-
pytest_plugins = ['doctest']
15+
pytest_plugins = ["doctest"]

doc/example/funcmultiplier.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
1+
# -*- coding: utf-8 -*-
22
import execnet
33

4+
45
def multiplier(channel, factor):
56
while not channel.isclosed():
67
param = channel.receive()
78
channel.send(param * factor)
89

10+
911
gw = execnet.makegateway()
1012
channel = gw.remote_exec(multiplier, factor=10)
1113

0 commit comments

Comments
 (0)