fix: use raw strings for regex patterns in Lesson 6.1 grading#149
Open
Maanik23 wants to merge 1 commit intoanthropics:masterfrom
Open
fix: use raw strings for regex patterns in Lesson 6.1 grading#149Maanik23 wants to merge 1 commit intoanthropics:masterfrom
Maanik23 wants to merge 1 commit intoanthropics:masterfrom
Conversation
The REGEX_CATEGORIES dict in Exercise 6.1 uses backslash-escaped parentheses (e.g., "A\) P") which triggers Python SyntaxWarning for invalid escape sequences. Adding the r prefix makes them proper raw strings so the regex engine receives the intended patterns. Fixed across all three tutorial variants: Anthropic 1P, AmazonBedrock anthropic, and AmazonBedrock boto3. Fixes anthropics#103
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.
Fixes #103
Summary
The
REGEX_CATEGORIESdictionary in Exercise 6.1 uses backslash-escaped parentheses (e.g.,"A\) P") as regex patterns. Without therprefix, Python interprets\)as an invalid escape sequence, raisingSyntaxWarningin Python 3.12+ and potentially causingDeprecationWarningin earlier versions.Changes
Added the
r(raw string) prefix to all four regex pattern strings inREGEX_CATEGORIESacross all three tutorial variants:Files changed:
prompt_engineering_interactive_tutorial/Anthropic 1P/06_Precognition_Thinking_Step_by_Step.ipynbprompt_engineering_interactive_tutorial/AmazonBedrock/anthropic/06_Precognition_Thinking_Step_by_Step.ipynbprompt_engineering_interactive_tutorial/AmazonBedrock/boto3/06_Precognition_Thinking_Step_by_Step.ipynbTest plan
REGEX_CATEGORIESin Exercise 6.1 is affected (Exercise 6.2 uses XML tag patterns which don't need escaping)