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

Fix SyntaxError by replacing regular string regex to raw string Regex in python 3.12 #38119

Closed

Conversation

GameSetAndMatch
Copy link

@GameSetAndMatch GameSetAndMatch commented Oct 28, 2024

Description

Pytest tests fail when importing the azure-search-documents==11.5.1 library due to syntax error when using python 3.12.

Related documentation about the issue

As documented in this python 3.12 change information, SyntaxWarning are now replaced by SyntaxError.

A backslash-character pair that is not a valid escape sequence now generates a SyntaxWarning, instead of DeprecationWarning. For example, re.compile("\d+.\d+") now emits a SyntaxWarning ("\d" is an invalid escape sequence, use raw strings for regular expression: re.compile(r"\d+.\d+")). In a future Python version, SyntaxError will eventually be raised, instead of SyntaxWarning. (Contributed by Victor Stinner in gh-98401.)

and also the python regex doc

In addition, special escape sequences that are valid in regular expressions, but not valid as Python string literals, now result in a DeprecationWarning and will eventually become a SyntaxError, which means the sequences will be invalid if raw string notation or escaping the backslashes isn’t used.

To fix the issues, I added the raw string notation before the "\W+" patterns where necessary.

If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@github-actions github-actions bot added Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Search labels Oct 28, 2024
Copy link

Thank you for your contribution @GameSetAndMatch! We will review the pull request and get back to you soon.

@GameSetAndMatch
Copy link
Author

GameSetAndMatch commented Oct 28, 2024

Draft PR as I do not pass the Contribution Checklist.

@GameSetAndMatch GameSetAndMatch changed the title Update _models_py3.py by replacing regular string regex to raw string Regex Fix SyntaxError by replacing regular string regex to raw string Regex in python 3.12 Oct 28, 2024
@GameSetAndMatch GameSetAndMatch marked this pull request as ready for review October 28, 2024 18:03
@xiangyan99
Copy link
Member

Thanks for your contribution.

This code is auto-generated and we don't modify it manually.

I have the fix in my PR: #38110

Thanks.

@xiangyan99 xiangyan99 closed this Oct 28, 2024
@GameSetAndMatch
Copy link
Author

GameSetAndMatch commented Oct 28, 2024

Thank you for the update. Any way I can use your PR on dev release or pypi prerelease?

I am not developpong production code.

Thanks!

@xiangyan99

@xiangyan99
Copy link
Member

Thank you for the update. Any way I can use your PR on dev release or pypi prerelease?

I am not developpong production code.

Sure. It is open-source project, and you can download the code and use pip install -e <path_to_the_search_library> to install it.

We will have a release with the fix in Nov.

And to clarify, this will be a preview release. The feature is not ready to GA yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Search
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants