# Buggy code
def process(
    self, *, in_str: str, fname: Optional[str] = None, config=None
) -> Tuple[Optional[TemplatedFile], list]:
    """Process a string and return a TemplatedFile.

    Note that the arguments are enforced as keywords
    because Templaters can have differences in their
    `process` method signature.
    A Templater that only supports reading from a file
    would need the following signature:
        process(*, fname, in_str=None, config=None)
    (arguments are swapped)

    Args:
        in_str (:obj:`str`): The input string.
        fname (:obj:`str`, optional): The filename of this string. This is
            mostly for loading config files at runtime.
        config (:obj:`FluffConfig`): A specific config to use for this
            templating operation. Only necessary for some templaters.

    """
    live_context = self.get_context(fname=fname, config=config)
    try:
        new_str = in_str.format(**live_context)
    except KeyError as err:
        # TODO: Add a url here so people can get more help.
        raise SQLTemplaterError(
            "Failure in Python templating: {0}. Have you configured your variables?".format(
                err
            )
        )
    raw_sliced, sliced_file = self.slice_file(in_str, new_str)
    return (
        TemplatedFile(
            source_str=in_str,
            templated_str=new_str,
            fname=fname,
            sliced_file=sliced_file,
            raw_sliced=raw_sliced,
        ),
        [],
    )


# Traceback (IndexError)
Traceback (most recent call last):
File "/Users/niallwoodward/dev/pull_requests/dbt_sqlfluff_venv/bin/sqlfluff", line 11, in <module>
load_entry_point('sqlfluff', 'console_scripts', 'sqlfluff')()
File "/Users/niallwoodward/dev/pull_requests/dbt_sqlfluff_venv/lib/python3.6/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/Users/niallwoodward/dev/pull_requests/dbt_sqlfluff_venv/lib/python3.6/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/Users/niallwoodward/dev/pull_requests/dbt_sqlfluff_venv/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/niallwoodward/dev/pull_requests/dbt_sqlfluff_venv/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/niallwoodward/dev/pull_requests/dbt_sqlfluff_venv/lib/python3.6/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/Users/niallwoodward/dev/pull_requests/sqlfluff/src/sqlfluff/cli/commands.py", line 323, in lint
ignore_files=not disregard_sqlfluffignores,
File "/Users/niallwoodward/dev/pull_requests/sqlfluff/src/sqlfluff/core/linter.py", line 1161, in lint_paths
ignore_files=ignore_files,
File "/Users/niallwoodward/dev/pull_requests/sqlfluff/src/sqlfluff/core/linter.py", line 1139, in lint_path
target_file.read(), fname=fname, fix=fix, config=config
File "/Users/niallwoodward/dev/pull_requests/sqlfluff/src/sqlfluff/core/linter.py", line 939, in lint_string
parsed = self.parse_string(in_str=in_str, fname=fname, config=config)
File "/Users/niallwoodward/dev/pull_requests/sqlfluff/src/sqlfluff/core/linter.py", line 723, in parse_string
tokens, lex_vs = lexer.lex(templated_file)
File "/Users/niallwoodward/dev/pull_requests/sqlfluff/src/sqlfluff/core/parser/lexer.py", line 343, in lex
return self.enrich_segments(segment_buff, raw), violations
File "/Users/niallwoodward/dev/pull_requests/sqlfluff/src/sqlfluff/core/parser/lexer.py", line 373, in enrich_segments
templated_slice
File "/Users/niallwoodward/dev/pull_requests/sqlfluff/src/sqlfluff/core/templaters/base.py", line 283, in templated_slice_to_source_slice
elif start_slices[0][0] == "literal":
IndexError: list index out of range

# Fixed code
def process(
    self, *, in_str: str, fname: Optional[str] = None, config=None
) -> Tuple[Optional[TemplatedFile], list]:
    """Process a string and return a TemplatedFile.

    Note that the arguments are enforced as keywords
    because Templaters can have differences in their
    `process` method signature.
    A Templater that only supports reading from a file
    would need the following signature:
        process(*, fname, in_str=None, config=None)
    (arguments are swapped)

    Args:
        in_str (:obj:`str`): The input string.
        fname (:obj:`str`, optional): The filename of this string. This is
            mostly for loading config files at runtime.
        config (:obj:`FluffConfig`): A specific config to use for this
            templating operation. Only necessary for some templaters.

    """
    live_context = self.get_context(fname=fname, config=config)
    try:
        new_str = in_str.format(**live_context)
    except KeyError as err:
        # TODO: Add a url here so people can get more help.
        raise SQLTemplaterError(
            "Failure in Python templating: {0}. Have you configured your variables?".format(
                err
            )
        )
    raw_sliced, sliced_file, new_str = self.slice_file(in_str, new_str, config=config)
    return (
        TemplatedFile(
            source_str=in_str,
            templated_str=new_str,
            fname=fname,
            sliced_file=sliced_file,
            raw_sliced=raw_sliced,
        ),
        [],
    )