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

adding escapting of backslashes for re.sub value #84

Merged
merged 1 commit into from
Aug 30, 2023

Conversation

assaftibm
Copy link
Member


Status

READY

Description

Adding escaping for back-slashes in re.sub() value.

Impacted Areas in Library

prompt template creation

Which issue(s) does this pull-request fix?

Closes: #83

Any special notes for your reviewer?


Checklist

  • Automated tests exist
  • Updated Package Requirements (if required, and with maintainers' approval)
  • Local unit tests performed
  • Documentation exists link
  • Local pre-commit hooks performed
  • Desired commit message set as PR title and description set above
  • Link to relevant GitHub issue provided

@coveralls
Copy link

coveralls commented Jul 10, 2023

Pull Request Test Coverage Report for Build 5506270401

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 94.737%

Totals Coverage Status
Change from base Build 5425902251: 0.0%
Covered Lines: 1242
Relevant Lines: 1311

💛 - Coveralls

@Tomas2D
Copy link
Member

Tomas2D commented Jul 24, 2023

Firstly, this is a breaking change, and secondly, the user should escape it.
If you add this feature there is no way to pass only a single backslash (\).

@assaftibm
Copy link
Member Author

@Tomas2D

  1. The user isn't aware of prompt.sub() using re.sub() so he/she is not aware of the need to escape backslashes.

  2. The official Python docs say that

for the replacement string in sub() and subn(), only backslashes should be escaped

So I see no harm in escaping back slashes in the call to re.sub().

  1. Not sure why you say that there is no way to pass a single slash. The escaping doesn't make it a double slash in the substitution; it just prevents the slash from being interpreted as part of a meta character like \S or \C.

@Tomas2D
Copy link
Member

Tomas2D commented Aug 30, 2023

Hey @assaftibm! I've reconsidered my decision, and I now see there is no harm in merging this.
Thanks for the reported issue and for creating this PR.

@Tomas2D Tomas2D merged commit c7a642c into IBM:develop Aug 30, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants