Skip to content

Commit e961891

Browse files
committed
Update docstrings to work with pep257 tool
I don't have a preference either way, but it is nice having clean tooling output.
1 parent 2e4468c commit e961891

File tree

11 files changed

+46
-29
lines changed

11 files changed

+46
-29
lines changed

awsshell/app.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class InputInterrupt(Exception):
4040
4141
Raising `InputInterrupt` is useful to force a cli rebuild, which is
4242
sometimes necessary in order for config changes to take effect.
43+
4344
"""
4445
pass
4546

@@ -91,7 +92,7 @@ def __init__(self, output=sys.stdout, err=sys.stderr):
9192
self._err = err
9293

9394
def handle_cmd(self, command, application):
94-
"""Handles running a given dot command from a user.
95+
"""Handle running a given dot command from a user.
9596
9697
:type command: str
9798
:param command: The full dot command string, e.g. ``.edit``,
@@ -115,7 +116,7 @@ def _unknown_cmd(self, cmd_parts, application):
115116

116117

117118
class AWSShell(object):
118-
"""Encapsulates the ui, completer, command history, docs, and config.
119+
"""Encapsulate the ui, completer, command history, docs, and config.
119120
120121
Runs the input event loop and delegates the command execution to either
121122
the `awscli` or the underlying shell.
@@ -147,6 +148,7 @@ class AWSShell(object):
147148
148149
:type theme: str
149150
:param theme: The pygments theme.
151+
150152
"""
151153

152154
def __init__(self, completer, model_completer, docs):
@@ -172,7 +174,7 @@ def __init__(self, completer, model_completer, docs):
172174
self.load_config()
173175

174176
def load_config(self):
175-
"""Loads the config from the config file or template."""
177+
"""Load the config from the config file or template."""
176178
config = Config()
177179
self.config_obj = config.load('awsshellrc')
178180
self.config_section = self.config_obj['aws-shell']
@@ -186,7 +188,7 @@ def load_config(self):
186188
self.theme = self.config_section['theme']
187189

188190
def save_config(self):
189-
"""Saves the config to the config file."""
191+
"""Save the config to the config file."""
190192
self.config_section['match_fuzzy'] = self.model_completer.match_fuzzy
191193
self.config_section['enable_vi_bindings'] = self.enable_vi_bindings
192194
self.config_section['show_completion_columns'] = \
@@ -235,13 +237,14 @@ def run(self):
235237
p.communicate()
236238

237239
def stop_input_and_refresh_cli(self):
238-
"""Stops input by raising an `InputInterrupt`, forces a cli refresh.
240+
"""Stop input by raising an `InputInterrupt`, forces a cli refresh.
239241
240242
The cli refresh is necessary because changing options such as key
241243
bindings, single vs multi column menu completions, and the help pane
242244
all require a rebuild.
243245
244246
:raises: :class:`InputInterrupt <exceptions.InputInterrupt>`.
247+
245248
"""
246249
self.refresh_cli = True
247250
self.cli.request_redraw()
@@ -267,7 +270,7 @@ def create_buffer(self, completer, history):
267270
accept_action=AcceptAction.RETURN_DOCUMENT)
268271

269272
def create_key_manager(self):
270-
"""Creates the :class:`KeyManager`.
273+
"""Create the :class:`KeyManager`.
271274
272275
The inputs to KeyManager are expected to be callable, so we can't
273276
use the standard @property and @attrib.setter for these attributes.
@@ -277,13 +280,14 @@ def create_key_manager(self):
277280
:return: A KeyManager with callables to set the toolbar options. Also
278281
includes the method stop_input_and_refresh_cli to ensure certain
279282
options take effect within the current session.
280-
"""
281283
284+
"""
282285
def set_match_fuzzy(match_fuzzy):
283286
"""Setter for fuzzy matching mode.
284287
285288
:type match_fuzzy: bool
286289
:param match_fuzzy: The match fuzzy flag.
290+
287291
"""
288292
self.model_completer.match_fuzzy = match_fuzzy
289293

@@ -295,6 +299,7 @@ def set_enable_vi_bindings(enable_vi_bindings):
295299
296300
:type enable_vi_bindings: bool
297301
:param enable_vi_bindings: The enable Vi bindings flag.
302+
298303
"""
299304
self.enable_vi_bindings = enable_vi_bindings
300305

