pyqode.python.modes package

Module contents

This package contains a series of python specific modes (calltips, autoindent, code linting,...).

Classes

Assignment

class pyqode.python.modes.Assignment(path, line, column, full_name)

Bases: builtins.object

Defines an assignment. Used by GoToAssignmentsMode.

column = None

Column number

full_name = None

Assignement full name

line = None

Line number

module_path = None

File path of the module where the assignment can be found

CalltipsMode

class pyqode.python.modes.CalltipsMode

Bases: pyqode.core.api.mode.Mode, PyQt5.QtCore.QObject

Shows function calltips.

This mode shows function/method call tips in a QToolTip using jedi.Script.call_signatures().

on_state_changed(state)
tooltipDisplayRequested
tooltipHideRequested

CommentsMode

class pyqode.python.modes.CommentsMode

Bases: pyqode.core.api.mode.Mode

Comments/uncomments a set of lines using Ctrl+/.

check_selection(cursor)
comment()

Comments/Uncomments the selected lines or the current lines if there is no selection.

on_key_pressed(key_event)
on_state_changed(state)

Called when the mode is activated/deactivated

DocumentAnalyserMode

class pyqode.python.modes.DocumentAnalyserMode(delay=1000)

Bases: pyqode.core.api.mode.Mode, PyQt5.QtCore.QObject

Analyses the document outline as a tree of statements.

This mode analyses the structure of a document (a tree of pyqode.python.backend.workers.Definition.

pyqode.python.modes.DocumentAnalyserMode.document_changed is emitted whenever the document structure changed.

To keep good performances, the analysis task is run when the application is idle for more than 1 second (by default).

on_state_changed(state)
to_tree_widget_items(to_collapse=None)

Returns the results as a list of top level QTreeWidgetItem.

This is a convenience function that you can use to update a document tree widget wheneve the document changed.

document_changed

Signal emitted when the document structure changed.

flattened_results

Flattens the document structure tree as a simple sequential list.

results = None

The list of results (elements might have children; this is actually a tree).

FrostedCheckerMode

class pyqode.python.modes.FrostedCheckerMode

Bases: pyqode.core.modes.checker.CheckerMode

Runs pyflakes on you code while you’re typing

This checker mode runs pyflakes on the fly to check your python syntax.

GoToAssignmentsMode

class pyqode.python.modes.GoToAssignmentsMode

Bases: pyqode.core.modes.wordclick.WordClickMode

Goes to the assignments (using jedi.Script.goto_assignments) when the user execute the shortcut or click word. If there are more than one assignments, an input dialog is used to ask the user to choose the desired assignment.

This mode will emit the out_of_doc signal if the definition can not be reached in the current document. IDE will typically connects a slot that open a new editor tab and goes to the definition position.

on_state_changed(state)
request_goto()

Request a goto action for the word under the text cursor.

no_results_found

Signal emitted when no results could be found.

out_of_doc

Signal emitted when the definition cannot be reached in the current document

shortcut = 'Alt+F2'

PEP8CheckerMode

class pyqode.python.modes.PEP8CheckerMode

Bases: pyqode.core.modes.checker.CheckerMode

This checker mode runs pep8.py on the fly to check your python style.

PyAutoCompleteMode

class pyqode.python.modes.PyAutoCompleteMode

Bases: pyqode.core.modes.autocomplete.AutoCompleteMode

Auto complete parentheses and method definitions.

Extends pyqode.core.modes.AutoCompleteMode to add support for method/function call:

  • function completion adds ”):” to the function definition.
  • method completion adds “self):” to the method definition.

PyAutoIndentMode

class pyqode.python.modes.PyAutoIndentMode

Bases: pyqode.core.modes.autoindent.AutoIndentMode

Automatically indents text, respecting the PEP8 conventions.

Customised pyqode.core.modes.AutoIndentMode for python that tries its best to follow the pep8 indentation guidelines.

on_install(editor)

PyIndenterMode

class pyqode.python.modes.PyIndenterMode

Bases: pyqode.core.modes.indenter.IndenterMode

Extends the core indenter to add the ability to always indent the whole line instead of inserting a tab at the cursor position. This behaviour can be turned off at runtime by setting tab_always_indent to False.

clone_settings(original)
indent()

Performs an indentation

unindent()

Performs an un-indentation

tab_always_indent

When this flag is set to True, any call to indent will indent the whole line instead of inserting a tab at the cursor position.

PythonSH

class pyqode.python.modes.PythonSH(parent, color_scheme=None)

Bases: pyqode.core.api.syntax_highlighter.SyntaxHighlighter

Highlights python syntax in the editor.

highlight_block(text, block)
rehighlight()
ASPROG = re.compile('.*?\\b(as)\\b')
IDPROG = re.compile('\\s+(\\w+)', re.DOTALL)
INSIDE_DQ3STRING = 2
INSIDE_DQSTRING = 4
INSIDE_SQ3STRING = 1
INSIDE_SQSTRING = 3
NORMAL = 0
OECOMMENT = re.compile('^(# ?--[-]+|##[#]+ )[ -]*[^- ]+')
PROG = re.compile('(?P<instance>\\bself\\b|\\bcls\\b)|(?P<decorator>@\\w*|.setter)|\\b(?P<keyword>self|False|None|True|and|as|assert|break|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is, re.DOTALL)
mimetype = 'text/x-python'