squabble.lint module¶
linting engine
-
class
squabble.lint.
Severity
[source]¶ Bases:
enum.Enum
Enumeration describing the relative severity of a
LintIssue
.By themselves, these values don’t mean much, but are meant to convey the likely hood that a detected issue is truly problematic. For example, a syntax error in a migration would be
CRITICAL
, but perhaps a naming inconsistency would beLOW
.-
LOW
= 'LOW'¶
-
MEDIUM
= 'MEDIUM'¶
-
HIGH
= 'HIGH'¶
-
CRITICAL
= 'CRITICAL'¶
-
-
squabble.lint.
check_file
(config, name, contents)[source]¶ Return a list of lint issues from using
config
to lintname
.
-
class
squabble.lint.
Session
(rules, sql_text, file_name)[source]¶ Bases:
object
A run of the linter using a given set of rules over a single file. This class exists mainly to hold the list of issues returned by the enabled rules.
-
class
squabble.lint.
Context
(session)[source]¶ Bases:
object
Contains the node tag callback hooks enabled at or below the parent_node passed to the call to traverse.
>>> import pglast >>> ast = pglast.Node(pglast.parse_sql(''' ... CREATE TABLE foo (id INTEGER PRIMARY KEY); ... ''')) >>> ctx = Context(session=...) >>> >>> def create_stmt(child_ctx, node): ... print('create stmt') ... child_ctx.register('ColumnDef', lambda _c, _n: print('from child')) ... >>> ctx.register('CreateStmt', create_stmt) >>> ctx.register('ColumnDef', lambda _c, _n: print('from root')) >>> ctx.traverse(ast) create stmt from child from root
-
traverse
(parent_node)[source]¶ Recursively walk down the AST starting at parent_node.
For every node, call any callback functions registered for that particular node tag.
-
register_exit
(fn)[source]¶ Register fn to be called when the current node is finished being traversed.
-