@@ -304,6 +309,7 @@ def set_show_completion_columns(show_completion_columns):
304309
:type show_completion_columns: bool
305310
:param show_completion_columns: The show completions in
306311
multiple columns flag.
312+
307313
"""
308314
self.show_completion_columns = show_completion_columns
309315

@@ -312,6 +318,7 @@ def set_show_help(show_help):
312318
313319
:type show_help: bool
314320
:param show_help: The show help flag.
321+
315322
"""
316323
self.show_help = show_help
317324

awsshell/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Config(object):
2222
"""Reads and writes the config template and user config file."""
2323

2424
def load(self, config_template, config_file=None):
25-
"""Reads the config file if it exists, else reads the default config.
25+
"""Read the config file if it exists, else read the default config.
2626
2727
Creates the user config file if it doesn't exist using the template.
2828
@@ -45,7 +45,7 @@ def load(self, config_template, config_file=None):
4545
return self._load_template_or_config(template_path, config_path)
4646

4747
def _load_template_or_config(self, template_path, config_path):
48-
"""Loads the config file if it exists, else reads the default config.
48+
"""Load the config file if it exists, else read the default config.
4949
5050
:type template_path: str
5151
:param template_path: The template config file path.
@@ -65,7 +65,7 @@ def _load_template_or_config(self, template_path, config_path):
6565

6666
def _copy_template_to_config(self, template_path,
6767
config_path, overwrite=False):
68-
"""Writes the default config from a template.
68+
"""Write the default config from a template.
6969
7070
:type template_path: str
7171
:param template_path: The template config file path.

awsshell/docs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ def load_doc_db(filename):
1313

1414

1515
class DocRetriever(object):
16-
"""Retrieves documentation for the AWS CLI.
17-
"""
16+
"""Retrieve documentation for the AWS CLI."""
1817
def __init__(self, doc_index):
1918
# Internally, most of the speedup comes from
2019
# the fact that this data is pre-rendered and

