-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
py(types): Add type annotations to email utils. #29854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b61c9ff to
38c974a
Compare
|
|
||
| def __init__(self, namespace, type_handlers): | ||
| def __init__( | ||
| self, namespace: str, type_handlers: Mapping[type[Model], Callable[[M], Any]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the return type of each handler at least Iterable[Any]? I think based on the implementation below it might even be Iterable[str]?
| to: list[str] | None = None, | ||
| cc: Iterable[str] | None = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why list for some and Iterable for others?
| fmt = options.get("system.logging-format") | ||
| messages = self.get_built_messages(to, cc=cc, bcc=bcc) | ||
| extra = {"message_type": self.type} | ||
| extra: MutableMapping[str, str | tuple[str]] = {"message_type": self.type} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I skimmed around a bit and it looks like the value here should just be str, I didn't see where it might be tuple[str]?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a sneaky tuple on line 244:
extra["message_to"] = (self.format_to(message.to),)| def get_built_messages( | ||
| self, | ||
| to: list[str] | None = None, | ||
| cc: Iterable[str] | None = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is to a list but cc and bcc are Iterable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question let me see if i can get it to match.
|
We're not supposed to change functionality in typing PRs but I fixed up the regex function to address your comments. |
Extracting types from #28879.
One tricky thing I'm doing here is turning a
Tuple[Optional[str], Optional[str]]into aOptional[Tuple[str, str]]which required a small code change in a conditional.