eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer

Module implementing a class to fix certain PEP 8 issues.

Global Attributes

Pep8FixableIssues

Classes

Pep8Fixer Class implementing a fixer for certain PEP 8 issues.

Functions

None


Pep8Fixer

Class implementing a fixer for certain PEP 8 issues.

Derived from

QObject

Class Attributes

None

Class Methods

None

Methods

Pep8Fixer Constructor
__finalize Private method to apply all deferred fixes.
__fixBlankLinesAfterDecorator Private method to fix superfluous blank lines after a function decorator.
__fixMissingWhitespaceAfter Private method to fix missing whitespace after ',;:'.
__fixMissingWhitespaceAroundOperator Private method to fix missing whitespace after ',;:'.
__fixNewline Private method to fix a missing newline at the end of file.
__fixNotEqual Private method to fix the not equal notation.
__fixOneBlankLine Private method to fix the need for one blank line.
__fixTabs Private method to fix obsolete tab usage.
__fixTooManyBlankLines Private method to fix superfluous blank lines.
__fixTrailingBlankLines Private method to fix trailing blank lines.
__fixTwoBlankLines Private method to fix the need for two blank lines.
__fixWhitespace Private method to fix trailing whitespace.
__fixWhitespaceAfter Private method to fix superfluous whitespace after '([{'.
__fixWhitespaceAfterInline Private method to fix whitespace after inline comment.
__fixWhitespaceAroundEquals Private method to fix extraneous whitespace around keyword and default parameter equals.
__fixWhitespaceAroundOperator Private method to fix extraneous whitespace around operator.
__fixWhitespaceBefore Private method to fix superfluous whitespace before '}])', ',;:' and '(['.
__fixWhitespaceBeforeInline Private method to fix missing whitespace before inline comment.
__getEol Private method to get the applicable eol string.
fixIssue Public method to fix the fixable issues.
saveFile Public method to save the modified file.

Static Methods

None

Pep8Fixer (Constructor)

Pep8Fixer(project, filename, sourceLines, fixCodes, inPlace)

Constructor

project
reference to the project object (Project)
filename
name of the file to be fixed (string)
sourceLines
list of source lines including eol marker (list of string)
fixCodes
list of codes to be fixed as a comma separated string (string)
inPlace
flag indicating to modify the file in place (boolean)

Pep8Fixer.__finalize

__finalize()

Private method to apply all deferred fixes.

Pep8Fixer.__fixBlankLinesAfterDecorator

__fixBlankLinesAfterDecorator(code, line, pos, apply=False)

Private method to fix superfluous blank lines after a function decorator.

code
code of the issue (string)
line
line number of the issue (integer)
pos
position inside line (integer)
apply=
flag indicating, that the fix should be applied (boolean)
Returns:
flag indicating an applied fix (boolean) and a message for the fix (string)

Pep8Fixer.__fixMissingWhitespaceAfter

__fixMissingWhitespaceAfter(code, line, pos, apply=False)

Private method to fix missing whitespace after ',;:'.

code
code of the issue (string)
line
line number of the issue (integer)
pos
position inside line (integer)
apply=
flag indicating, that the fix should be applied (boolean)
Returns:
flag indicating an applied fix (boolean) and a message for the fix (string)

Pep8Fixer.__fixMissingWhitespaceAroundOperator

__fixMissingWhitespaceAroundOperator(code, line, pos, apply=False)

Private method to fix missing whitespace after ',;:'.

code
code of the issue (string)
line
line number of the issue (integer)
pos
position inside line (integer)
apply=
flag indicating, that the fix should be applied (boolean)
Returns:
flag indicating an applied fix (boolean) and a message for the fix (string)

Pep8Fixer.__fixNewline

__fixNewline(code, line, pos)

Private method to fix a missing newline at the end of file.

code
code of the issue (string)
line
line number of the issue (integer)
pos
position inside line (integer)
Returns:
flag indicating an applied fix (boolean) and a message for the fix (string)

Pep8Fixer.__fixNotEqual

__fixNotEqual(code, line, pos)

Private method to fix the not equal notation.

code
code of the issue (string)
line
line number of the issue (integer)
pos
position inside line (integer)
Returns:
flag indicating an applied fix (boolean) and a message for the fix (string)

Pep8Fixer.__fixOneBlankLine

__fixOneBlankLine(code, line, pos, apply=False)

Private method to fix the need for one blank line.

code
code of the issue (string)
line
line number of the issue (integer)
pos
position inside line (integer)
apply=
flag indicating, that the fix should be applied (boolean)
Returns:
flag indicating an applied fix (boolean) and a message for the fix (string)

