Skip to content

Fix for python error when using python 3.12.11#189

Open
RiccardoGandolfi wants to merge 2 commits intopulp-platform:develfrom
FondazioneChipsIT:rg/deeploy_types_python_fix
Open

Fix for python error when using python 3.12.11#189
RiccardoGandolfi wants to merge 2 commits intopulp-platform:develfrom
FondazioneChipsIT:rg/deeploy_types_python_fix

Conversation

@RiccardoGandolfi
Copy link
Copy Markdown

@RiccardoGandolfi RiccardoGandolfi commented May 6, 2026

This PR adds a minor fix in the Deeploy types python file.

Added

Changed

  • Added r keyword for raw string interpretation. The previous escape sequence was breaking on python 3.12.11

Fixed

  • This fixes the following error
E     File "Deeploy/Deeploy/DeeployTypes.py", line 689
E       repStr = re.sub('\.', '_', repStr)
E                        ^^
E   SyntaxError: invalid escape sequence '\.'

PR Merge Checklist

  1. The PR is rebased on the latest devel commit and pointing to devel.
  2. Your PR reviewed and approved.
  3. All checks are passing.
  4. The CHANGELOG.md file has been updated.
  5. If the docker was modified, change back its link after review.

@RiccardoGandolfi RiccardoGandolfi changed the title [DEEPLOY] Fix for python error when running regression Fix for python error when running regression May 6, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cb9fa263-c908-4af9-8426-3d209f0a585a

📥 Commits

Reviewing files that changed from the base of the PR and between 41384b8 and 67a9a34.

📒 Files selected for processing (1)
  • CHANGELOG.md
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an invalid escape sequence error that was preventing regression tests from running successfully.

Walkthrough

The _mangle method in Deeploy/DeeployTypes.py is refactored to use raw string literals for regex patterns; a CHANGELOG entry documents a Python invalid escape sequence fix.

Changes

Regex Pattern String Literals

Layer / File(s) Summary
Code: _mangle regex refactor
Deeploy/DeeployTypes.py
Regex patterns in _mangle updated to use raw string literals (e.g., r'\.') and the final replacement adjusted accordingly.
Docs: CHANGELOG entry
CHANGELOG.md
Added a Fixed bullet under Unreleased noting an invalid escape sequence Python error in DeeployTypes.py observed during pytest regressions.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Suggested reviewers

  • Xeratec
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly addresses the main change: fixing a Python 3.12.11 compatibility error by using raw string literals in DeeployTypes.py.
Description check ✅ Passed The description clearly relates to the changeset, explaining the invalid escape sequence error and the raw string fix applied to DeeployTypes.py.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
Deeploy/DeeployTypes.py (1)

687-693: 💤 Low value

Fix is correct; consider applying r prefix consistently to Line 690 as well.

Lines 689 and 692 are properly fixed. Line 690 (re.sub(':', '_', repStr)) is not broken — : has no special Python escape meaning — but it's now the odd one out among three consecutive re.sub calls.

✨ Optional consistency fix
-        repStr = re.sub(':', '_', repStr)
+        repStr = re.sub(r':', '_', repStr)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Deeploy/DeeployTypes.py` around lines 687 - 693, In _mangle, make the regex
style consistent by changing the plain string pattern for the colon to a raw
string: replace re.sub(':', '_', repStr) with re.sub(r':', '_', repStr) so all
re.sub calls in that function use raw-pattern literals (refer to function
_mangle and the occurrences of re.sub).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@Deeploy/DeeployTypes.py`:
- Around line 687-693: In _mangle, make the regex style consistent by changing
the plain string pattern for the colon to a raw string: replace re.sub(':', '_',
repStr) with re.sub(r':', '_', repStr) so all re.sub calls in that function use
raw-pattern literals (refer to function _mangle and the occurrences of re.sub).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2589193c-c99a-4ef0-a866-95bbbf01ed38

📥 Commits

Reviewing files that changed from the base of the PR and between 3b011bb and 41384b8.

📒 Files selected for processing (1)
  • Deeploy/DeeployTypes.py

@RiccardoGandolfi RiccardoGandolfi changed the title Fix for python error when running regression Fix for python error when using python 3.12.11 May 6, 2026
@Victor-Jung
Copy link
Copy Markdown
Member

Ciao Riccardo, thanks for the fix. Can you share the command you ran when you encountered this error? I'm very surprised that's an issue because I never encountered it in my local env where I use Python 3.12.13.

@RiccardoGandolfi
Copy link
Copy Markdown
Author

RiccardoGandolfi commented May 6, 2026

Ciao Riccardo, thanks for the fix. Can you share the command you ran when you encountered this error? I'm very surprised that's an issue because I never encountered it in my local env where I use Python 3.12.13.

Ciao Victor, the command I ran was this one:

pytest -m siracusa -v

With the following output:

============================================================================================================ test session starts =============================================================================================================
platform linux -- Python 3.12.11, pytest-9.0.1, pluggy-1.6.0 -- /home/riccardo.gandolfi/.local/share/mamba/envs/deeploy_env/bin/python3.12
cachedir: .pytest_cache
rootdir: /scratch/riccardo.gandolfi/work/pulp_deeploy/Deeploy
configfile: pytest.ini
plugins: xdist-3.8.0
collected 827 items / 1 error / 760 deselected / 67 selected                                                                                                                                                                                 

=================================================================================================================== ERRORS ===================================================================================================================
_________________________________________________________________________________________________ ERROR collecting DeeployTest/test_dmas.py __________________________________________________________________________________________________
/home/riccardo.gandolfi/.local/share/mamba/envs/deeploy_env/lib/python3.12/site-packages/_pytest/python.py:507: in importtestmodule
    mod = import_path(
/home/riccardo.gandolfi/.local/share/mamba/envs/deeploy_env/lib/python3.12/site-packages/_pytest/pathlib.py:587: in import_path
    importlib.import_module(module_name)
/home/riccardo.gandolfi/.local/share/mamba/envs/deeploy_env/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<frozen importlib._bootstrap>:1387: in _gcd_import
    ???
<frozen importlib._bootstrap>:1360: in _find_and_load
    ???
<frozen importlib._bootstrap>:1331: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:935: in _load_unlocked
    ???
/home/riccardo.gandolfi/.local/share/mamba/envs/deeploy_env/lib/python3.12/site-packages/_pytest/assertion/rewrite.py:197: in exec_module
    exec(co, module.__dict__)
test_dmas.py:19: in <module>
    from testUtils.codeGenerate import generateTestNetwork
testUtils/codeGenerate.py:10: in <module>
    from Deeploy.DeeployTypes import CodeGenVerbosity, ConstantBuffer, NetworkDeployer, VariableBuffer
E     File "/scratch/riccardo.gandolfi/work/pulp_deeploy/Deeploy/Deeploy/DeeployTypes.py", line 689
E       repStr = re.sub('\.', '_', repStr)
E                        ^^
E   SyntaxError: invalid escape sequence '\.'
========================================================================================================== short test summary info ===========================================================================================================
ERROR test_dmas.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
====================================================================================================== 760 deselected, 1 error in 1.07s ======================================================================================================

Copy link
Copy Markdown
Member

@Victor-Jung Victor-Jung left a comment

Choose a reason for hiding this comment

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

LGTM, please update the changelog, and then I will merge. Thanks for the contribution!

Signed-off-by: RiccardoGandolfi <riccardogandi95@gmail.com>
@RiccardoGandolfi
Copy link
Copy Markdown
Author

LGTM, please update the changelog, and then I will merge. Thanks for the contribution!

Done 👍 Thank you!

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.

2 participants