Skip to content

Commit f4f5dee

Browse files
committed
Ban re.match
1 parent 103441b commit f4f5dee

5 files changed

Lines changed: 9 additions & 5 deletions

File tree

holoviews/plotting/bokeh/styles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def mpl_to_bokeh(properties):
141141
validators = {
142142
"angle": angle.is_valid,
143143
"alpha": alpha.is_valid,
144-
"color": lambda x: color.is_valid(x) or (isinstance(x, str) and RGB_HEX_REGEX.match(x)),
144+
"color": lambda x: color.is_valid(x) or (isinstance(x, str) and RGB_HEX_REGEX.search(x)),
145145
"font_size": font_size.is_valid,
146146
"line_dash": dash_pattern.is_valid,
147147
"marker": lambda x: marker.is_valid(x) or x in markers,

holoviews/plotting/mpl/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def is_color(color):
5151
"""Checks if supplied object is a valid color spec."""
5252
if not isinstance(color, str):
5353
return False
54-
elif RGB_HEX_REGEX.match(color):
54+
elif RGB_HEX_REGEX.search(color):
5555
return True
5656
elif color in COLOR_ALIASES:
5757
return True

holoviews/plotting/plotly/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124

125125
# Regular expression to extract any trailing digits from a subplot-style
126126
# string.
127-
_subplot_re = re.compile(r"\D*(\d+)")
127+
_subplot_re = re.compile(r"(\d+)")
128128

129129

130130
def _get_subplot_number(subplot_val):
@@ -149,7 +149,7 @@ def _get_subplot_number(subplot_val):
149149
-------
150150
int
151151
"""
152-
match = _subplot_re.match(subplot_val)
152+
match = _subplot_re.search(subplot_val)
153153
if match:
154154
subplot_number = int(match.group(1))
155155
else:

holoviews/plotting/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ def scale_fontsize(size, scaling):
11641164
"""Scales a numeric or string font size."""
11651165
ext = None
11661166
if isinstance(size, str):
1167-
match = re.match(r"[-+]?\d*\.\d+|\d+", size)
1167+
match = re.search(r"^[-+]?\d*\.\d+|\d+", size)
11681168
if match:
11691169
value = match.group()
11701170
ext = size.replace(value, "")

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ select = [
182182
"PT",
183183
"RUF",
184184
"TC",
185+
"TID251",
185186
"UP",
186187
"W",
187188
]
@@ -247,6 +248,9 @@ allow-dict-calls-with-keyword-arguments = true
247248
[tool.ruff.lint.pydocstyle]
248249
convention = "numpy"
249250

251+
[tool.ruff.lint.flake8-tidy-imports.banned-api]
252+
"re.match".msg = "Use re.search with '^' instead of re.match"
253+
250254
[tool.ty.src]
251255
include = [
252256
"holoviews/*.py",

0 commit comments

Comments
 (0)