Possible indentation bug related to `py-indent-list-style`
I am editing the following code:
import os
import pytest
from contextlib import ExitStack
from sybil import Sybil
from doctest import ELLIPSIS, REPORT_NDIFF, NORMALIZE_WHITESPACE
from sybil.parsers.doctest import DocTestParser
from sybil.parsers.codeblock import PythonCodeBlockParser
DOCTEST_FLAGS = ELLIPSIS | NORMALIZE_WHITESPACE | REPORT_NDIFF
class DoctestNamespace:
def __init__(self):
self._resources = ExitStack()
def setup(self, namespace):
# The docs include an example of how enums can be pickled and
# unpickled. For this, our test module must be importable. Hack
# sys.path so that the `fruit.py` module (containing an enum for the
# pickle tests) can be imported. There's probably a more robust way to
# do this, but it works and is simple so fix it only if necessary.
test_dir = os.path.join(os.getcwd(), 'test')
assert os.path.isfile(os.path.join(test_dir, 'fruit.py'))
self._resources.enter_context(pytest.MonkeyPatch
def teardown(self, namespace):
self._resources.close()
namespace = DoctestNamespace()
pytest_collect_file = Sybil(
parsers=[
DocTestParser(optionflags=DOCTEST_FLAGS),
PythonCodeBlockParser(),
],
pattern='*.rst',
setup=namespace.setup,
).pytest()
Point is on L:26,C:38, i.e. the p
in pytest.MonkeyPatch
.
If I hit RET
with py-indent-list-style
set to line-up-with-first-element
I get this:
self._resources.enter_context(
pytest.MonkeyPatch
If I hit RET
with py-indent-list-style
set to one-level-to-beginning-of-statement
I get this:
self._resources.enter_context(
pytest.MonkeyPatch
The second case is what I want, and I would expect most people would want.
Here's the confusion though: I am not in a list, I'm in a function call. From reading the customize docs for the variable, it seems like the intent of py-indent-list-style
is intended to affect function definitions, not lists. Does "lists" in the variable name imply any open parenthesis statement? I.e. like here where I'm writing a function call? I gather it also affects multi-line lists (and tuples, etc?), but I can also imagine I might want different behavior for those types of constructs.
Anyway, if everything is working as intended, feel free to close this issue, although in this case I might suggest that the name of the variable or its customize docs could be improved.
Thanks!