openrewrite / rewrite-python

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

Python 2 syntax: PsiPythonMapper throws IllegalStateException #34

Closed traceyyoshima closed 1 year ago

traceyyoshima commented 1 year ago

Error is thrown here:

    private void assertDiscardable() {
        if (!(this.state instanceof State.Discardable)) {
            throw new IllegalStateException("resetting would discard an active whitespace position;\n" + printDebuggingMessage("ATTEMPTED TO RESET HERE"));
        }
    }
    @Test
    void test() {
        rewriteRun(
          python(
            """
            import time

            while True:
                time.sleep(5)
                print "FooBar"
            """
          )
        );
    }
traceyyoshima commented 1 year ago

Fixed by https://github.com/openrewrite/rewrite-python/commit/8b3d7946d12db363123275a76cae277084344a15