awsshell/keys.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _create_key_manager(self, get_match_fuzzy, set_match_fuzzy,
4444
set_show_completion_columns,
4545
get_show_help, set_show_help,
4646
stop_input_and_refresh_cli):
47-
"""Creates and initializes the keybinding manager.
47+
"""Create and initialize the keybinding manager.
4848
4949
:type get_fuzzy_match: callable
5050
:param get_fuzzy_match: Gets the fuzzy matching config.
@@ -81,6 +81,7 @@ def _create_key_manager(self, get_match_fuzzy, set_match_fuzzy,
8181
8282
:rtype: :class:`prompt_toolkit.KeyBindingManager`
8383
:return: A custom `KeyBindingManager`.
84+
8485
"""
8586
assert callable(get_match_fuzzy)
8687
assert callable(set_match_fuzzy)
@@ -101,51 +102,56 @@ def _create_key_manager(self, get_match_fuzzy, set_match_fuzzy,
101102

102103
@self.manager.registry.add_binding(Keys.F2)
103104
def handle_f2(_):
104-
"""Enables/disables fuzzy matching.
105+
"""Toggle fuzzy matching.
105106
106107
:type _: :class:`prompt_toolkit.Event`
107108
:param _: (Unused)
109+
108110
"""
109111
set_match_fuzzy(not get_match_fuzzy())
110112

111113
@self.manager.registry.add_binding(Keys.F3)
112114
def handle_f3(_):
113-
"""Enables/disables Vi mode keybindings matching.
115+
"""Toggle Vi mode keybindings matching.
114116
115117
Disabling Vi keybindings will enable Emacs keybindings.
116118
117119
:type _: :class:`prompt_toolkit.Event`
118120
:param _: (Unused)
121+
119122
"""
120123
set_enable_vi_bindings(not get_enable_vi_bindings())
121124
stop_input_and_refresh_cli()
122125

123126
@self.manager.registry.add_binding(Keys.F4)
124127
def handle_f4(_):
125-
"""Enables/disables multiple column completions.
128+
"""Toggle multiple column completions.
126129
127130
:type _: :class:`prompt_toolkit.Event`
128131
:param _: (Unused)
132+
129133
"""
130134
set_show_completion_columns(not get_show_completion_columns())
131135
stop_input_and_refresh_cli()
132136

133137
@self.manager.registry.add_binding(Keys.F5)
134138
def handle_f5(_):
135-
"""Shows/hides the help container.
139+
"""Toggle the help container.
136140
137141
:type _: :class:`prompt_toolkit.Event`
138142
:param _: (Unused)
143+
139144
"""
140145
set_show_help(not get_show_help())
141146
stop_input_and_refresh_cli()
142147

143148
@self.manager.registry.add_binding(Keys.F10)
144149
def handle_f10(event):
145-
"""Quits when the `F10` key is pressed.
150+
"""Quit when the `F10` key is pressed.
146151
147152
:type event: :class:`prompt_toolkit.Event`
148153
:param event: Contains info about the event, namely the cli
149154
which is used for exiting the app.
155+
150156
"""
151157
event.cli.set_exit()

awsshell/makeindex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def render_docs_for_cmd(help_command):
122122

123123

124124
def convert_rst_to_basic_text(contents):
125-
"""Converts restructured text to basic text output.
125+
"""Convert restructured text to basic text output.
126126
127127
This function removes most of the decorations added
128128
in restructured text.

awsshell/resource/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def __init__(self, resource_index):
9292
self._index = resource_index
9393

9494
def describe_autocomplete(self, service, operation, param):
95-
"""
95+
"""Describe operation and args needed for server side completion.
9696
9797
:type service: str
9898
:param service: The AWS service name.

awsshell/style.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
class StyleFactory(object):
21-
"""Provides styles for the autocomplete menu and the toolbar.
21+
"""Provide styles for the autocomplete menu and the toolbar.
2222
2323
:type style: :class:`pygments.style.StyleMeta`
2424
:param style: Contains pygments style info.
@@ -28,7 +28,7 @@ def __init__(self, style_name):
2828
self.style = self.style_factory(style_name)
2929

3030
def style_factory(self, style_name):
31-
"""Retrieves the specified pygments style.
31+
"""Retrieve the specified pygments style.
3232
3333
If the specified style is not found, the vim style is returned.
3434

awsshell/substring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
def substring_search(word, collection):
16-
"""Finds all matches in the `collection` for the specified `word`.
16+
"""Find all matches in the `collection` for the specified `word`.
1717
1818
If `word` is empty, returns all items in `collection`.
1919

awsshell/toolbar.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414

1515

1616
class Toolbar(object):
17-
"""Shows information about the aws-shell in a tool bar.
17+
"""Show information about the aws-shell in a tool bar.
1818
1919
:type handler: callable
2020
:param handler: Wraps the callable `get_toolbar_items`.
21+
2122
"""
2223

2324
def __init__(self, get_match_fuzzy, get_enable_vi_bindings,
@@ -28,7 +29,7 @@ def __init__(self, get_match_fuzzy, get_enable_vi_bindings,
2829

2930
def _create_toolbar_handler(self, get_match_fuzzy, get_enable_vi_bindings,
3031
get_show_completion_columns, get_show_help):
31-
"""Creates the toolbar handler.
32+
"""Create the toolbar handler.
3233
3334
:type get_fuzzy_match: callable
3435
:param fuzzy_match: Gets the fuzzy matching config.
@@ -46,14 +47,15 @@ def _create_toolbar_handler(self, get_match_fuzzy, get_enable_vi_bindings,
4647
4748
:rtype: callable
4849
:returns: get_toolbar_items.
50+
4951
"""
5052
assert callable(get_match_fuzzy)
5153
assert callable(get_enable_vi_bindings)
5254
assert callable(get_show_completion_columns)
5355
assert callable(get_show_help)
5456

5557
def get_toolbar_items(_):
56-
"""Returns the toolbar items.
58+
"""Return the toolbar items.
5759
5860
:type _: :class:`prompt_toolkit.Cli`
5961
:param _: (Unused)

awsshell/ui.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def create_default_layout(app, message='',
3434
extra_input_processors=None, multiline=False):
3535
"""
3636
Generate default layout.
37+
3738
Returns a ``Layout`` instance.
3839
3940
:param message: Text to be used as prompt.
@@ -193,10 +194,12 @@ def separator():
193194

194195

195196
def _split_multiline_prompt(get_prompt_tokens):
196-
"""
197+
"""Split prompt tokens into two multiline prompt token functions.
198+
197199
Take a `get_prompt_tokens` function. and return two new functions instead.
198200
One that returns the tokens to be shown on the lines above the input, and
199201
another one with the tokens to be shown at the first line of the input.
202+
200203
"""
201204
def before(cli):
202205
result = []

awsshell/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class FSLayer(object):
7171
7272
"""
7373
def file_contents(self, filename, binary=False):
74-
"""Returns the file for a given filename.
74+
"""Return the file for a given filename.
7575
7676
If you want binary content use ``mode='rb'``.
7777
@@ -87,7 +87,7 @@ def file_contents(self, filename, binary=False):
8787
raise FileReadError(str(e))
8888

8989
def file_exists(self, filename):
90-
"""Checks if a file exists.
90+
"""Check if a file exists.
9191
9292
This method returns true if:
9393

0 commit comments

Comments
 (0)