Support for PEP3131 (Non-ASCII Identifiers) #160
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the process of using Baron for some research on source pulled from hundreds/thousands of repositories on GitHub, I've found that in many cases Baron is unable to tokenize/parse source containing non-ASCII identifiers.
Non-ASCII identifiers are supported by (at least as far back as) Python 3, as specified by PEP3131.
This pull request includes some very small changes that allow Baron to handle non-ASCII identifiers:
re
module with a dependency on theregex
module.regex
supports Unicode character property classes.NAME
tokens:[a-zA-Z_]\w*
[\p{XID_Start}_]\p{XID_Continue}*
I have checked that all tests pass without regression, and have added another simple test:
Note:
PEP3131 states:
However, this seems to be an error, as XID_Start does not contain
_
by default (though the Unicode specifications suggest a Start class could or should contain it.