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

More regex as string literal #586

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

jmartin-tech
Copy link
Collaborator

@jmartin-tech jmartin-tech commented Apr 8, 2024

Python 3.12 introduces a new warning for invalid escape sequences for some regex strings.

Update string literal notation for regex.

Found during testing:

% python -m garak -m huggingface.Model -n meta-llama/Llama-2-7b-chat-hf -p dan.AutoDAN
...
🕵️  queue of probes: dan.AutoDAN
garak/garak/resources/autodan/genetic.py:234: SyntaxWarning: invalid escape sequence '\s'
  sentences1 = [s for s in re.split("(?<=[.!?])\s+", str1) if s]
/garak/garak/resources/autodan/genetic.py:235: SyntaxWarning: invalid escape sequence '\s'
  sentences2 = [s for s in re.split("(?<=[.!?])\s+", str2) if s]
[nltk_data] Downloading package stopwords to

… some regex strings.

Update string literal notation for regex.
Copy link
Collaborator

@erickgalinkin erickgalinkin left a comment

Choose a reason for hiding this comment

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

LGTM

@leondz leondz merged commit eb82b47 into leondz:main Apr 8, 2024
1 check passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 8, 2024
@jmartin-tech jmartin-tech deleted the fix/more-regex-literal branch April 8, 2024 15:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants