eric6/Plugins/CheckerPlugins/CodeStyleChecker/Miscellaneous/MiscellaneousChecker.py

changeset 8228
772103b14c18
parent 8222
5994b80b8760
child 8243
cc717c2ae956
equal deleted inserted replaced
8227:349308e84eeb 8228:772103b14c18
2098 2098
2099 elif node.func.attr == 'strptime': 2099 elif node.func.attr == 'strptime':
2100 # datetime.strptime(...).replace(tzinfo=UTC) 2100 # datetime.strptime(...).replace(tzinfo=UTC)
2101 parent = getattr(node, '_dtCheckerParent', None) 2101 parent = getattr(node, '_dtCheckerParent', None)
2102 pparent = getattr(parent, '_dtCheckerParent', None) 2102 pparent = getattr(parent, '_dtCheckerParent', None)
2103 if not (isinstance(parent, ast.Attribute) and 2103 if (
2104 parent.attr == 'replace'): 2104 not (isinstance(parent, ast.Attribute) and
2105 isCase1 = False 2105 parent.attr == 'replace') or
2106 elif not isinstance(pparent, ast.Call): 2106 not isinstance(pparent, ast.Call)
2107 ):
2107 isCase1 = False 2108 isCase1 = False
2108 else: 2109 else:
2109 tzinfoKeyword = self.__getFromKeywords(pparent.keywords, 2110 tzinfoKeyword = self.__getFromKeywords(pparent.keywords,
2110 'tzinfo') 2111 'tzinfo')
2111 isCase1 = ( 2112 isCase1 = (
2191 @return flag indicating a match 2192 @return flag indicating a match
2192 @rtype bool 2193 @rtype bool
2193 """ 2194 """
2194 match = False 2195 match = False
2195 if ( 2196 if (
2196 isinstance(node, ast.Attribute) and 2197 (isinstance(node, ast.Attribute) and
2197 isinstance(node.value, ast.Name) and 2198 isinstance(node.value, ast.Name) and
2198 node.value.id == "sys" and 2199 node.value.id == "sys" and
2199 node.attr == attr 2200 node.attr == attr) or
2200 ): 2201 (isinstance(node, ast.Name) and
2201 match = True 2202 node.id == attr and
2202 elif ( 2203 self.__fromImports.get(node.id) == "sys")
2203 isinstance(node, ast.Name) and
2204 node.id == attr and
2205 self.__fromImports.get(node.id) == "sys"
2206 ): 2204 ):
2207 match = True 2205 match = True
2208 2206
2209 return match 2207 return match
2210 2208

eric ide

mercurial