Skip to content

Commit 4d08044

Browse files
wentasahglopezdiest
authored andcommitted
osc2_scenario: Fix SyntaxWarnings (carla-simulator#1122)
This fixes warnings like the one below: .../srunner/scenarios/osc2_scenario.py:515: SyntaxWarning: invalid escape sequence '\W' expression_value = re.split("\W+", option) Co-authored-by: glopezdiest <[email protected]>
1 parent bc3525c commit 4d08044

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
## Upcoming
1616
* Improvements to the CarlaDataProvider:
1717
- Added `spawn_actor` for a blueprint based actor creation similar to `World.spawn_actor`
18+
* Removed SyntaxWarnings in osc2_scenario.py
1819
* Implement `strtobool` formerly included in `distutils`, which is removed in Python 3.12.
1920

2021
## CARLA ScenarioRunner 0.9.15

srunner/scenarios/osc2_scenario.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,8 @@ def visit_do_directive(self, node: ast_node.DoDirective):
512512

513513
def bool_result(self, option):
514514
# wait(x < y) @drive_distance Handling of Boolean expressions x < y
515-
expression_value = re.split("\W+", option)
516-
symbol = re.search("\W+", option).group()
515+
expression_value = re.split(r"\W+", option)
516+
symbol = re.search(r"\W+", option).group()
517517
if symbol == "<":
518518
symbol = operator.lt
519519
elif symbol == ">":
@@ -1194,10 +1194,10 @@ def visit_identifier_reference(self, node: ast_node.IdentifierReference):
11941194
if isinstance(para_value, (Physical, float, int)):
11951195
return para_value
11961196
para_value = para_value.strip('"')
1197-
if re.fullmatch("(^[-]?[0-9]+(\.[0-9]+)?)\s*(\w+)", para_value):
1197+
if re.fullmatch(r"(^[-]?[0-9]+(\.[0-9]+)?)\s*(\w+)", para_value):
11981198
# Regular expression ^[-]?[0-9]+(\.[0-9]+)? matching float
11991199
# para_value_num = re.findall('^[-]?[0-9]+(\.[0-9]+)?', para_value)[0]
1200-
patter = re.compile("(^[-]?[0-9]+[\.[0-9]+]?)\s*(\w+)")
1200+
patter = re.compile(r"(^[-]?[0-9]+[\.[0-9]+]?)\s*(\w+)")
12011201
para_value_num, para_value_unit = patter.match(para_value).groups()
12021202
if para_value_num.count(".") == 1:
12031203
return Physical(

0 commit comments

Comments
 (0)