Remove Emit:/Raise: from docstrings.

They got out-of-sync fast and provided no real benefit.
This commit is contained in:
Florian Bruhin 2014-10-07 23:08:37 +02:00
parent f3ad1b71e6
commit 6349a6a213
29 changed files with 9 additions and 190 deletions

View File

@ -431,12 +431,13 @@ Style conventions
qutebrowser's coding conventions are based on qutebrowser's coding conventions are based on
http://legacy.python.org/dev/peps/pep-0008/[PEP8] and the https://google-styleguide.googlecode.com/svn/trunk/pyguide.html[Google Python style guidelines] with some additions: http://legacy.python.org/dev/peps/pep-0008/[PEP8] and the https://google-styleguide.googlecode.com/svn/trunk/pyguide.html[Google Python style guidelines] with some additions:
* The _Raise:_ section is not added to the docstring.
* Methods overriding Qt methods (obviously!) don't follow the naming schemes. * Methods overriding Qt methods (obviously!) don't follow the naming schemes.
* Everything else does though, even slots. * Everything else does though, even slots.
* Docstrings should look like described in * Docstrings should look like described in
http://legacy.python.org/dev/peps/pep-0257/[PEP257] and the google guidelines. http://legacy.python.org/dev/peps/pep-0257/[PEP257] and the google guidelines.
* Class docstrings have additional _Attributes:_, _Class attributes:_ and * Class docstrings have additional _Attributes:_, _Class attributes:_ and
_Signals:_ sections, method/function docstrings have an _Emit:_ section. _Signals:_ sections.
* In docstrings of command handlers (registered via `@cmdutils.register`), the * In docstrings of command handlers (registered via `@cmdutils.register`), the
description should be split into two parts by using `//` - the first part is description should be split into two parts by using `//` - the first part is
the description of the command like it will appear in the documentation, the the description of the command like it will appear in the documentation, the
@ -475,12 +476,6 @@ Args:
Return: Return:
True if something, False if something else. True if something, False if something else.
Raise:
ValueError if foo is None
Emit:
value_changed
""" """
---- ----
+ +

View File

