Raw String needed for re.match to Suppress Warning
See original GitHub issueDescribe 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:
- Created 10 months ago
- Comments:6 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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
Great. I’ll do that tomorrow morning when I’m at my laptop. Thanks for your help