Fix parse test case on Python 3.12
This fixes the test case testFStringWithFormatSpecifierExpression on Python 3.12.
Strip redundant empty string literal from AST generated from f-string. It's not generated on earlier Python versions and it seems fine to just drop it.
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅
Looks like this might be changed in CPython, so maybe we should just wait for the next 3.12 beta rather than merging this:
- https://github.com/python/cpython/pull/106401
maybe we should just wait for the next 3.12 beta rather than merging this
We can wait until the next beta, unless perhaps we want to enable 3.12 in CI before the next beta is available. I'll keep this open for now.
unless perhaps we want to enable 3.12 in CI before the next beta is available.
For now could we maybe just skip the test? I can't remember the pytest equivalent off the top of my head, but for unittest I'd just decorate the test with:
@skipIf(
sys.version_info[:4] == (3, 12, 0, "beta") and sys.version_info[4] < 4,
"Early 3.12 betas had a bug"
)
Though mypy's test suite is very data-driven I guess, so maybe it's more difficult to be that granular for a single test case
This is still failing for me on Python 3.12.0 beta 4. I'm leaning towards merging this. We can always revert this afterwards if it's no longer needed.
This is still failing for me on Python 3.12.0 beta 4. I'm leaning towards merging this. We can always revert this afterwards if it's no longer needed.
Makes sense!