--- a/RefactoringRope/CodeAssistClient.py Sat Mar 27 09:48:05 2021 +0100 +++ b/RefactoringRope/CodeAssistClient.py Sat Apr 24 11:19:08 2021 +0200 @@ -9,6 +9,7 @@ import sys import os +import contextlib sys.path.insert(0, os.path.dirname(__file__)) @@ -39,7 +40,7 @@ @param projectPath path to the project @type str """ - super(CodeAssistClient, self).__init__(host, port, idString) + super().__init__(host, port, idString) self.__methodMapping = { "getConfig": self.__getConfig, @@ -140,11 +141,11 @@ maxfixes = params["MaxFixes"] self.__project.prefs.set("python_path", params["SysPath"]) - if filename: - resource = rope.base.libutils.path_to_resource( - self.__project, filename) - else: - resource = None + resource = ( + rope.base.libutils.path_to_resource(self.__project, filename) + if filename else + None + ) errorDict = {} completions = [] @@ -187,11 +188,11 @@ maxfixes = params["MaxFixes"] self.__project.prefs.set("python_path", params["SysPath"]) - if filename: - resource = rope.base.libutils.path_to_resource( - self.__project, filename) - else: - resource = None + resource = ( + rope.base.libutils.path_to_resource(self.__project, filename) + if filename else + None + ) errorDict = {} calltips = [] @@ -224,24 +225,22 @@ offset = params["Offset"] maxfixes = params["MaxFixes"] - if not self.__id == CodeAssistClient.IdProject: + if self.__id != CodeAssistClient.IdProject: self.__project.prefs.set("python_path", params["SysPath"]) - if filename: - resource = rope.base.libutils.path_to_resource( - self.__project, filename) - else: - resource = None + resource = ( + rope.base.libutils.path_to_resource(self.__project, filename) + if filename else + None + ) errorDict = {} documentation = "" cts = None - try: + with contextlib.suppress(Exception): cts = rope.contrib.codeassist.get_calltip( self.__project, source, offset, resource, maxfixes=maxfixes, remove_self=True) - except Exception: # secok - pass if cts is not None: while '..' in cts: @@ -391,11 +390,11 @@ source = params["Source"] self.__project.prefs.set("python_path", params["SysPath"]) - if filename: - resource = rope.base.libutils.path_to_resource( - self.__project, filename) - else: - resource = None + resource = ( + rope.base.libutils.path_to_resource(self.__project, filename) + if filename else + None + ) errorDict = {} result = {} @@ -428,12 +427,9 @@ filename = params["FileName"] oldSource = params["OldSource"] - try: + with contextlib.suppress(Exception): rope.base.libutils.report_change( self.__project, filename, oldSource) - except Exception: # secok - # simply ignore it - pass if __name__ == '__main__':