Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line continuation indent for triple-strings #45

Merged
merged 1 commit into from
Aug 16, 2024

Conversation

fredrikekre
Copy link
Owner

@fredrikekre fredrikekre commented Aug 16, 2024

This patch introduces line continuation based indent for triple strings,
which typically span multiple lines without any explicit newlines in the
syntax tree (since they are hidden inside the string).

This result in the following changes, some of which are clearly
bugfixes:

Operator chains:

 """
 abc
 """ * """
-def
-"""
+    def
+    """

Operator chain as assignment right hand side:

 x = """
-abc
-""" * """
-def
-"""
+    abc
+    """ * """
+    def
+    """

Implicit tuples:

 """
 abc
 """,
   """
-def
-"""
+    def
+    """

Note that single triple strings as a right hand side is excluded from
the indent rule, similar to having if/try/let/... blocks as a right
hand side.

This patch introduces line continuation based indent for triple strings,
which typically span multiple lines without any explicit newlines in the
syntax tree (since they are hidden inside the string).

This result in the following changes, some of which are clearly
bugfixes:

Operator chains:
```diff
 """
 abc
 """ * """
-def
-"""
+    def
+    """
```

Operator chain as assignment right hand side:
```diff
 x = """
-abc
-""" * """
-def
-"""
+    abc
+    """ * """
+    def
+    """
```

Implicit tuples:
```diff
 """
 abc
 """,
   """
-def
-"""
+    def
+    """
```

Note that single triple strings as a right hand side is excluded from
the indent rule, similar to having `if/try/let/...` blocks as a right
hand side.
@fredrikekre fredrikekre merged commit af1b737 into master Aug 16, 2024
14 checks passed
@fredrikekre fredrikekre deleted the fe/continue-triple-strings branch August 16, 2024 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant