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

branch
eric7
changeset 11148
15e30f0c76a8
parent 11147
dee6e106b4d3
equal deleted inserted replaced
11147:dee6e106b4d3 11148:15e30f0c76a8
19 # CodeStyleCheckerDialog tries to import FixableCodeStyleIssues which fails 19 # CodeStyleCheckerDialog tries to import FixableCodeStyleIssues which fails
20 # under Python3. So ignore it. 20 # under Python3. So ignore it.
21 with contextlib.suppress(ImportError): 21 with contextlib.suppress(ImportError):
22 import pycodestyle 22 import pycodestyle
23 23
24 FixableCodeStyleIssues = [ # noqa: U200 24 FixableCodeStyleIssues = [ # noqa: U-200
25 "D-111", 25 "D-111",
26 "D-112", 26 "D-112",
27 "D-121", 27 "D-121",
28 "D-131", 28 "D-131",
29 "D-141", 29 "D-141",
1700 1700
1701 def __fixE501(self, code, line, pos, apply=False): 1701 def __fixE501(self, code, line, pos, apply=False):
1702 """ 1702 """
1703 Private method to fix the long lines by breaking them. 1703 Private method to fix the long lines by breaking them.
1704 1704
1705 Codes: E501 1705 Codes: E-501
1706 1706
1707 @param code code of the issue 1707 @param code code of the issue
1708 @type str 1708 @type str
1709 @param line line number of the issue 1709 @param line line number of the issue
1710 @type int 1710 @type int
1746 if newNextText and newNextText != nextText: 1746 if newNextText and newNextText != nextText:
1747 if newNextText == " ": 1747 if newNextText == " ":
1748 newNextText = "" 1748 newNextText = ""
1749 self.__source[line + 1] = newNextText 1749 self.__source[line + 1] = newNextText
1750 # Long lines have been shortened. 1750 # Long lines have been shortened.
1751 return (1, "FIX-E501", [], 0) 1751 return (1, "FIX-E-501", [], 0)
1752 else: 1752 else:
1753 return (0, "", [], 0) 1753 return (0, "", [], 0)
1754 else: 1754 else:
1755 fixId = self.__getID() 1755 fixId = self.__getID()
1756 self.__stack.append((fixId, code, line, pos)) 1756 self.__stack.append((fixId, code, line, pos))
3053 @return number of unmatched open/close brackets 3053 @return number of unmatched open/close brackets
3054 @rtype int 3054 @rtype int
3055 """ 3055 """
3056 count = 0 3056 count = 0
3057 for opening, closing in ["()", "[]", "{}"]: 3057 for opening, closing in ["()", "[]", "{}"]:
3058 # __IGNORE_WARNING_M613__ 3058 # __IGNORE_WARNING_M-613__
3059 count += abs(line.count(opening) - line.count(closing)) 3059 count += abs(line.count(opening) - line.count(closing))
3060 3060
3061 return count 3061 return count
3062 3062
3063 def __getIndent(self, line): 3063 def __getIndent(self, line):

eric ide

mercurial