Skip to content

Conversation

sven-oly
Copy link
Collaborator

Some regex compilations need to use 'r' in front of their pattern strings.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @sven-oly, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily addresses an issue with Python regular expressions by ensuring that pattern strings are correctly interpreted as raw strings using the r prefix. This prevents backslashes from being treated as escape sequences within the regex patterns, improving their reliability. Additionally, the run_config.json file has been updated to remove the datetime_fmt test type from various test configurations across different execution environments.

Highlights

  • Python Regex Fixes: Applied r prefix to several regex pattern strings in Python generator files (collation.py, number_fmt.py, plurals.py) to ensure correct interpretation of backslashes and prevent unintended escape sequence processing.
  • Test Configuration Update: Removed datetime_fmt from the test_type arrays in run_config.json for multiple executors (C++, Node.js, Dart Native, Dart Web, Rust, ICU4J), streamlining the test configurations.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to fix Python regular expressions by using raw strings. The changes in testgen/generators/number_fmt.py and testgen/generators/plurals.py are correct and follow best practices.

However, the changes in testgen/generators/collation.py introduce a bug. While using raw strings is a good idea, the number of backslashes is now incorrect, which will cause the regex to fail to match the intended patterns. I've left a specific comment with a suggested fix.

Additionally, this PR includes the removal of "datetime_fmt" from many test configurations in run_config.json. This seems unrelated to the stated goal of fixing Python regexes. Could you please clarify if this is an intended change and provide some context in the PR description?

@sven-oly sven-oly self-assigned this Aug 21, 2025
@sven-oly
Copy link
Collaborator Author

This doesn't change any test output, but cleans up some warnings during Python script evaluation.

@sven-oly sven-oly requested review from echeran and sffc August 22, 2025 23:38
@sffc sffc requested a review from Copilot August 26, 2025 21:21
Copilot

This comment was marked as outdated.

@sffc sffc requested a review from Copilot August 26, 2025 21:25
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes Python regex compilation by adding raw string literals (prefixed with 'r') to regex pattern strings that contain escape sequences. This prevents Python from interpreting backslashes as escape characters before the regex engine processes them.

  • Added raw string literals to regex patterns containing escape sequences
  • Fixed potential issues with backslash interpretation in regex compilation
  • Applied changes consistently across multiple generator files

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
testgen/generators/plurals.py Added raw string literal to blank line regex pattern
testgen/generators/number_fmt.py Added raw string literals to blank line and comment line regex patterns
testgen/generators/collation.py Added raw string literals to Unicode escape sequence regex patterns

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@sven-oly sven-oly merged commit 001f0d4 into unicode-org:main Aug 29, 2025
10 checks passed
@sven-oly sven-oly deleted the fix_python_regex branch August 29, 2025 18:04
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.

3 participants