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 all invalid escape sequences #49004

Merged

Conversation

bluenote10
Copy link
Contributor

Why are these changes needed?

This PR fixes all invalid escape sequences, and enables the corresponding flake8 rule W605.

This came up as part of #48921, leading to the wrong conclusion that the mypy hiccup is related to invalid escape sequences. Most likely it isn't (python/mypy#18215 (comment)), but it may still be a good idea to get rid of these to avoid unnecessary warnings and confusion.

I couldn't really figure out how flake8 is executed by the CI, because just running flake8 on the master branch actually fails, and running scripts/format.sh doesn't seem to do anything (most likely because it only checks the diff, and isn't a full check). So I'm wondering if enabling the W605 check currently actually has much of an effect.

Related issue number

Related to #48921

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@bluenote10 bluenote10 force-pushed the fix_all_invalid_escape_sequences branch from 4e7e167 to ee9f0c7 Compare December 1, 2024 20:31
Signed-off-by: Fabian Keller <[email protected]>
@alexeykudinkin
Copy link
Contributor

@bluenote10 thank you very much for doing the clean up!

Can you please take a look at the CI failures?

Signed-off-by: Fabian Keller <[email protected]>
@bluenote10
Copy link
Contributor Author

@bluenote10 thank you very much for doing the clean up!

With pleasure 😉

Can you please take a look at the CI failures?

Good catch: There were actually a few regexes where the \ was partially escaped and non-escaped. I've re-checked them all, and hope they are now all fixed.

@jcotant1 jcotant1 added the data Ray Data-related issues label Dec 2, 2024
@alexeykudinkin alexeykudinkin added the go add ONLY when ready to merge, run all tests label Dec 4, 2024
@@ -26,7 +26,7 @@

@DeveloperAPI
class DoublyRobust(OffPolicyEstimator):
"""The Doubly Robust estimator.
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, these aren't regexes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but docstrings can also contain invalid escape sequences. See for instance the noise coming out of mypy in #48921, which points to malformed docstrings.

I would assume that most likely these docstrings were written thinking that a \ is just a plain \, which raw string literals achieve.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, but the solution isn't to annotate it as regex though, right?

Solution should be to escape the slash

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean by "annotate it as regex"?

Using raw string literals like r"""...""" has nothing to do with regexes. They are just string literals where the \ is not used as an escape code for introducing special chars like \n or \r.

It just happens to be common to use raw string literals when writing regexes, because it often involves \ and the raw string literal avoid having to escape them all.

@richardliaw
Copy link
Contributor

@alexeykudinkin could you take another pass at this?

Copy link

stale bot commented Jan 22, 2025

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

  • If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@stale stale bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Jan 22, 2025
@pcmoritz pcmoritz requested a review from a team as a code owner February 8, 2025 18:13
@stale stale bot removed the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Feb 8, 2025
@pcmoritz
Copy link
Contributor

pcmoritz commented Feb 8, 2025

Thanks a lot for working on this @bluenote10, let's get this merged if the tests pass :)

@pcmoritz pcmoritz merged commit 3faccef into ray-project:master Feb 9, 2025
5 checks passed
@pcmoritz
Copy link
Contributor

pcmoritz commented Feb 9, 2025

@bluenote10 Thanks a lot for your contribution, and sorry for the delay in getting this merged 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data Ray Data-related issues go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants