question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Raw String needed for re.match to Suppress Warning

See original GitHub issue

Describe the bug

There is a re.match regular expression which is not being specified as a raw string, leading to a warning being raised: https://github.com/allegroai/clearml/blob/762bc5325f790b0ba0614f4aefddc1f881a2644c/clearml/backend_api/session/jsonmodels/fields.py#L137

../.pyenv/versions/3.9.7/lib/python3.9/site-packages/clearml/backend_api/session/jsonmodels/fields.py:137
  /home/circleci/.pyenv/versions/3.9.7/lib/python3.9/site-packages/clearml/backend_api/session/jsonmodels/fields.py:137: DeprecationWarning: invalid escape sequence \w
    if not re.match('^[A-Za-z_](([\w\-]*)?\w+)?$', self.name):  # noqa: W605

Expected behaviour

By prefixing the string with r, this warning would no longer be raised.

Environment

MacOS Python 3.9.12

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
erezalgcommented, Nov 27, 2022

@daugihao You can also refer to our contribution guidelines which should help make the PR easier to merge 😄 https://github.com/allegroai/clearml/blob/master/docs/contributing.md

1reaction
daugihaocommented, Nov 27, 2022

Great. I’ll do that tomorrow morning when I’m at my laptop. Thanks for your help

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - How to match a newline character in a raw string?
The simplest answer is to simply not use a raw string. You can escape backslashes by using \\ .
Read more >
re — Regular expression operations — Python 3.11.1 ...
The solution is to use Python's raw string notation for regular expression patterns; backslashes are not handled in any special way in a...
Read more >
Escaping metacharacters - Python re(gex)? - learnbyexample
Escaping metacharacters. This chapter will show how to match metacharacters literally, for manually as well as programmatically constructed patterns.
Read more >
Regular Expression (Regex) Tutorial
To match a character having special meaning in regex, you need to use a escape ... denotes raw strings which ignore escape code,...
Read more >
Regular Expressions: Regexes in Python (Part 1)
It's good practice to use a raw string to specify a regex in Python whenever it contains backslashes. Remove ads. Anchors. Anchors are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found