Pep8Fixer.__fixTabs

__fixTabs(code, line, pos)

Private method to fix obsolete tab usage.

code
code of the issue (string)
line
line number of the issue (integer)
pos
position inside line (integer)
Returns:
flag indicating an applied fix (boolean) and a message for the fix (string)

Pep8Fixer.__fixTooManyBlankLines

__fixTooManyBlankLines(code, line, pos, apply=False)

Private method to fix superfluous blank lines.

code
code of the issue (string)
line
line number of the issue (integer)
pos
position inside line (integer)
apply=
flag indicating, that the fix should be applied (boolean)
Returns:
flag indicating an applied fix (boolean) and a message for the fix (string)

Pep8Fixer.__fixTrailingBlankLines

__fixTrailingBlankLines(code, line, pos)

Private method to fix trailing blank lines.

code
code of the issue (string)
line
line number of the issue (integer)
pos
position inside line (integer)
Returns:
flag indicating an applied fix (boolean) and a message for the fix (string)

Pep8Fixer.__fixTwoBlankLines

__fixTwoBlankLines(code, line, pos, apply=False)

Private method to fix the need for two blank lines.

Pep8Fixer.__fixWhitespace

__fixWhitespace(code, line, pos)

Private method to fix trailing whitespace.

code
code of the issue (string)
line
line number of the issue (integer)
pos
position inside line (integer)
Returns:
flag indicating an applied fix (boolean) and a message for the fix (string)

Pep8Fixer.__fixWhitespaceAfter

__fixWhitespaceAfter(code, line, pos, apply=False)

Private method to fix superfluous whitespace after '([{'.

code
code of the issue (string)
line
line number of the issue (integer)
pos
position inside line (integer)
apply=
flag indicating, that the fix should be applied (boolean)
Returns:
flag indicating an applied fix (boolean) and a message for the fix (string)

Pep8Fixer.__fixWhitespaceAfterInline

__fixWhitespaceAfterInline(code, line, pos, apply=False)

Private method to fix whitespace after inline comment.

code
code of the issue (string)
line
line number of the issue (integer)
pos
position inside line (integer)
apply=
flag indicating, that the fix should be applied (boolean)
Returns:
flag indicating an applied fix (boolean) and a message for the fix (string)

Pep8Fixer.__fixWhitespaceAroundEquals

__fixWhitespaceAroundEquals(code, line, pos, apply=False)

Private method to fix extraneous whitespace around keyword and default parameter equals.

code
code of the issue (string)
line
line number of the issue (integer)
pos
position inside line (integer)
apply=
flag indicating, that the fix should be applied (boolean)
Returns:
flag indicating an applied fix (boolean) and a message for the fix (string)

Pep8Fixer.__fixWhitespaceAroundOperator

__fixWhitespaceAroundOperator(code, line, pos, apply=False)

Private method to fix extraneous whitespace around operator.

code
code of the issue (string)
line
line number of the issue (integer)
pos
position inside line (integer)
apply=
flag indicating, that the fix should be applied (boolean)
Returns:
flag indicating an applied fix (boolean) and a message for the fix (string)

Pep8Fixer.__fixWhitespaceBefore

__fixWhitespaceBefore(code, line, pos, apply=False)

Private method to fix superfluous whitespace before '}])', ',;:' and '(['.

code
code of the issue (string)
line
line number of the issue (integer)
pos
position inside line (integer)
apply=
flag indicating, that the fix should be applied (boolean)
Returns:
flag indicating an applied fix (boolean) and a message for the fix (string)

Pep8Fixer.__fixWhitespaceBeforeInline

__fixWhitespaceBeforeInline(code, line, pos, apply=False)

Private method to fix missing whitespace before inline comment.

code
code of the issue (string)
line
line number of the issue (integer)
pos
position inside line (integer)
apply=
flag indicating, that the fix should be applied (boolean)
Returns:
flag indicating an applied fix (boolean) and a message for the fix (string)

Pep8Fixer.__getEol

__getEol()

Private method to get the applicable eol string.

Returns:
eol string (string)

Pep8Fixer.fixIssue

fixIssue(line, pos, message)

Public method to fix the fixable issues.

line
line number of issue (integer)
pos
character position of issue (integer)
message
message text (string)
Returns:
flag indicating an applied fix (boolean) and a message for the fix (string)

Pep8Fixer.saveFile

saveFile(encoding)

Public method to save the modified file.

encoding
encoding of the source file (string)
Returns:
flag indicating success (boolean)
Up