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

Add Tuple funsor #430

Merged
merged 4 commits into from
Jan 20, 2021
Merged

Add Tuple funsor #430

merged 4 commits into from
Jan 20, 2021

Conversation

eb8680
Copy link
Member

@eb8680 eb8680 commented Jan 19, 2021

pair-coded with @fritzo. Addresses #351.

@eb8680 eb8680 added Blocked Blocked by other issues and removed Blocked Blocked by other issues labels Jan 19, 2021
Copy link
Member

@fritzo fritzo left a comment

Choose a reason for hiding this comment

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

🎉


class Product(tuple, metaclass=ProductDomain):
"""like typing.Tuple, but works with issubclass"""
__args__ = NotImplemented
Copy link
Member

Choose a reason for hiding this comment

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

Does the __args__ name have something to do with the typing module? I would expect Python-builtin-style naming to correspond to some Python concept, and to use ._args otherwise.

Copy link
Member Author

@eb8680 eb8680 Jan 20, 2021

Choose a reason for hiding this comment

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

Yes, it's a convention I copied from typing whose purpose seems to be to signal that __args__ are to be accessed through a typing introspection API (e.g. typing_extensions.get_args(t)) rather than directly, perhaps because the internals of typing change a lot between releases. In a future PR we can add get_origin() and get_args() for Domains, as suggested in #351.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants