Skip to content

Commit 5166add

Browse files
sty: Apply ruff preview rule RUF039
RUF039 First argument to `re.compile()` is not raw string
1 parent ac43481 commit 5166add

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

nibabel/cmdline/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def table2string(table, out=None):
5353
table[i] += [''] * (nelements_max - len(table_))
5454

5555
# eat whole entry while computing width for @w (for wide)
56-
markup_strip = re.compile('^@([lrc]|w.*)')
56+
markup_strip = re.compile(r'^@([lrc]|w.*)')
5757
col_width = [max(len(markup_strip.sub('', x)) for x in column) for column in zip(*table)]
5858
trans = str.maketrans('lrcw', '<>^^')
5959
lines = []

nibabel/nicom/dicomwrappers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ def vendor(self):
153153
# Look at manufacturer tag first
154154
mfgr = self.get('Manufacturer')
155155
if mfgr:
156-
if re.search('Siemens', mfgr, re.IGNORECASE):
156+
if re.search(r'Siemens', mfgr, re.IGNORECASE):
157157
return Vendor.SIEMENS
158-
if re.search('Philips', mfgr, re.IGNORECASE):
158+
if re.search(r'Philips', mfgr, re.IGNORECASE):
159159
return Vendor.PHILIPS
160-
if re.search('GE Medical', mfgr, re.IGNORECASE):
160+
if re.search(r'GE Medical', mfgr, re.IGNORECASE):
161161
return Vendor.GE
162162
# Next look at UID prefixes
163163
for uid_src in ('StudyInstanceUID', 'SeriesInstanceUID', 'SOPInstanceUID'):

nibabel/nicom/tests/test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_find_private_section_real():
1515
# On real data first
1616
assert fps(DATA, 0x29, 'SIEMENS CSA HEADER') == 0x1000
1717
assert fps(DATA, 0x29, b'SIEMENS CSA HEADER') == 0x1000
18-
assert fps(DATA, 0x29, re.compile('SIEMENS CSA HEADER')) == 0x1000
18+
assert fps(DATA, 0x29, re.compile(r'SIEMENS CSA HEADER')) == 0x1000
1919
assert fps(DATA, 0x29, 'NOT A HEADER') is None
2020
assert fps(DATA, 0x29, 'SIEMENS MEDCOM HEADER2') == 0x1100
2121
assert fps(DATA_PHILIPS, 0x29, 'SIEMENS CSA HEADER') == None
@@ -55,7 +55,7 @@ def test_find_private_section_fake():
5555
ds.add_new((0x11, 0x15), 'LO', b'far section')
5656
assert fps(ds, 0x11, 'far section') == 0x1500
5757
# More than one match - find the first.
58-
assert fps(ds, 0x11, re.compile('(another|third) section')) == 0x1100
58+
assert fps(ds, 0x11, re.compile(r'(another|third) section')) == 0x1100
5959
# The signalling element number must be <= 0xFF
6060
ds = pydicom.dataset.Dataset({})
6161
ds.add_new((0x11, 0xFF), 'LO', b'some section')

nibabel/tests/test_analyze.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ def test_str(self):
497497
hdr = self.header_class()
498498
s1 = str(hdr)
499499
# check the datacode recoding
500-
rexp = re.compile('^datatype +: float32', re.MULTILINE)
500+
rexp = re.compile(r'^datatype +: float32', re.MULTILINE)
501501
assert rexp.search(s1) is not None
502502

503503
def test_from_header(self):

0 commit comments

Comments
 (0)