eric6.Plugins.CheckerPlugins.CodeStyleChecker.MiscellaneousChecker

Module implementing a checker for miscellaneous checks.

Global Attributes

None

Classes

MiscellaneousChecker Class implementing a checker for miscellaneous checks.
TextVisitor Class implementing a node visitor for bytes and str instances.

Functions

None


MiscellaneousChecker

Class implementing a checker for miscellaneous checks.

Derived from

object

Class Attributes

Codes
FormatFieldRegex
Formatter

Class Methods

None

Methods

MiscellaneousChecker Constructor
__checkBlindExcept Private method to check for blind except statements.
__checkCoding Private method to check the presence of a coding line and valid encodings.
__checkCopyright Private method to check the presence of a copyright statement.
__checkFormatString Private method to check string format strings.
__checkFuture Private method to check the __future__ imports.
__checkPep3101 Private method to check for old style string formatting.
__checkPrintStatements Private method to check for print statements.
__checkTuple Private method to check for one element tuples.
__error Private method to record an issue.
__getCoding Private method to get the defined coding of the source.
__getFields Private method to extract the format field information.
__ignoreCode Private method to check if the message code should be ignored.
__reportInvalidSyntax Private method to report a syntax error.
run Public method to check the given source against miscellaneous conditions.

Static Methods

None

MiscellaneousChecker (Constructor)

MiscellaneousChecker(source, filename, select, ignore, expected, repeat, args)

Constructor

source (list of str)
source code to be checked
filename (str)
name of the source file
select (list of str)
list of selected codes
ignore (list of str)
list of codes to be ignored
expected (list of str)
list of expected codes
repeat (bool)
flag indicating to report each occurrence of a code
args (dict)
dictionary of arguments for the miscellaneous checks

MiscellaneousChecker.__checkBlindExcept

__checkBlindExcept()

Private method to check for blind except statements.

MiscellaneousChecker.__checkCoding

__checkCoding()

Private method to check the presence of a coding line and valid encodings.

MiscellaneousChecker.__checkCopyright

__checkCopyright()

Private method to check the presence of a copyright statement.

MiscellaneousChecker.__checkFormatString

__checkFormatString()

Private method to check string format strings.

MiscellaneousChecker.__checkFuture

__checkFuture()

Private method to check the __future__ imports.

MiscellaneousChecker.__checkPep3101

__checkPep3101()

Private method to check for old style string formatting.

MiscellaneousChecker.__checkPrintStatements

__checkPrintStatements()

Private method to check for print statements.

MiscellaneousChecker.__checkTuple

__checkTuple()

Private method to check for one element tuples.

MiscellaneousChecker.__error

__error(lineNumber, offset, code, *args)

Private method to record an issue.

lineNumber (int)
line number of the issue
offset (int)
position within line of the issue
code (str)
message code
args (list)
arguments for the message

MiscellaneousChecker.__getCoding

__getCoding()

Private method to get the defined coding of the source.

Returns:
tuple containing the line number and the coding
Return Type:
tuple of int and str

MiscellaneousChecker.__getFields

__getFields(string)

Private method to extract the format field information.

string (str)
format string to be parsed
Returns:
format field information as a tuple with fields, implicit field definitions present and explicit field definitions present
Return Type:
tuple of set of str, bool, bool

MiscellaneousChecker.__ignoreCode

__ignoreCode(code)

Private method to check if the message code should be ignored.

code (str)
message code to check for
Returns:
flag indicating to ignore the given code
Return Type:
bool

MiscellaneousChecker.__reportInvalidSyntax

__reportInvalidSyntax()

Private method to report a syntax error.

MiscellaneousChecker.run

run()

Public method to check the given source against miscellaneous conditions.

Up


TextVisitor

Class implementing a node visitor for bytes and str instances.

It tries to detect docstrings as string of the first expression of each module, class or function.

Derived from

ast.NodeVisitor

Class Attributes

None

Class Methods

None

Methods

TextVisitor Constructor
__addNode Private method to add a node to our list of nodes.
__isBaseString Private method to determine, if a node is a base string node.
__visitBody Private method to traverse the body of the node manually.
__visitDefinition Private method handling class and function definitions.
visit_Bytes Public method to record a bytes node.
visit_Call Public method to handle a function call.
visit_ClassDef Public method to handle a class definition.
visit_FunctionDef Public method to handle a function definition.
visit_Module Public method to handle a module.
visit_Str Public method to record a string node.

Static Methods

None

TextVisitor (Constructor)

TextVisitor()

Constructor

TextVisitor.__addNode

__addNode(node)

Private method to add a node to our list of nodes.

node (ast.AST)
reference to the node to add

TextVisitor.__isBaseString

__isBaseString(node)

Private method to determine, if a node is a base string node.

node (ast.AST)
reference to the node to check
Returns:
flag indicating a base string
Return Type:
bool

TextVisitor.__visitBody

__visitBody(node)

Private method to traverse the body of the node manually.

If the first node is an expression which contains a string or bytes it marks that as a docstring.

node (ast.AST)
reference to the node to traverse

TextVisitor.__visitDefinition

__visitDefinition(node)

Private method handling class and function definitions.

node (ast.FunctionDef or ast.ClassDef)
reference to the node to handle

TextVisitor.visit_Bytes

visit_Bytes(node)

Public method to record a bytes node.

node (ast.Bytes)
reference to the bytes node

TextVisitor.visit_Call

visit_Call(node)

Public method to handle a function call.

node (ast.Call)
reference to the node to handle

TextVisitor.visit_ClassDef

visit_ClassDef(node)

Public method to handle a class definition.

node (ast.ClassDef)
reference to the node to handle

TextVisitor.visit_FunctionDef

visit_FunctionDef(node)

Public method to handle a function definition.

node (ast.FunctionDef)
reference to the node to handle

TextVisitor.visit_Module

visit_Module(node)

Public method to handle a module.

node (ast.Module)
reference to the node to handle

TextVisitor.visit_Str

visit_Str(node)

Public method to record a string node.

node (ast.Str)
reference to the string node
Up