openrewrite / rewrite-python

OpenRewrite recipes for Python.
Apache License 2.0
17 stars 5 forks source link

Comma delimiter is removed #45

Open traceyyoshima opened 1 year ago

traceyyoshima commented 1 year ago
    @Test
    void test() {
        rewriteRun(
          python(
            """
              candidates = [
                  ("tmp/../path", "tmp/.."),
                  ("tmp\\\\..\\\\path", "tmp/.."),
                  ("/tmp/../path", "/tmp/.."),
                  ("\\\\tmp\\\\..\\\\path", "/tmp/.."),
              ]
              """
          )
        );
    }
traceyyoshima commented 1 year ago

Update: The issue is caused by mapExpressionsAsRightPadded.

TODO: Add a method similar to other Parsers like convertAll(@Nullable PsiElement[] elements) that will automatically create the appropriate empty container OR a JContainer that handles trailing commas. Note: TrailingCommas marker already exists.