From a list of possible function types, find the best one. For best, we want the fewest errors, then the best "score" from score_callable.
(self, func: FuncDef, guesses: list[CallableType])
| 448 | ] |
| 449 | |
| 450 | def find_best(self, func: FuncDef, guesses: list[CallableType]) -> tuple[CallableType, int]: |
| 451 | """From a list of possible function types, find the best one. |
| 452 | |
| 453 | For best, we want the fewest errors, then the best "score" from score_callable. |
| 454 | """ |
| 455 | if not guesses: |
| 456 | raise SuggestionFailure("No guesses that match criteria!") |
| 457 | errors = {guess: self.try_type(func, guess) for guess in guesses} |
| 458 | best = min(guesses, key=lambda s: (count_errors(errors[s]), self.score_callable(s))) |
| 459 | return best, count_errors(errors[best]) |
| 460 | |
| 461 | def get_guesses_from_parent(self, node: FuncDef) -> list[CallableType]: |
| 462 | """Try to get a guess of a method type from a parent class.""" |
no test coverage detected