Exemple #1
0
 def cmd_suggest(self, function: str, callsites: bool,
                 **kwargs: Any) -> Dict[str, object]:
     """Suggest a signature for a function."""
     if not self.fine_grained_manager:
         return {
             'error':
             "Command 'suggest' is only valid after a 'check' command"
             " (that produces no parse errors)"
         }
     engine = SuggestionEngine(self.fine_grained_manager, **kwargs)
     try:
         if callsites:
             out = engine.suggest_callsites(function)
         else:
             out = engine.suggest(function)
     except SuggestionFailure as err:
         return {'error': str(err)}
     else:
         if not out:
             out = "No suggestions\n"
         elif not out.endswith("\n"):
             out += "\n"
         return {'out': out, 'err': "", 'status': 0}
     finally:
         self.fscache.flush()
Exemple #2
0
 def cmd_suggest(
         self,
         function: str,
         callsites: bool,
         # We'd like to just use **kwargs here and save some duplication but
         # mypyc doesn't support it yet...
         json: bool,
         no_errors: bool,
         no_any: bool) -> Dict[str, object]:
     """Suggest a signature for a function."""
     if not self.fine_grained_manager:
         return {
             'error':
             "Command 'suggest' is only valid after a 'check' command"
         }
     engine = SuggestionEngine(self.fine_grained_manager, json, no_errors,
                               no_any)
     try:
         if callsites:
             out = engine.suggest_callsites(function)
         else:
             out = engine.suggest(function)
     except SuggestionFailure as err:
         return {'error': str(err)}
     else:
         if not out:
             out = "No suggestions\n"
         elif not out.endswith("\n"):
             out += "\n"
         return {'out': out, 'err': "", 'status': 0}
     finally:
         self.fscache.flush()
Exemple #3
0
 def cmd_suggest(self,
                 function: str,
                 callsites: bool,
                 # We'd like to just use **kwargs here and save some duplication but
                 # mypyc doesn't support it yet...
                 json: bool,
                 no_errors: bool,
                 no_any: bool) -> Dict[str, object]:
     """Suggest a signature for a function."""
     if not self.fine_grained_manager:
         return {'error': "Command 'suggest' is only valid after a 'check' command"}
     engine = SuggestionEngine(self.fine_grained_manager, json, no_errors, no_any)
     try:
         if callsites:
             out = engine.suggest_callsites(function)
         else:
             out = engine.suggest(function)
     except SuggestionFailure as err:
         return {'error': str(err)}
     else:
         if not out:
             out = "No suggestions\n"
         elif not out.endswith("\n"):
             out += "\n"
         return {'out': out, 'err': "", 'status': 0}
     finally:
         self.fscache.flush()
Exemple #4
0
 def cmd_suggest(self, function: str, json: bool,
                 callsites: bool) -> Dict[str, object]:
     """Suggest a signature for a function."""
     if not self.fine_grained_manager:
         return {
             'error':
             "Command 'suggest' is only valid after a 'check' command"
         }
     engine = SuggestionEngine(self.fine_grained_manager)
     try:
         if callsites:
             out = engine.suggest_callsites(function)
         else:
             out = engine.suggest(function, json)
     except SuggestionFailure as err:
         return {'error': str(err)}
     else:
         if not out:
             out = "No suggestions\n"
         elif not out.endswith("\n"):
             out += "\n"
         return {'out': out, 'err': "", 'status': 0}