Skip to content

Conversation

@mgaeta
Copy link
Contributor

@mgaeta mgaeta commented Nov 8, 2021

Extracting types from #28879.
One tricky thing I'm doing here is turning a Tuple[Optional[str], Optional[str]] into a Optional[Tuple[str, str]] which required a small code change in a conditional.


def __init__(self, namespace, type_handlers):
def __init__(
self, namespace: str, type_handlers: Mapping[type[Model], Callable[[M], Any]]
Copy link
Member

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]?

Comment on lines 214 to 215
to: list[str] | None = None,
cc: Iterable[str] | None = None,
Copy link
Member

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}
Copy link
Member

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]?

Copy link
Contributor Author

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,
Copy link
Member

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?

Copy link
Contributor Author

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.

@mgaeta
Copy link
Contributor Author

mgaeta commented Nov 9, 2021

We're not supposed to change functionality in typing PRs but I fixed up the regex function to address your comments.

@mgaeta mgaeta merged commit 36a8e35 into master Nov 9, 2021
@mgaeta mgaeta deleted the feat/api-2029-webhook-task-10 branch November 9, 2021 02:40
@github-actions github-actions bot locked and limited conversation to collaborators Nov 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants