src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py

branch
eric7
changeset 10041
67c8efa6d098
parent 9786
f94b530722af
child 10046
35b27af462ef
equal deleted inserted replaced
10040:b5ef1a93cd1a 10041:67c8efa6d098
107 comment = line[pos + len(startComment) :].strip() 107 comment = line[pos + len(startComment) :].strip()
108 if endComment: 108 if endComment:
109 endPos = line.rfind(endComment) 109 endPos = line.rfind(endComment)
110 if endPos >= 0: 110 if endPos >= 0:
111 comment = comment[:endPos] 111 comment = comment[:endPos]
112 flags = [ 112 if comment.startswith(("noqa:", "NOQA:")):
113 f.strip() 113 flags = [
114 for f in comment.split() 114 "noqa:{0}".format(f.strip())
115 if (f.startswith("__") and f.endswith("__")) 115 for f in comment[len("noqa:"):].split(",")
116 ] 116 ]
117 flags += [ 117 else:
118 f.strip().lower() 118 flags = [
119 for f in comment.split() 119 f.strip()
120 if f in ("noqa", "NOQA", "nosec", "NOSEC", "secok", "SECOK") 120 for f in comment.split()
121 ] 121 if (f.startswith("__") and f.endswith("__"))
122 ]
123 flags += [
124 f.strip().lower()
125 for f in comment.split()
126 if f in ("noqa", "NOQA", "nosec", "NOSEC", "secok", "SECOK")
127 ]
122 return flags 128 return flags
123 129
124 130
125 def ignoreCode(code, lineFlags): 131 def ignoreCode(code, lineFlags):
126 """ 132 """
144 150
145 for flag in lineFlags: 151 for flag in lineFlags:
146 # check individual warning code 152 # check individual warning code
147 if flag.startswith("__IGNORE_WARNING_"): 153 if flag.startswith("__IGNORE_WARNING_"):
148 ignoredCode = flag[2:-2].rsplit("_", 1)[-1] 154 ignoredCode = flag[2:-2].rsplit("_", 1)[-1]
155 if code.startswith(ignoredCode):
156 return True
157 elif flag.startswith("noqa:"):
158 ignoredCode = flag[len("noqa:"):].strip()
149 if code.startswith(ignoredCode): 159 if code.startswith(ignoredCode):
150 return True 160 return True
151 161
152 return False 162 return False
153 163

eric ide

mercurial