Skip to content

Commit 77e4399

Browse files
authored
Merge pull request #46095 from smuzaffar/core-py312-SyntaxWarning
[CORE] [PY312] String formatting to fix SyntaxWarning
2 parents 8955c1f + 2048ee5 commit 77e4399

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

Utilities/ReleaseScripts/python/cmsCodeRules/config.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
Configuration[ruleName]['filesToMatch'] = ['*.h']
3636
Configuration[ruleName]['exceptPaths'] = ['HeterogeneousCore/CUDAUtilities/interface/cudaCompat.h']
3737
Configuration[ruleName]['skip'] = [comment, function]
38-
Configuration[ruleName]['filter'] = '(\susing|\Ausing)\s+(namespace|std::)' #should be regular expression
38+
Configuration[ruleName]['filter'] = '(\\susing|\\Ausing)\\s+(namespace|std::)' #should be regular expression
3939
Configuration[ruleName]['exceptFilter'] = []
4040

4141
# --------------------------------------------------------------------------------
@@ -50,7 +50,7 @@
5050
Configuration[ruleName]['filesToMatch'] = ['BuildFile', 'BuildFile.xml']
5151
Configuration[ruleName]['exceptPaths'] = []
5252
Configuration[ruleName]['skip'] = [comment]
53-
Configuration[ruleName]['filter'] = '\s(CXXFLAGS|CPPFLAGS)(\+|=|\w|\"|\'|-|\s)*(-g|-O0)(\s|\'|\")' #should be regular expression
53+
Configuration[ruleName]['filter'] = '\\s(CXXFLAGS|CPPFLAGS)(\\+|=|\\w|\"|\'|-|\\s)*(-g|-O0)(\\s|\'|\")' #should be regular expression
5454
Configuration[ruleName]['exceptFilter'] = []
5555

5656
# --------------------------------------------------------------------------------
@@ -65,7 +65,7 @@
6565
Configuration[ruleName]['filesToMatch'] = ['*.cc', '*.cxx']
6666
Configuration[ruleName]['exceptPaths'] = ['FWCore/*', 'EventFilter/*', '*/*/test/*', '*/*/bin/*']
6767
Configuration[ruleName]['skip'] = [comment]
68-
Configuration[ruleName]['filter'] = 'catch\s*\(\s*\.\.\.\s*\)' #should be regular expression
68+
Configuration[ruleName]['filter'] = 'catch\\s*\\(\\s*\\.\\.\\.\\s*\\)' #should be regular expression
6969
Configuration[ruleName]['exceptFilter'] = []
7070
# --------------------------------------------------------------------------------
7171

@@ -92,7 +92,7 @@
9292
'PhysicsTools/JetMCUtils/interface/combination.h',
9393
] #could be file name, dir, fileName:line. But path should be only from that directory in which we are searching
9494
Configuration[ruleName]['skip'] = []
95-
Configuration[ruleName]['filter'] = '(\A|\W)(c|C)(o|O)(p|P)(y|Y)(r|R)(i|I)(g|G)(h|H)(t|T)\W(\+|=|\w|\"|\'|-|\s)*(\((c|C)\)|\d{4})' #should be regular expression
95+
Configuration[ruleName]['filter'] = '(\\A|\\W)(c|C)(o|O)(p|P)(y|Y)(r|R)(i|I)(g|G)(h|H)(t|T)\\W(\\+|=|\\w|\"|\'|-|\\s)*(\\((c|C)\\)|\\d{4})' #should be regular expression
9696
Configuration[ruleName]['exceptFilter'] = []
9797

