plum
plum copied to clipboard
My New Scoring System
Hello!
Sorry for the massive delay, but here's a link to my new scoring system, with generalized types providing their own using custom __instancescore__ and __subclassscore__ methods for the alias, metaclass, and main class; I'd appreciate if y'all could take a gander whenever possible! 😹
I'll be more than happy to explain any other questions you may have, but for now, it deals with ..., converting TypeVars, named keyword arguments, and unknown arguments and keyword arguments. Additionally, here's the scoring system for Callables, for example:
def __aliassubclassscore__(self, C: Annotation) -> typing.Optional[int]:
if C_args := typing.get_args(C):
if typing.get_origin(C) == typing.get_origin(self):
total = 1
self_args = typing.get_args(self)
last_score = scoresubclass(C_args[-1], self_args[-1])
if last_score is not None:
total += last_score
ca = C_args[0]
sa = self_args[0]
if isinstance(ca, list):
if isinstance(sa, list):
list_score = scoreargs(tuple(ca), tuple(sa), True)
if list_score is None:
return None
return total + list_score
first_score = any_score if sa is ... else scoresubclass(ca, sa)
if first_score is not None:
return total + first_score
Thank you kindly for all the help over the years!