Skip to content
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

Ignore quantifiers when splitting comma-separated regexes #8898

Merged
merged 12 commits into from
Jul 30, 2023

Conversation

jacobtylerwalls
Copy link
Member

@jacobtylerwalls jacobtylerwalls commented Jul 29, 2023

Successor to #7241 with cosmetic updates applied and merge conflicts/tests fixed.

lihu and others added 5 commits July 28, 2022 18:28
Do not split on commas if they are between braces, since that indicates
a quantifier. Also added a protection for slow implementations since
existing workarounds may result in long strings of chained regular
expressions.
Overkill, slows down unit tests

Co-authored-by: Pierre Sassoulas <[email protected]>
@github-actions

This comment has been minimized.

@codecov
Copy link

codecov bot commented Jul 29, 2023

Codecov Report

Merging #8898 (4de6f9d) into main (1f8c4d9) will decrease coverage by 0.01%.
The diff coverage is 95.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #8898      +/-   ##
==========================================
- Coverage   95.88%   95.88%   -0.01%     
==========================================
  Files         173      173              
  Lines       18552    18570      +18     
==========================================
+ Hits        17789    17806      +17     
- Misses        763      764       +1     
Files Changed Coverage Δ
pylint/utils/__init__.py 100.00% <ø> (ø)
pylint/utils/utils.py 87.30% <94.73%> (+0.75%) ⬆️
pylint/config/argument.py 100.00% <100.00%> (ø)

@github-actions

This comment has been minimized.

@jacobtylerwalls jacobtylerwalls linked an issue Jul 30, 2023 that may be closed by this pull request
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

mbyrnepr2
mbyrnepr2 previously approved these changes Jul 30, 2023
@jacobtylerwalls
Copy link
Member Author

I'm going to revert the unrelated doc/news updates from fdd914a, because that will stop this from backporting cleanly.

r"""Split a comma-separated list of regexps, taking care to avoid splitting
a regex employing a comma as quantifier, as in `\d{1,2}`."""
if isinstance(value, (list, tuple)):
yield from value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codecov message looks important since that line yields a value and apparently isn’t covered?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No current code path sends a list of strings to this util, or the one above it (also missing coverage for the analogous line). Should we just delete these lines? Not certain--I think it makes sense to let this util be this permissive. Also helps guard against unexpected input. I'm inclined to leave as is. WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think taking the time to try to understand is not worth it vs just not touching it.

@github-actions
Copy link
Contributor

🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉

This comment was generated for commit 4de6f9d

@jacobtylerwalls jacobtylerwalls merged commit d28def9 into pylint-dev:main Jul 30, 2023
@github-actions
Copy link
Contributor

The backport to maintenance/2.17.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-maintenance/2.17.x maintenance/2.17.x
# Navigate to the new working tree
cd .worktrees/backport-maintenance/2.17.x
# Create a new branch
git switch --create backport-8898-to-maintenance/2.17.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 d28def9f9eb5e55d3571b53b11f42e4142d53167
# Push it to GitHub
git push --set-upstream origin backport-8898-to-maintenance/2.17.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-maintenance/2.17.x

Then, create a pull request where the base branch is maintenance/2.17.x and the compare/head branch is backport-8898-to-maintenance/2.17.x.

@jacobtylerwalls jacobtylerwalls deleted the 7229-take2 branch July 30, 2023 15:33
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this pull request Jul 30, 2023
…#8898)

Do not split on commas if they are between braces, since that indicates
a quantifier. Also added a protection for slow implementations since
existing workarounds may result in long strings of chained regular
expressions.

Adjust existing test for invalid regex to be truly invalid

Co-authored-by: lihu <[email protected]>
(cherry picked from commit d28def9)
jacobtylerwalls added a commit that referenced this pull request Jul 30, 2023
)

Do not split on commas if they are between braces, since that indicates
a quantifier. Also added a protection for slow implementations since
existing workarounds may result in long strings of chained regular
expressions.

Adjust existing test for invalid regex to be truly invalid

Co-authored-by: lihu <[email protected]>
(cherry picked from commit d28def9)
mbyrnepr2 pushed a commit to mbyrnepr2/pylint that referenced this pull request Aug 3, 2023
…#8898)

Do not split on commas if they are between braces, since that indicates
a quantifier. Also added a protection for slow implementations since
existing workarounds may result in long strings of chained regular
expressions.

Adjust existing test for invalid regex to be truly invalid

Co-authored-by: lihu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bad-names-rgxs mangles regular expressions with commas
3 participants