docusign-esign-python-client icon indicating copy to clipboard operation
docusign-esign-python-client copied to clipboard

Python 3.12 - SyntaxWarning: invalid escape sequence

Open joshkersey opened this issue 1 year ago • 3 comments

When running in Python 3.12 we see SyntaxWarning being raised for a couple regex strings:

/opt/venv/lib/python3.12/site-packages/docusign_esign/client/api_client.py:280: SyntaxWarning: invalid escape sequence '\['
  sub_kls = re.match('list\[(.*)\]', klass).group(1)
/opt/venv/lib/python3.12/site-packages/docusign_esign/client/api_client.py:285: SyntaxWarning: invalid escape sequence '\('
  sub_kls = re.match('dict\(([^,]*), (.*)\)', klass).group(2)

It's my understanding this can be fixed either by either escaping the backslashes (re.match('list\\[(.*)\\]', klass).group(1)) or by using a raw string literal (re.match(r'list\[(.*)\]', klass).group(1).

joshkersey avatar May 06 '24 18:05 joshkersey

Hi @joshkersey Thanks for notifying us! Do you receive this when running something in particular or is this something you're able to reproduce all the time?

karankaushik95 avatar May 07 '24 04:05 karankaushik95

Hi @joshkersey Thanks for notifying us! Do you receive this when running something in particular or is this something you're able to reproduce all the time?

This happens when the library is imported. It's documented here:

Changed in version 3.12: Unrecognized escape sequences produce a SyntaxWarning. In a future Python version they will be eventually a SyntaxError.

I fixed it in #189.

Lucianod28 avatar May 11 '24 00:05 Lucianod28

Hi @joshkersey , @Lucianod28 ,

Thanks a lot for pointing out the issue and providing a solution for the same. Due to how the SDK code is being generated, we can't merge the PR.

But we have made similar changes within 5.0.0rc1 release.

Please test out the same when possible.

Thank You.

garg-mudit avatar Jul 22 '24 19:07 garg-mudit