Closed OtherBarry closed 2 years ago
This doesn't seem to trigger on the examples in PEP 636, which I added to Shed's test suite in #47.
It would be very helpful if you could upgrade to that version, check that it still occurs, and then provide a file which triggers this problem! Otherwise I'm stuck in "can't reproduce 😢" territory, and can't do much. Minimal examples preferred, but if you want to just dump the whole original file that's fine too.
Still getting the issue.
Created a fresh virtualenv and ran pip install shed
. Pip freeze now outputs this:
autoflake==1.5.3
black==22.8.0
click==8.1.3
com2ann==0.3.0
isort==5.10.1
libcst==0.4.7
mypy-extensions==0.4.3
pathspec==0.10.1
platformdirs==2.5.2
pyflakes==2.5.0
pyupgrade==2.37.3
PyYAML==6.0
shed==0.10.2
tokenize-rt==4.2.1
toml==0.10.2
tomli==2.0.1
typing-inspect==0.8.0
typing_extensions==4.3.0
I created a file named shed_test.py, with the following content
import random
choice = random.choice(["foo", "bar", "baz", "error"])
match choice:
case "foo":
print("foo")
case "bar":
print("bar")
case "baz":
print("baz")
case _:
print("Something went wrong")
It runs as expected with python 3.10.4. When I run shed --py310-plus shed_test.py
, I get the following error:
Internal error formatting 'shed_test.py': InvalidInput: Cannot parse: 5:6: match choice:
Please report this to https://github.com/Zac-HD/shed/issues
OK, thanks for the repro! I've got a partial fix to clean up and release later this week - I had a bug which wasn't enforcing the lower bound, which would have been fine except that Black doesn't detect that "match statement implies 3.10+".
I'll also need to fix the way versions are configured for LibCST (for --refactor
mode), since apparently their transition to Rust added support for pattern matching but didn't list 3.9 or later in the known versions 😕
Fixed in 0.10.3 / https://github.com/Zac-HD/shed/commit/6abc9b62de9e788d54cfaf25228e3310c18353be 🙂
Thanks, works great!
When I run shed in a repo that uses pattern matching, I get the following error:
Let me know if there's anything I can do to assist.