@ -75,9 +75,6 @@ class SignalFilter(QObject):
signal: The signal to emit if the sender was the current widget. signal: The signal to emit if the sender was the current widget.
tab: The WebView which the filter belongs to. tab: The WebView which the filter belongs to.
*args: The args to pass to the signal. *args: The args to pass to the signal.
Emit:
The target signal if the sender was the current widget.
""" """
log_signal = debug.signal_name(signal) not in self.BLACKLIST log_signal = debug.signal_name(signal) not in self.BLACKLIST
tabbed_browser = objreg.get('tabbed-browser', scope='window', tabbed_browser = objreg.get('tabbed-browser', scope='window',

View File

@ -166,12 +166,7 @@ class BrowserPage(QWebPage):
@pyqtSlot('QNetworkRequest') @pyqtSlot('QNetworkRequest')
def on_download_requested(self, request): def on_download_requested(self, request):
"""Called when the user wants to download a link. """Called when the user wants to download a link."""
Emit:
start_download: Emitted with the QNetworkReply associated with the
passed request.
"""
reply = self.networkAccessManager().get(request) reply = self.networkAccessManager().get(request)
self.start_download.emit(reply) self.start_download.emit(reply)

View File

@ -36,10 +36,6 @@ def check_overflow(arg, ctype):
Args: Args:
arg: The argument to check arg: The argument to check
ctype: The C/Qt type to check as a string. ctype: The C/Qt type to check as a string.
Raise:
CommandError if the argument is out of bounds.
ValueError if the given ctype is unknown.
""" """
try: try:
qtutils.check_overflow(arg, ctype) qtutils.check_overflow(arg, ctype)
@ -63,9 +59,6 @@ def arg_or_count(arg, count, default=None, countzero=None):
Return: Return:
The value to use. The value to use.
Raise:
ValueError: If nothing was set.
""" """
if count is not None and arg is not None: if count is not None and arg is not None:
raise ValueError("Both count and argument given!") raise ValueError("Both count and argument given!")

View File

@ -100,9 +100,6 @@ class Command:
Args: Args:
win_id: The window ID the command is run in. win_id: The window ID the command is run in.
Raise:
PrerequisitesError if the command can't be called currently.
""" """
mode_manager = objreg.get('mode-manager', scope='window', mode_manager = objreg.get('mode-manager', scope='window',
window=win_id) window=win_id)

View File

@ -74,9 +74,6 @@ class SearchRunner(QObject):
Args: Args:
text: The text to search for. text: The text to search for.
rev: Search direction, True if reverse, else False. rev: Search direction, True if reverse, else False.
Emit:
do_search: If a search should be started.
""" """
if self._text is not None and self._text != text: if self._text is not None and self._text != text:
# We first clear the marked text, then the highlights # We first clear the marked text, then the highlights
@ -124,9 +121,6 @@ class SearchRunner(QObject):
Args: Args:
count: How many elements to ignore. count: How many elements to ignore.
Emit:
do_search: If a search should be started.
""" """
if self._text is not None: if self._text is not None:
for _ in range(count): for _ in range(count):
@ -138,9 +132,6 @@ class SearchRunner(QObject):
Args: Args:
count: How many elements to ignore. count: How many elements to ignore.
Emit:
do_search: If a search should be started.
""" """
if self._text is None: if self._text is None:
return return
@ -209,9 +200,6 @@ class CommandRunner(QObject):
unknown. unknown.
alias_no_args: Whether to apply an alias if there are no arguments. alias_no_args: Whether to apply an alias if there are no arguments.
Raise:
NoSuchCommandError if a command wasn't found.
Return: Return:
A split string commandline, e.g ['open', 'www.google.com'] A split string commandline, e.g ['open', 'www.google.com']
""" """

View File

@ -268,11 +268,7 @@ class _WindowsUserscriptRunner(_BaseUserscriptRunner):
self._oshandle = None self._oshandle = None
def on_proc_finished(self): def on_proc_finished(self):
"""Read back the commands when the process finished. """Read back the commands when the process finished."""
Emit:
got_cmd: Emitted for every command in the file.
"""
log.procs.debug("proc finished") log.procs.debug("proc finished")
with open(self._filepath, 'r', encoding='utf-8') as f: with open(self._filepath, 'r', encoding='utf-8') as f:
for line in f: for line in f:

View File

@ -476,14 +476,6 @@ class ConfigManager(QObject):
sectname: The name of the section to change. sectname: The name of the section to change.
optname: The name of the option to change. optname: The name of the option to change.
value: The new value. value: The new value.
Raise:
NoSectionError: If the specified section doesn't exist.
NoOptionError: If the specified option doesn't exist.
Emit:
changed: If the config was changed.
style_changed: When style caches need to be invalidated.
""" """
try: try:
value = self._interpolation.before_set(self, sectname, optname, value = self._interpolation.before_set(self, sectname, optname,

View File

@ -127,10 +127,6 @@ class BaseType:
Args: Args:
value: The value to validate. value: The value to validate.
Raise:
ValidationError if the value was invalid.
NotImplementedError if self.valid_values is not defined and this
method should be overridden. method should be overridden.
""" """
if not value and self._none_ok: if not value and self._none_ok:

View File

@ -278,9 +278,6 @@ class BaseKeyParser(QObject):
Args: Args:
command/count: As if passed to self.execute() command/count: As if passed to self.execute()
Emit:
keystring_updated to do a delayed update.
""" """
self._debug_log("Executing delayed command now!") self._debug_log("Executing delayed command now!")
self._timer = None self._timer = None
@ -293,9 +290,6 @@ class BaseKeyParser(QObject):
Args: Args:
e: the KeyPressEvent from Qt e: the KeyPressEvent from Qt
Emit:
keystring_updated: If a new keystring should be set.
""" """
handled = self._handle_special_key(e) handled = self._handle_special_key(e)
if handled or not self._supports_chains: if handled or not self._supports_chains:

View File

@ -269,9 +269,6 @@ class ModeManager(QObject):
mode: The mode to enter as a KeyMode member. mode: The mode to enter as a KeyMode member.
reason: Why the mode was entered. reason: Why the mode was entered.
override: Override a locked mode. override: Override a locked mode.
Emit:
entered: With the new mode name.
""" """
if not isinstance(mode, usertypes.KeyMode): if not isinstance(mode, usertypes.KeyMode):
raise TypeError("Mode {} is no KeyMode member!".format(mode)) raise TypeError("Mode {} is no KeyMode member!".format(mode))
@ -314,9 +311,6 @@ class ModeManager(QObject):
Args: Args:
mode: The name of the mode to leave. mode: The name of the mode to leave.
reason: Why the mode was left. reason: Why the mode was left.
Emit:
left: With the old mode name.
""" """
try: try:
self._mode_stack.remove(mode) self._mode_stack.remove(mode)

View File

@ -105,9 +105,6 @@ class HintKeyParser(keyparser.CommandKeyParser):
Return: Return:
True if event has been handled, False otherwise. True if event has been handled, False otherwise.
Emit:
keystring_updated: Emitted when keystring has been changed.
""" """
log.keyboard.debug("Got special key 0x{:x} text {}".format( log.keyboard.debug("Got special key 0x{:x} text {}".format(
e.key(), e.text())) e.key(), e.text()))
@ -143,9 +140,6 @@ class HintKeyParser(keyparser.CommandKeyParser):
Args: Args:
e: the KeyPressEvent from Qt e: the KeyPressEvent from Qt
Emit:
keystring_updated: If a new keystring should be set.
""" """
handled = self._handle_single_key(e) handled = self._handle_single_key(e)
if handled and self._keystring: if handled and self._keystring:

View File

@ -144,8 +144,5 @@ class BaseCompletionModel(QStandardItemModel):
"""Sort the data in column according to order. """Sort the data in column according to order.
Override QAbstractItemModel::sort. Override QAbstractItemModel::sort.
Raise:
NotImplementedError, should be overwritten in a superclass.
""" """
raise NotImplementedError raise NotImplementedError

View File

@ -94,10 +94,6 @@ class History:
"""Get the previous item in the temp history. """Get the previous item in the temp history.
start() needs to be called before calling this. start() needs to be called before calling this.
Raise:
ValueError if start() wasn't called.
HistoryEndReachedError if the first item was reached.
""" """
if not self.is_browsing(): if not self.is_browsing():
raise ValueError("Currently not browsing history") raise ValueError("Currently not browsing history")
@ -110,10 +106,6 @@ class History:
"""Get the next item in the temp history. """Get the next item in the temp history.
start() needs to be called before calling this. start() needs to be called before calling this.
Raise:
ValueError if start() wasn't called.
HistoryEndReachedError if the last item was reached.
""" """
if not self.is_browsing(): if not self.is_browsing():
raise ValueError("Currently not browsing history") raise ValueError("Currently not browsing history")

View File

@ -48,10 +48,6 @@ class SchemeHandler(QObject):
Return: Return:
A QNetworkReply. A QNetworkReply.
Raise:
NotImplementedError because this needs to be overwritten by
subclasses.
""" """
raise NotImplementedError raise NotImplementedError
@ -68,9 +64,6 @@ class SpecialNetworkReply(QNetworkReply):
fileData: reference to the data buffer (QByteArray) fileData: reference to the data buffer (QByteArray)
mimeType: for the reply (string) mimeType: for the reply (string)
parent: reference to the parent object (QObject) parent: reference to the parent object (QObject)
Emit:
metaDataChanged and readyRead and finished after initializing.
""" """
super().__init__(parent) super().__init__(parent)

View File

@ -50,9 +50,6 @@ class ConfigStub:
Args: Args:
name: The section name to get. name: The section name to get.
Raise:
ValueError if section isn't test1/test2.
Return: Return:
The section as dict. The section as dict.
""" """

View File

@ -161,9 +161,6 @@ class Completer(QObject):
Args: Args:
selected: New selection. selected: New selection.
_delected: Previous selection. _delected: Previous selection.
Emit:
change_completed_part: Emitted when there's data for the new item.
""" """
indexes = selected.indexes() indexes = selected.indexes()
if not indexes: if not indexes:

View File

@ -128,8 +128,6 @@ class DocstringParser:
"""Parse the long description in the docstring.""" """Parse the long description in the docstring."""
if line.startswith('Args:'): if line.startswith('Args:'):
self._state = self.State.arg_start self._state = self.State.arg_start
elif line.startswith('Emit:') or line.startswith('Raise:'):
self._state = self.State.misc
elif line.strip() == '//': elif line.strip() == '//':
self._state = self.State.desc_hidden self._state = self.State.desc_hidden
elif line.strip(): elif line.strip():

View File

@ -65,9 +65,6 @@ class ExternalEditor(QObject):
"""Write the editor text into the form field and clean up tempfile. """Write the editor text into the form field and clean up tempfile.
Callback for QProcess when the editor was closed. Callback for QProcess when the editor was closed.
Emit:
editing_finished: If process exited normally.
""" """
log.procs.debug("Editor closed") log.procs.debug("Editor closed")
if exitstatus != QProcess.NormalExit: if exitstatus != QProcess.NormalExit:
@ -113,9 +110,6 @@ class ExternalEditor(QObject):
Args: Args:
text: The initial text to edit. text: The initial text to edit.
Emit:
editing_finished with the new text if editing finshed successfully.
""" """
if self._text is not None: if self._text is not None:
raise ValueError("Already editing a file!") raise ValueError("Already editing a file!")

View File

@ -68,9 +68,6 @@ def check_overflow(arg, ctype, fatal=True):
Return Return
The truncated argument if fatal=False The truncated argument if fatal=False
The original argument if it's in bounds. The original argument if it's in bounds.
Raise:
OverflowError if the argument is out of bounds and fatal=True.
""" """
maxval = MAXVALS[ctype] maxval = MAXVALS[ctype]
minval = MINVALS[ctype] minval = MINVALS[ctype]
@ -119,11 +116,7 @@ def check_print_compat():
def ensure_valid(obj): def ensure_valid(obj):
"""Ensure a Qt object with an .isValid() method is valid. """Ensure a Qt object with an .isValid() method is valid."""
Raise:
QtValueError if the object is invalid.
"""
if not obj.isValid(): if not obj.isValid():
raise QtValueError(obj) raise QtValueError(obj)

View File

@ -43,9 +43,6 @@ def _get_search_url(txt):
Return: Return:
The search URL as a QUrl. The search URL as a QUrl.
Raise:
FuzzyUrlError if there is no template or no search term was found.
""" """
log.url.debug("Finding search engine for '{}'".format(txt)) log.url.debug("Finding search engine for '{}'".format(txt))
r = re.compile(r'(^|\s+)!(\w+)($|\s+)') r = re.compile(r'(^|\s+)!(\w+)($|\s+)')
@ -186,9 +183,6 @@ def is_url(urlstr):
Return: Return:
True if it is a valid URL, False otherwise. True if it is a valid URL, False otherwise.
Raise:
ValueError if the autosearch config value is invalid.
""" """
autosearch = config.get('general', 'auto-search') autosearch = config.get('general', 'auto-search')

View File

@ -128,10 +128,6 @@ class NeighborList(collections.abc.Sequence):
Return: Return:
The new item. The new item.
Raise:
IndexError if the border of the list is reached and mode is
exception.
""" """
try: try:
if self._idx + offset >= 0: if self._idx + offset >= 0:
@ -164,10 +160,6 @@ class NeighborList(collections.abc.Sequence):
Return: Return:
The new item. The new item.
Raise:
IndexError if the border of the list is reached and mode is
exception.
""" """
log.misc.debug("{} items, idx {}, offset {}".format( log.misc.debug("{} items, idx {}, offset {}".format(
len(self._items), self._idx, offset)) len(self._items), self._idx, offset))
@ -324,11 +316,7 @@ class Question(QObject):
self.completed.emit() self.completed.emit()
def abort(self): def abort(self):
"""Abort the question. """Abort the question."""
Emit:
aborted: Always emitted.
"""
self.is_aborted = True self.is_aborted = True
try: try:
self.aborted.emit() self.aborted.emit()

View File

@ -61,10 +61,6 @@ def debug_crash(typ: ('exception', 'segfault')='exception'):
Args: Args:
typ: either 'exception' or 'segfault'. typ: either 'exception' or 'segfault'.
Raises:
raises Exception when typ is not segfault.
segfaults when typ is (you don't say...)
""" """
if typ == 'segfault': if typ == 'segfault':
# From python's Lib/test/crashers/bogus_code_obj.py # From python's Lib/test/crashers/bogus_code_obj.py

View File

@ -289,9 +289,6 @@ def _get_color_percentage(a_c1, a_c2, a_c3, b_c1, b_c2, b_c3, percent):
Return: Return:
A (c1, c2, c3) tuple with the interpolated color components. A (c1, c2, c3) tuple with the interpolated color components.
Raise:
ValueError if the percentage was invalid.
""" """
if not 0 <= percent <= 100: if not 0 <= percent <= 100:
raise ValueError("percent needs to be between 0 and 100!") raise ValueError("percent needs to be between 0 and 100!")
@ -313,9 +310,6 @@ def interpolate_color(start, end, percent, colorspace=QColor.Rgb):
Return: Return:
The interpolated QColor, with the same spec as the given start color. The interpolated QColor, with the same spec as the given start color.
Raise:
ValueError if invalid parameters are passed.
""" """
qtutils.ensure_valid(start) qtutils.ensure_valid(start)
qtutils.ensure_valid(end) qtutils.ensure_valid(end)

View File

@ -411,9 +411,6 @@ class StatusBar(QWidget):
Args: Args:
e: The QResizeEvent. e: The QResizeEvent.
Emit:
resized: Always emitted.
""" """
super().resizeEvent(e) super().resizeEvent(e)
self.resized.emit(self.geometry()) self.resized.emit(self.geometry())
@ -423,9 +420,6 @@ class StatusBar(QWidget):
Args: Args:
e: The QMoveEvent. e: The QMoveEvent.
Emit:
moved: Always emitted.
""" """
super().moveEvent(e) super().moveEvent(e)
self.moved.emit(e.pos()) self.moved.emit(e.pos())

View File

@ -145,9 +145,6 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
Args: Args:
text: The text to set as string. text: The text to set as string.
Emit:
update_completion: Emitted if the text changed.
""" """
old_text = self.text() old_text = self.text()
self.setText(text) self.setText(text)
@ -248,13 +245,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
@cmdutils.register(instance='status-command', hide=True, @cmdutils.register(instance='status-command', hide=True,
modes=[usertypes.KeyMode.command], scope='window') modes=[usertypes.KeyMode.command], scope='window')
def command_accept(self): def command_accept(self):
"""Execute the command currently in the commandline. """Execute the command currently in the commandline."""
Emit:
got_cmd: If a new cmd was entered.
got_search: If a new search was entered.
got_search_rev: If a new reverse search was entered.
"""
signals = { signals = {
':': self.got_cmd, ':': self.got_cmd,
'/': self.got_search, '/': self.got_search,
@ -285,10 +276,6 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
Args: Args:
mode: The mode which was left. mode: The mode which was left.
Emit:
clear_completion_selection: Always emitted.
hide_completion: Always emitted so the completion is hidden.
""" """
if mode == usertypes.KeyMode.command: if mode == usertypes.KeyMode.command:
self.setText('') self.setText('')

View File

@ -132,9 +132,6 @@ class Prompter(QObject):
Return: Return:
The mode which should be entered. The mode which should be entered.
Raise:
ValueError if the set PromptMode is invalid.
""" """
prompt = objreg.get('prompt', scope='window', window=self._win_id) prompt = objreg.get('prompt', scope='window', window=self._win_id)
if self._question.mode == usertypes.PromptMode.yesno: if self._question.mode == usertypes.PromptMode.yesno:

View File

@ -188,9 +188,6 @@ class TabbedBrowser(tabwidget.TabWidget):
Return: Return:
The current URL as QUrl. The current URL as QUrl.
Raise:
CommandError if the current URL is invalid.
""" """
widget = self.currentWidget() widget = self.currentWidget()
if widget is None: if widget is None:
@ -208,11 +205,7 @@ class TabbedBrowser(tabwidget.TabWidget):
return url return url
def shutdown(self): def shutdown(self):
"""Try to shut down all tabs cleanly. """Try to shut down all tabs cleanly."""
Emit:
shutdown_complete if the shutdown completed successfully.
"""
try: try:
self.currentChanged.disconnect() self.currentChanged.disconnect()
except TypeError: except TypeError:
@ -240,9 +233,6 @@ class TabbedBrowser(tabwidget.TabWidget):
Args: Args:
tab: The QWebView to be closed. tab: The QWebView to be closed.
Raise:
ValueError if the tab is not in the QTabWidget.
""" """
idx = self.indexOf(tab) idx = self.indexOf(tab)
if idx == -1: if idx == -1:
@ -553,9 +543,6 @@ class TabbedBrowser(tabwidget.TabWidget):
Args: Args:
e: The QResizeEvent e: The QResizeEvent
Emit:
resize: Always emitted.
""" """
super().resizeEvent(e) super().resizeEvent(e)
self.resized.emit(self.geometry()) self.resized.emit(self.geometry())

View File

@ -128,11 +128,7 @@ class WebView(QWebView):
return utils.get_repr(self, tab_id=self.tab_id, url=url) return utils.get_repr(self, tab_id=self.tab_id, url=url)
def _set_load_status(self, val): def _set_load_status(self, val):
"""Setter for load_status. """Setter for load_status."""
Emit:
load_status_changed
"""
if not isinstance(val, LoadStatus): if not isinstance(val, LoadStatus):
raise TypeError("Type {} is no LoadStatus member!".format(val)) raise TypeError("Type {} is no LoadStatus member!".format(val))
log.webview.debug("load status for {}: {}".format(repr(self), val)) log.webview.debug("load status for {}: {}".format(repr(self), val))
@ -279,9 +275,6 @@ class WebView(QWebView):
Return: Return:
Return status of self.load Return status of self.load
Emit:
titleChanged
""" """
qtutils.ensure_valid(url) qtutils.ensure_valid(url)
urlstr = url.toDisplayString() urlstr = url.toDisplayString()
@ -412,9 +405,6 @@ class WebView(QWebView):
Args: Args:
e: The QPaintEvent. e: The QPaintEvent.
Emit:
scroll_pos_changed; If the scroll position changed.
Return: Return:
The superclass event return value. The superclass event return value.
""" """