9898
# --------------------------------------------------------------------------------
@@ -107,9 +107,9 @@
107107
Configuration[ruleName]['filesToMatch'] = ['*.h', '*.c', '*.cc', '*.cxx']
108108
Configuration[ruleName]['exceptPaths'] = ['*/*LinkDef.h',
109109
'FWCore/Utilities/interface/tinyxml.h',
110-
'Utilities/StorageFactory/src/LocalFileSystem.cc:.*:#\s*pragma\s+GCC\s+diagnostic\s+ignored',
110+
'Utilities/StorageFactory/src/LocalFileSystem.cc:.*:#\\s*pragma\\s+GCC\\s+diagnostic\\s+ignored',
111111
'RecoVertex/BeamSpotProducer/test/scripts/BSVectorDict.h',
112-
'FWCore/Utilities/*/*:.*:#\s*pragma\s+GCC\s+visibility\s+(push\\(default\\)|pop)\s*$',
112+
'FWCore/Utilities/*/*:.*:#\\s*pragma\\s+GCC\\s+visibility\\s+(push\\(default\\)|pop)\\s*$',
113113
'CondFormats/JetMETObjects/interface/Linkdef.h',
114114
'DataFormats/GeometryVector/interface/Basic3DVectorLD.h',
115115
'DataFormats/Scalers/interface/ScalersRaw.h',
@@ -161,7 +161,7 @@
161161
'RecoTracker/TkDetLayers/src/TIDRing.h',
162162
]#could be file name, dir, fileName:line. Path should be only from that directory in which we are searching
163163
Configuration[ruleName]['skip'] = [comment]
164-
Configuration[ruleName]['filter'] = '#\s*pragma\s' #should be regular expression
164+
Configuration[ruleName]['filter'] = '#\\s*pragma\\s' #should be regular expression
165165
Configuration[ruleName]['exceptFilter'] = []
166166
# --------------------------------------------------------------------------------
167167
# configuration for rule 6
@@ -183,10 +183,10 @@
183183
'L1Trigger/CSCTrackFinder/BuildFile.xml:.*:ADD_SUBDIR=',
184184
'MagneticField/Interpolation/BuildFile.xml:.*:="-Wno-format"',
185185
'MagneticField/Interpolation/test/BuildFile.xml:.*:="-Wno-format"',
186-
'GeneratorInterface/Pythia6Interface/plugins/BuildFile.xml:.*:LDFLAGS="\$\(PYTHIA6_BASE\)/lib/pydata.o"',
186+
'GeneratorInterface/Pythia6Interface/plugins/BuildFile.xml:.*:LDFLAGS="\\$\\(PYTHIA6_BASE\\)/lib/pydata.o"',
187187
]
188188
Configuration[ruleName]['skip'] = [comment]
189-
Configuration[ruleName]['filter'] = '<\s*(f|F)(l|L)(a|A)(g|G)(s|S)\s+' #should be regular expression
189+
Configuration[ruleName]['filter'] = '<\\s*(f|F)(l|L)(a|A)(g|G)(s|S)\\s+' #should be regular expression
190190
Configuration[ruleName]['exceptFilter'] = ['EDM_PLUGIN','RIVET_PLUGIN', 'GENREFLEX_ARGS', 'TEST_RUNNER_ARGS', 'INSTALL_SCRIPTS', 'NO_TESTRUN', 'NO_EXPORT']
191191
# --------------------------------------------------------------------------------
192192

Utilities/ReleaseScripts/python/cmsCodeRules/cppFunctionSkipper.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
import re
77

8-
declarator = '(\*|&)?(\w|<|,|>|$|::)+'
9-
cv_decl = '\s*(const|volatile|noexcept)\s*'
10-
exception = 'throw\(((::)|\w|\s|,|<|>)*\)'
11-
decl_param = '\s((\(%s\))|(%s))\s*\((\w|\s|\*|&|\.|=|\'|\"|-|<|>|,|(::))*\)'%(declarator, declarator)
12-
operator = '(%s|)operator\s*(\(\)|\[\]|\s+(new|delete)(\s*\[\]|)|\-\>[*]{0,1}|[+\-*/%%^&|~!=<>,]{1,2}(=|))'%(declarator)
8+
declarator = '(\\*|&)?(\\w|<|,|>|$|::)+'
9+
cv_decl = '\\s*(const|volatile|noexcept)\\s*'
10+
exception = 'throw\\(((::)|\\w|\\s|,|<|>)*\\)'
11+
decl_param = '\\s((\\(%s\\))|(%s))\\s*\\((\\w|\\s|\\*|&|\\.|=|\'|\"|-|<|>|,|(::))*\\)'%(declarator, declarator)
12+
operator = '(%s|)operator\\s*(\\(\\)|\\[\\]|\\s+(new|delete)(\\s*\\[\\]|)|\\-\\>[*]{0,1}|[+\\-*/%%^&|~!=<>,]{1,2}(=|))'%(declarator)
1313
dm_init = '(:[^{]*)'
14-
functStart_re = re.compile('(\s|~|^)((\(%s\))|(%s)|(%s))\s*\((%s|\w|\s|\*|&|\.|=|\'|\"|-|<|>|,|::)*\)(%s)?(%s)?\s*(%s)?\s*{'%(declarator, declarator, operator, decl_param, cv_decl, exception,dm_init), re.MULTILINE)
14+
functStart_re = re.compile('(\\s|~|^)((\\(%s\\))|(%s)|(%s))\\s*\\((%s|\\w|\\s|\\*|&|\\.|=|\'|\"|-|<|>|,|::)*\\)(%s)?(%s)?\\s*(%s)?\\s*{'%(declarator, declarator, operator, decl_param, cv_decl, exception,dm_init), re.MULTILINE)
1515

1616
def filterFiles(fileList):
1717
files = []

Utilities/ReleaseScripts/python/cmsCodeRules/pathToRegEx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def pathsToRegEx(Paths):
1313

1414
def pathToRegEx(path):
1515
path = path.replace("\\", "\\\\")
16-
path = "\A%s$" %path
17-
path = path.replace(".", "\.")
16+
path = "\\A%s$" %path
17+
path = path.replace(".", "\\.")
1818
path = path.replace("*",".*")
1919
return path

0 commit comments

Comments
 (0)