Skip to content

Commit 868d09c

Browse files
authored
Feature/black format (#120)
* using `black` formatting * adding `pre-commit` hooks for black
1 parent 7360fe4 commit 868d09c

17 files changed

+625
-377
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
repos:
2+
3+
# Automatic source code formatting
4+
- repo: https://github.com/psf/black
5+
rev: stable
6+
hooks:
7+
- id: black
8+
args: [--safe, --quiet]

.travis.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,16 @@ jobs:
3535
- python: "pypy2.7-5.10.0"
3636
- python: "pypy3.5-5.10.0"
3737
- stage: lint
38-
name: "pylint"
38+
name: "black"
39+
python:
40+
- 3.6
41+
before_install:
42+
- pip install black
43+
before_script: skip
44+
script:
45+
- black --check setup.py tests graypy
46+
after_script: skip
47+
- name: "pylint"
3948
python:
4049
- 3.6
4150
before_script: skip

docs/conf.py

Lines changed: 58 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
# -- Project information -----------------------------------------------------
1111

12-
copyright = '2019, Sever Băneşiu, Nathan Klapstein'
13-
author = 'Sever Băneşiu, Nathan Klapstein'
12+
copyright = "2019, Sever Băneşiu, Nathan Klapstein"
13+
author = "Sever Băneşiu, Nathan Klapstein"
1414
project = "graypy"
1515

1616

@@ -19,7 +19,9 @@ def find_version(*file_paths):
1919
import os
2020
import re
2121

22-
with codecs.open(os.path.join(os.path.abspath(os.path.dirname(__file__)), *file_paths), 'r') as fp:
22+
with codecs.open(
23+
os.path.join(os.path.abspath(os.path.dirname(__file__)), *file_paths), "r"
24+
) as fp:
2325
version_file = fp.read()
2426
m = re.search(r"^__version__ = \((\d+), ?(\d+), ?(\d+)\)", version_file, re.M)
2527
if m:
@@ -35,15 +37,15 @@ def find_version(*file_paths):
3537
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3638
# ones.
3739
extensions = [
38-
'sphinx.ext.autodoc',
39-
'sphinx.ext.viewcode',
40+
"sphinx.ext.autodoc",
41+
"sphinx.ext.viewcode",
4042
"sphinx.ext.intersphinx",
4143
"sphinx_autodoc_typehints",
4244
]
4345

44-
source_suffix = '.rst'
46+
source_suffix = ".rst"
4547

46-
master_doc = 'index'
48+
master_doc = "index"
4749

4850
# The language for content autogenerated by Sphinx. Refer to documentation
4951
# for a list of supported languages.
@@ -55,37 +57,37 @@ def find_version(*file_paths):
5557
# List of patterns, relative to source directory, that match files and
5658
# directories to ignore when looking for source files.
5759
# This pattern also affects html_static_path and html_extra_path .
58-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
60+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
5961

6062
# The name of the Pygments (syntax highlighting) style to use.
61-
pygments_style = 'sphinx'
63+
pygments_style = "sphinx"
6264

6365

6466
# -- Options for HTML output -------------------------------------------------
6567

6668
# The theme to use for HTML and HTML Help pages. See the documentation for
6769
# a list of builtin themes.
6870
#
69-
html_theme = 'sphinx_rtd_theme'
71+
html_theme = "sphinx_rtd_theme"
7072

7173
html_theme_options = {
72-
'logo_only': False,
73-
'display_version': True,
74-
'prev_next_buttons_location': 'bottom',
75-
'style_external_links': False,
74+
"logo_only": False,
75+
"display_version": True,
76+
"prev_next_buttons_location": "bottom",
77+
"style_external_links": False,
7678
# Toc options
77-
'collapse_navigation': True,
78-
'sticky_navigation': True,
79-
'navigation_depth': 4,
80-
'includehidden': True,
81-
'titles_only': False
79+
"collapse_navigation": True,
80+
"sticky_navigation": True,
81+
"navigation_depth": 4,
82+
"includehidden": True,
83+
"titles_only": False,
8284
}
8385

8486

8587
# -- Options for HTMLHelp output ---------------------------------------------
8688

8789
# Output file base name for HTML help builder.
88-
htmlhelp_basename = 'graypydoc'
90+
htmlhelp_basename = "graypydoc"
8991

9092

9193
# -- Options for LaTeX output ------------------------------------------------
@@ -94,72 +96,85 @@ def find_version(*file_paths):
9496
# The paper size ('letterpaper' or 'a4paper').
9597
#
9698
# 'papersize': 'letterpaper',
97-
9899
# The font size ('10pt', '11pt' or '12pt').
99100
#
100101
# 'pointsize': '10pt',
101-
102102
# Additional stuff for the LaTeX preamble.
103103
#
104104
# 'preamble': '',
105-
106105
# Latex figure (float) alignment
107106
#
108107
# 'figure_align': 'htbp',
109108
}
110109

