diff --git a/changes/1077.general.rst b/changes/1077.general.rst new file mode 100644 index 000000000..515a52d49 --- /dev/null +++ b/changes/1077.general.rst @@ -0,0 +1 @@ +replaces deprecated string literals with raw strings in regex pattern matching diff --git a/crds/certify/certify.py b/crds/certify/certify.py index 8197c59ad..eb4076028 100644 --- a/crds/certify/certify.py +++ b/crds/certify/certify.py @@ -687,7 +687,7 @@ def load(self): class AsdfCertifier(ReferenceCertifier): """Certifier for ADSF type, invoke data models checks.""" - _VERSION_RE = re.compile(f"^[0-9]+\.[0-9]+\.[0-9]+$") + _VERSION_RE = re.compile(r"^[0-9]+\.[0-9]+\.[0-9]+$") def certify(self): """Certify an unknown format file.""" diff --git a/crds/certify/validators/synphot.py b/crds/certify/validators/synphot.py index e6b05b7e5..63466484a 100644 --- a/crds/certify/validators/synphot.py +++ b/crds/certify/validators/synphot.py @@ -179,7 +179,7 @@ def _check_component_filename(context, reftype, suffix, filename, header): log.error("Header missing COMPNAME, unable to certify filename") return False - pattern = re.compile(".*_([0-9]{3})_" + suffix + ".fits") + pattern = re.compile(r".*_([0-9]{3})_" + suffix + r".fits") match = pattern.match(os.path.basename(filename)) if not match: diff --git a/crds/core/timestamp.py b/crds/core/timestamp.py index fd39a9570..28bf87277 100644 --- a/crds/core/timestamp.py +++ b/crds/core/timestamp.py @@ -291,7 +291,7 @@ def parse_numerical_date(dstr): class DateParser: """Abstract baseclass for defining date parsers.""" - format = re.compile("^$") + format = re.compile(r"^$") should_be = "DATE FORMAT NOT DEFINED" @classmethod diff --git a/crds/hst/siname.py b/crds/hst/siname.py index 48840a6f1..44f718065 100644 --- a/crds/hst/siname.py +++ b/crds/hst/siname.py @@ -36,7 +36,7 @@ class UnknownCDBSPrefix(Exception): pass # global compiled regex for splitting filenames -filesplit = re.compile("[_\.]") +filesplit = re.compile(r"[_\.]") # post-SM2 instruments supported by CDBS CDBS_supports = ("ACS","STIS","NICMOS","WFPC2","WFC3","COS") diff --git a/crds/submit/submit.py b/crds/submit/submit.py index f317b22bc..e167d2dab 100644 --- a/crds/submit/submit.py +++ b/crds/submit/submit.py @@ -360,7 +360,7 @@ def find_new_rmaps(self, old_maps, new_maps): return rnew def get_renamed_rmaps(self, soup, fmap): - diffs = soup.find_all(string=re.compile("Logical Diff")) + diffs = soup.find_all(string=re.compile(r"Logical Diff")) if len(diffs) > 0: for diff in diffs: d = diff.split('(')[-1].split(')')[0]