145 defs = [None] * (len(context.node.args.args) - len(context.node.args.defaults)) |
145 defs = [None] * (len(context.node.args.args) - len(context.node.args.defaults)) |
146 defs.extend(context.node.args.defaults) |
146 defs.extend(context.node.args.defaults) |
147 |
147 |
148 # go through all (param, value)s and look for candidates |
148 # go through all (param, value)s and look for candidates |
149 for key, val in zip(context.node.args.args, defs): |
149 for key, val in zip(context.node.args.args, defs): |
150 if ( |
150 if isinstance(key, (ast.Name, ast.arg)): |
151 isinstance(key, (ast.Name, ast.arg)) |
151 # Skip if the default value is None |
152 and AstUtilities.isString(val) |
152 if val is None or ( |
153 and RE_CANDIDATES.search(key.arg) |
153 isinstance(val, (ast.Constant, ast.NameConstant)) |
154 ): |
154 and val.value is None |
155 reportError( |
155 ): |
156 context.node.lineno - 1, |
156 continue |
157 context.node.col_offset, |
157 if isinstance(val, ast.Str) and RE_CANDIDATES.search(key.arg): |
158 "S-107", |
158 reportError( |
159 "L", |
159 context.node.lineno - 1, |
160 "M", |
160 context.node.col_offset, |
161 val.value, |
161 "S-107", |
162 ) |
162 "L", |
|
163 "M", |
|
164 val.value, |
|
165 ) |