111110
# Grouping the document tree into LaTeX files. List of tuples
112-
# (source start file, target name, title,
113-
# author, documentclass [howto, manual, or own class]).
114-
latex_documents = [
115-
(master_doc, 'graypy.tex', 'graypy Documentation',
116-
author, 'manual'),
117-
]
111+
# (source start file, target name, title, author, documentclass [howto, manual, or own class]).
112+
latex_documents = [(master_doc, "graypy.tex", "graypy Documentation", author, "manual")]
118113

119114

120115
# -- Options for manual page output ------------------------------------------
121116

122117
# One entry per manual page. List of tuples
123118
# (source start file, name, description, authors, manual section).
124-
man_pages = [
125-
(master_doc, 'graypy', 'graypy Documentation', author.split(", "), 1)
126-
]
119+
man_pages = [(master_doc, "graypy", "graypy Documentation", author.split(", "), 1)]
127120

128121

129122
# -- Options for Texinfo output ----------------------------------------------
130123

131124
# Grouping the document tree into Texinfo files. List of tuples
132-
# (source start file, target name, title, author,
133-
# dir menu entry, description, category)
125+
# (
126+
# source start file,
127+
# target name,
128+
# title,
129+
# author,
130+
# dir menu entry,
131+
# description,
132+
# category
133+
# )
134134
texinfo_documents = [
135-
(master_doc, 'graypy', 'graypy Documentation', author, 'graypy',
136-
'Python logging handlers that send messages in the Graylog Extended Log Format (GELF).',
137-
'Miscellaneous'),
135+
(
136+
master_doc,
137+
"graypy",
138+
"graypy Documentation",
139+
author,
140+
"graypy",
141+
"Python logging handlers that send messages in the Graylog Extended Log Format (GELF).",
142+
"Miscellaneous",
143+
)
138144
]
139145

140146

141147
# -- Extension configuration -------------------------------------------------
142148

143149
intersphinx_mapping = {
144-
'python': ('https://docs.python.org/3', (None, 'python-inv.txt')),
150+
"python": ("https://docs.python.org/3", (None, "python-inv.txt"))
145151
}
146152

147153

148154
# -- auto api docs generation --
149155

150156
# order auto doc members by position in source code
151-
autodoc_member_order = 'bysource'
157+
autodoc_member_order = "bysource"
152158

153159

154160
def run_apidoc(_):
155161
from sphinx.ext.apidoc import main
156162
import os
157163
import sys
158-
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
164+
165+
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
159166
cur_dir = os.path.abspath(os.path.dirname(__file__))
160167
module = os.path.join(cur_dir, "..", "graypy")
161-
main(["--module-first", "--separate", "--implicit-namespaces", module,
162-
"--output-dir", os.path.join(cur_dir, "api")])
168+
main(
169+
[
170+
"--module-first",
171+
"--separate",
172+
"--implicit-namespaces",
173+
module,
174+
"--output-dir",
175+
os.path.join(cur_dir, "api"),
176+
]
177+
)
163178

164179

165180
def skip(app, what, name, obj, would_skip, options):
@@ -169,5 +184,5 @@ def skip(app, what, name, obj, would_skip, options):
169184

170185

171186
def setup(app):
172-
app.connect('builder-inited', run_apidoc)
187+
app.connect("builder-inited", run_apidoc)
173188
app.connect("autodoc-skip-member", skip)

graypy/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@
1111
+ :mod:`.rabbitmq` - RabbitMQ GELF Logging Handler
1212
"""
1313

14-
from graypy.handler import GELFUDPHandler, GELFTCPHandler, GELFTLSHandler, \
15-
GELFHTTPHandler, WAN_CHUNK, LAN_CHUNK
14+
from graypy.handler import (
15+
GELFUDPHandler,
16+
GELFTCPHandler,
17+
GELFTLSHandler,
18+
GELFHTTPHandler,
19+
WAN_CHUNK,
20+
LAN_CHUNK,
21+
)
1622

1723
try:
1824
from graypy.rabbitmq import GELFRabbitHandler, ExcludeFilter

0 commit comments

Comments
 (0)