Skip to content
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

Type annotate pyro.poutine.messenger #3290

Merged
merged 3 commits into from
Nov 5, 2023
Merged

Type annotate pyro.poutine.messenger #3290

merged 3 commits into from
Nov 5, 2023

Conversation

ordabayevy
Copy link
Member

No description provided.

@ordabayevy ordabayevy added the WIP label Nov 4, 2023
@@ -61,17 +74,15 @@ class Messenger:
Most inference operations are implemented in subclasses of this.
"""

def __call__(self, fn):
def __call__(self, fn: Callable) -> Callable:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be more precise and allow passing of type information?

_F = TypeVar("_F", bound=Callable)

class Messenger:
    def __call__(self, fn: _F) -> _F:
        ...

@@ -227,7 +250,9 @@ def unregister(cls, fn=None, type=None):


@contextmanager
def block_messengers(predicate):
def block_messengers(
predicate: Callable[[Messenger], bool]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great!

@fritzo fritzo merged commit 71e0f9c into dev Nov 5, 2023
9 checks passed
@ordabayevy ordabayevy deleted the type-messenger branch November 5, 2023 23:08
@ordabayevy ordabayevy mentioned this pull request Feb 5, 2024
23 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants