-
Notifications
You must be signed in to change notification settings - Fork 23
fix: Allow underscores in a combination expression #367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -193,7 +193,9 @@ class ValueReferenceConstants(Enum): | |
| _standard_string_regex = rf"(?-m:^[^{_Cc_characters}]+\z)" | ||
|
|
||
| # Latin alphanumeric, starting with a letter | ||
| _identifier_regex = r"(?-m:^[A-Za-z_][A-Za-z0-9_]*\z)" | ||
| # Shared with CombinationExpr, which §3.4.3 defines in terms of these characters. | ||
| _identifier_chars = r"A-Za-z0-9_" | ||
| _identifier_regex = rf"(?-m:^[A-Za-z_][{_identifier_chars}]*\z)" | ||
|
|
||
| # Regex for defining file filter patterns allowed for use in file dialogs. | ||
| # 1. Allowable values: "*", "*.*", and "*.[:file-extension-chars:]+". | ||
|
|
@@ -1777,12 +1779,17 @@ def _validate_range_elements(cls, value: Any) -> Any: | |
| max_length=16, | ||
| ), | ||
| ] | ||
| # Limit the CombinationExpr to characters allowed in an Identifier plus whitespace | ||
| # and the operator characters. | ||
| # §3.4.3: an Identifier's characters plus the space and the operators. Only the | ||
| # character class is shared with Identifier, not its leading-character rule. | ||
| # The space is deliberately just U+0020. The shared TokenStream folds all | ||
| # whitespace, which is wider than §3.4.3 allows, so a newline is refused here. | ||
| CombinationExpr = Annotated[ | ||
| str, | ||
| StringConstraints( | ||
| min_length=1, max_length=1280, strict=True, pattern=r"(?-m:^[A-Za-z0-9\*\(\), ]+\z)" | ||
| min_length=1, | ||
| max_length=1280, | ||
| strict=True, | ||
| pattern=rf"(?-m:^[{_identifier_chars}\*\(\), ]+\z)", | ||
|
leongdl marked this conversation as resolved.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The canonical character-class test for this exact type was not updated, so the regression this PR fixes is not pinned where a reader would look for it.
pytest.param(string.ascii_letters + string.digits, id="allowable identifier chars"),
Consequence for the mutation argument made elsewhere in this PR: re-hardcoding the pattern back to Cheapest fix is one character in the existing param, trivially safe because that model has no parser attached: pytest.param(string.ascii_letters + string.digits + "_", id="allowable identifier chars"),The same file has a |
||
| ), | ||
| ] | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.