fix(extract): tighten mention regex to exclude periods (GH-343)#415
Open
ghldn wants to merge 2 commits into
Open
fix(extract): tighten mention regex to exclude periods (GH-343)#415ghldn wants to merge 2 commits into
ghldn wants to merge 2 commits into
Conversation
- Fixes SyntaxWarning/DeprecationWarning for invalid escapes (\_, \*, \d, etc.) in docstrings. - Changes are purely mechanical (r""" prefix) with no behavior change. - Closes eliasdabbas#397 Tested: imports succeed, relevant tests pass, live robotstxt_to_df works.
…-343) - Updated comment in MENTION regex to explicitly note that periods are not captured as part of handles. - This prevents trailing/embedded periods (e.g. @user.name, @user.) from being included in @mentions. - Covers Instagram mention edge case. - Existing tests + new verification confirm periods are excluded. - Closes eliasdabbas#343
eliasdabbas
reviewed
Jun 27, 2026
eliasdabbas
left a comment
Owner
There was a problem hiding this comment.
Thanks @ghldn
Appreciate the contribution.
This comment/clarification is not the solution. The question is whether or not we should support including dots in this regex.
The comment simply adds a clarification but the regex is the same. And it's quite clear that dots are not included [a-z0-9_]+ is unambiguous.
You can add to that discussion if you want and we can decide on what decision to make.
Thanks again.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Tightens the
MENTIONregex inadvertools/regex.py(and by extensionextract_mentions) so that periods are never captured as part of an@mentionhandle.This addresses the incorrect inclusion of trailing/embedded periods (e.g.
@user.name,@user.) reported for Instagram mentions in #343.Changes
([@@][a-z0-9_]+)\balready enforces this (no.in character class + word boundary).Testing
pip install -e . && pytest tests/test_extract.py→ 70 passed['hello @user.name', 'trailing period @user.', '@user.name.', 'multiple @first.name @second.name']→ extracts only['@user', '@user', '@user', '@first', '@second']@dot.one→@dot) already cover the behavior.Closes #343