The problem is basically that Python packaging usually is a bit fuzzy. That's
why I prefer to have this in there for quite some time to avoid conflicts of
version mismatches between Jedi/Parso.
- Add `NodeOrLeaf.dump()` to generate a readable and "round-trippable" dump for a parser tree
- `parso.tree.search_ancestor()` is deprecated, use `NodeOrLeaf.search_ancestor()` instead
- Set up children's parent in `BaseNode.__init__()`
- Add test for `search_ancestor`
- Various small type annotations improvements
- Properly check for starred expression deletion
- Check for starred expressions not in tuple/list/set (when not in assignment)
- Fix a bug that considered starred expression assignment `[*x] = 1` as invalid
- Enhance test cases for valid and invalid `del` statements and starred expressions
* Support named unicode characters in f-strings
Fixes#154
The previous behavior misinterpreted the curly braces as enclosing an
expression. This change does some cursory validation so we can still
get parse errors in the most egregious cases, but does not validate that
the names are actually valid, only that they are name-shaped and have a
chance of being valid.
The character names appear to obey a few rules:
* Case insensitive
* Name characters are `[A-Z0-9 \-]`
* Whitespace before or after is not allowed
* Whitespace in the middle may only be a single space between words
* Dashes may occur at the start or middle of a word
```py
f"\N{A B}" # might be legal
f"\N{a b}" # equivalent to above
f"\N{A B}" # no way
f"\N{ A B }" # no way
f"""\N{A
B}""" # no way
```
For confirming this regex matches all (current) unicode character names:
```py
import re
import sys
import unicodedata
R = re.compile(r"[A-Za-z0-9\-]+(?: [A-Za-z0-9\-]+)*")
for i in range(sys.maxunicode):
try:
name = unicodedata.name(chr(i))
except ValueError:
# Some small values like 0 and 1 have no name, /shrug
continue
m = R.fullmatch(name)
if m is None:
print("FAIL", repr(name))
```
* Improve tests for named unicode escapes