Skip to content

Commit 8e37580

Browse files
committed
[#3287] fix pycodestyle warnings
- E111 indentation is not a multiple of 4 - E117 over-indented - E125 continuation line with same indent as next logical line - E127 continuation line over-indented for visual indent - E128 continuation line under-indented for visual indent - E129 visually indented line with same indent as next logical line - E131 continuation line unaligned for hanging indent - E201 whitespace after '[' - E201 whitespace after '{' - E202 whitespace before ')' - E202 whitespace before ']' - E202 whitespace before '}' - E203 whitespace before ' - E203 whitespace before ',' - E222 multiple spaces after operator - E225 missing whitespace around operator - E228 missing whitespace around modulo operator - E231 missing whitespace after ',' - E251 unexpected spaces around keyword / parameter equals - E261 at least two spaces before inline comment - E262 inline comment should start with '# ' - E265 block comment should start with '# ' - E301 expected 1 blank line, found 0 - E302 expected 2 blank lines, found 1 - E303 too many blank lines (2) - E305 expected 2 blank lines after class or function definition, found 1 - E306 expected 1 blank line before a nested definition, found 0 - E401 multiple imports on one line - E402 module level import not at top of file - E501 line too long - E502 the backslash is redundant between brackets - E703 statement ends with a semicolon - E713 test for membership should be 'not in' - E722 do not use bare 'except' - E741 ambiguous variable name 'l' - W605 invalid escape sequence '\/'
1 parent c0acd78 commit 8e37580

File tree

13 files changed

+340
-242
lines changed

13 files changed

+340
-242
lines changed

doc/sphinx/api2doc.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def read_input_files(files):
3838
# use OrderedDict to preserve order of fields in cmd-syntax
3939
try:
4040
descr = json.load(fp, object_pairs_hook=collections.OrderedDict)
41-
except:
42-
print('\nError while processing %s\n\n' % f)
41+
except Exception as e:
42+
print(f'\nError while processing {f}: {e}\n\n')
4343
raise
4444
if name != descr['name']:
4545
exit("Expected name == descr['name'], but name is {name} and descr['name'] is {descr['name']}")
@@ -78,14 +78,14 @@ def generate_rst(apis):
7878
for dm, funcs in sorted(daemons.items()):
7979
rst += '.. _commands-%s:\n\n' % dm
8080
rst += 'Commands supported by `%s` daemon: ' % dm
81-
funcs = sorted([ ':ref:`%s <ref-%s>`' % (f['name'], f['name']) for f in funcs])
81+
funcs = sorted([':ref:`%s <ref-%s>`' % (f['name'], f['name']) for f in funcs])
8282
rst += ', '.join(funcs)
8383
rst += '.\n\n'
8484

8585
for h, funcs in sorted(hooks.items()):
8686
rst += '.. _commands-%s:\n\n' % h
8787
rst += 'Commands supported by `%s` hook library: ' % h
88-
funcs = sorted([ ':ref:`%s <ref-%s>`' % (f['name'], f['name']) for f in funcs])
88+
funcs = sorted([':ref:`%s <ref-%s>`' % (f['name'], f['name']) for f in funcs])
8989
rst += ', '.join(funcs)
9090
rst += '.\n\n'
9191

@@ -112,16 +112,16 @@ def generate_rst(apis):
112112

113113
# availability
114114
rst += 'Availability: %s ' % func['avail']
115-
rst += '(:ref:`%s <commands-%s>` hook library)' % (func['hook'], func['hook']) if 'hook' in func else '(built-in)'
115+
rst += f'(:ref:`{func["hook"]} <commands-{func["hook"]}>` hook library)' if 'hook' in func else '(built-in)'
116116
rst += '\n\n'
117117

118118
# access
119119
try:
120120
access = func['access']
121-
except:
122-
print('\naccess missing in %s\n\n' % name)
121+
except Exception as e:
122+
print(f'\naccess missing in {name}: {e}\n\n')
123123
raise
124-
if not access in ['read', 'write']:
124+
if access not in ['read', 'write']:
125125
print('\nUnknown access %s in %s\n\n' % (access, name))
126126
raise ValueError('access must be read or write')
127127
rst += 'Access: %s *(parameter ignored in this Kea version)* \n\n' % access
@@ -151,8 +151,8 @@ def generate_rst(apis):
151151
rst += '\n\n'
152152

153153
if 'cmd-comment' in func:
154-
for l in func['cmd-comment']:
155-
rst += "%s\n" % l
154+
for line in func['cmd-comment']:
155+
rst += "%s\n" % line
156156
rst += '\n'
157157

158158
# response syntax
@@ -184,7 +184,8 @@ def generate_rst(apis):
184184
rst += '- 1 - error\n'
185185
rst += '- 2 - unsupported\n'
186186
rst += '- 3 - empty (command was completed successfully, but no data was affected or returned)\n'
187-
rst += '- 4 - conflict (command could not apply requested configuration changes because they were in conflict with the server state)\n\n'
187+
rst += '- 4 - conflict (command could not apply requested configuration changes because they were '
188+
rst += 'in conflict with the server state)\n\n'
188189

189190
return rst
190191

doc/sphinx/conf.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# import sys
1717
# sys.path.insert(0, os.path.abspath('.'))
1818

19-
# to avoid "sphinx.errors.SphinxParallelError: RecursionError: maximum recursion depth exceeded while pickling an object"
19+
# to avoid sphinx.errors.SphinxParallelError: RecursionError: maximum recursion depth exceeded while pickling an object
2020
import sys
2121
sys.setrecursionlimit(5000)
2222

@@ -45,7 +45,7 @@
4545
release = candidate_release
4646
break
4747
version = release
48-
dashed_version_series='-'.join(version.split('.')[0:2])
48+
dashed_version_series = '-'.join(version.split('.')[0:2])
4949

5050
# now let's replace versions with odd minor number with dev
5151
if int(dashed_version_series[-1]) % 2 != 0:
@@ -146,17 +146,17 @@
146146
# The theme to use for HTML and HTML Help pages. See the documentation for
147147
# a list of builtin themes.
148148
#
149-
#html_theme = 'alabaster'
149+
# html_theme = 'alabaster'
150150
html_theme = 'sphinx_rtd_theme'
151151
html_logo = 'static/kea-imageonly-100bw.png'
152152

153153
# Theme options are theme-specific and customize the look and feel of a theme
154154
# further. For a list of options available for each theme, see the
155155
# documentation.
156156
#
157-
#html_theme_options = {
158-
# "logo": "kea-logo-100x70.png",
159-
#}
157+
# html_theme_options = {
158+
# "logo": "kea-logo-100x70.png",
159+
# }
160160

161161
# Add any paths that contain custom static files (such as style sheets) here,
162162
# relative to this directory. They are copied after the builtin static files,
@@ -177,7 +177,7 @@
177177
# -- Options for HTMLHelp output ---------------------------------------------
178178

179179
# Output file base name for HTML help builder.
180-
#htmlhelp_basename = 'KeaAdministratorReferenceManualdoc'
180+
# htmlhelp_basename = 'KeaAdministratorReferenceManualdoc'
181181

182182

183183
# -- Options for LaTeX output ------------------------------------------------
@@ -241,10 +241,11 @@
241241

242242
# -- Substitutions -----------------------------------------------------------
243243

244-
rst_prolog="""
244+
rst_prolog = """
245245
.. |cloudsmith_repo| replace:: kea-{dashed_version_series}
246246
""".format(dashed_version_series=dashed_version_series)
247247

248+
248249
# -- Functions ---------------------------------------------------------------
249250

250251
# Do generation of api.rst and kea-messages.rst here in conf.py instead of Makefile.am
@@ -278,17 +279,17 @@ def run_generate_docs(_):
278279
# The first entry on this list is the actual file to copy, the second is a unique name
279280
# that will be used when copied over to arm/ directory.
280281
FILES_TO_COPY = [
281-
[ '../../platforms.rst', 'platforms.rst' ],
282-
[ '../examples/template-power-user-home/info.md', 'template-power-user-home.md' ],
283-
[ '../examples/template-power-user-home/kea-ca-1.conf', 'template-power-user-home-ca-1.conf' ],
284-
[ '../examples/template-power-user-home/kea-ca-2.conf', 'template-power-user-home-ca-2.conf' ],
285-
[ '../examples/template-power-user-home/kea-dhcp4-1.conf', 'template-power-user-home-dhcp4-1.conf' ],
286-
[ '../examples/template-power-user-home/kea-dhcp4-2.conf', 'template-power-user-home-dhcp4-2.conf' ],
287-
[ '../examples/template-ha-mt-tls/info.md', 'template-ha-mt-tls.md' ],
288-
[ '../examples/template-ha-mt-tls/kea-ca-1.conf', 'template-ha-mt-tls-ca-1.conf' ],
289-
[ '../examples/template-ha-mt-tls/kea-ca-2.conf', 'template-ha-mt-tls-ca-2.conf' ],
290-
[ '../examples/template-ha-mt-tls/kea-dhcp4-1.conf', 'template-ha-mt-tls-dhcp4-1.conf' ],
291-
[ '../examples/template-ha-mt-tls/kea-dhcp4-2.conf', 'template-ha-mt-tls-dhcp4-2.conf' ]
282+
['../../platforms.rst', 'platforms.rst'],
283+
['../examples/template-power-user-home/info.md', 'template-power-user-home.md'],
284+
['../examples/template-power-user-home/kea-ca-1.conf', 'template-power-user-home-ca-1.conf'],
285+
['../examples/template-power-user-home/kea-ca-2.conf', 'template-power-user-home-ca-2.conf'],
286+
['../examples/template-power-user-home/kea-dhcp4-1.conf', 'template-power-user-home-dhcp4-1.conf'],
287+
['../examples/template-power-user-home/kea-dhcp4-2.conf', 'template-power-user-home-dhcp4-2.conf'],
288+
['../examples/template-ha-mt-tls/info.md', 'template-ha-mt-tls.md'],
289+
['../examples/template-ha-mt-tls/kea-ca-1.conf', 'template-ha-mt-tls-ca-1.conf'],
290+
['../examples/template-ha-mt-tls/kea-ca-2.conf', 'template-ha-mt-tls-ca-2.conf'],
291+
['../examples/template-ha-mt-tls/kea-dhcp4-1.conf', 'template-ha-mt-tls-dhcp4-1.conf'],
292+
['../examples/template-ha-mt-tls/kea-dhcp4-2.conf', 'template-ha-mt-tls-dhcp4-2.conf']
292293
]
293294

294295
from shutil import copyfile
@@ -298,6 +299,7 @@ def run_generate_docs(_):
298299
print("Copying %s to %s" % (src, dst))
299300
copyfile(src, dst)
300301

302+
301303
# custom setup hook
302304
def setup(app):
303305
app.add_crossref_type('isccmd', 'isccmd')

doc/sphinx/mes2doc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
# Copyright (C) 2019-2021 Internet Systems Consortium, Inc. ("ISC")
3+
# Copyright (C) 2019-2024 Internet Systems Consortium, Inc. ("ISC")
44
#
55
# This Source Code Form is subject to the terms of the Mozilla Public
66
# License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -58,7 +58,7 @@ def read_input_files(files):
5858
messages[msg_id] = (section, msg_id, msg_text, msg_descr)
5959

6060
# start next message
61-
m = re.search('^%\s?([A-Z0-9_]+)\s+(.*)', line);
61+
m = re.search(r'^%\s?([A-Z0-9_]+)\s+(.*)', line)
6262
msg_id, msg_text = m.groups()
6363
msg_descr = []
6464

@@ -107,12 +107,12 @@ def generate_rst(messages):
107107

108108
rst += msg_text + '\n\n'
109109

110-
rst += ''.join([' ' + l + '\n' for l in msg_descr])
110+
rst += ''.join([' ' + line + '\n' for line in msg_descr])
111111
rst += '\n'
112112

113-
114113
return rst
115114

115+
116116
def generate(in_files, out_file):
117117
messages = read_input_files(in_files)
118118

0 commit comments

Comments
 (0)