def dialect_shell_complete(ctx, param, incomplete): """Shell completion for possible dialect names. We use this over click.Choice as we want to internally handle error messages and codes for incorrect/outdated dialects. """ dialect_names = [e.label for e in list_dialects()] return [ completion.CompletionItem(name) for name in dialect_names if name.startswith(incomplete) ]
def test__api__info_dialects(): """Basic linting of dialects.""" dialects = sqlfluff.list_dialects() assert isinstance(dialects, list) assert ("ansi", "ansi", "nothing") in dialects
"""Export global config variables.""" import sqlfluff SQLFLUFF_VERSION = sqlfluff.__version__ VALID_DIALECTS = tuple(d.name for d in sqlfluff.list_dialects()) # dict mapping string rule names to descriptions VALID_RULES = {r.code: r.description for r in sqlfluff.list_rules()}
"""This is an example of how get basic options from sqlfluff.""" import sqlfluff # -------- DIALECTS ---------- dialects = sqlfluff.list_dialects() # dialects = [DialectTuple(label='ansi', name='ansi', inherits_from='nothing'), ...] dialect_names = [dialect.label for dialect in dialects] # dialect_names = ["ansi", "snowflake", ...] # -------- RULES ---------- rules = sqlfluff.list_rules() # rules = [ # RuleTuple( # code='Example_L001', # description='ORDER BY on these columns is forbidden!' # ), # ... # ] rule_codes = [rule.code for rule in rules] # rule_codes = ["L001", "L002", ...]