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

Implement Variance. List and Dict are now invariant! #54

Merged
merged 3 commits into from
Mar 9, 2024
Merged

Conversation

erezsh
Copy link
Owner

@erezsh erezsh commented Mar 9, 2024

No description provided.

Copy link

@prplex prplex bot left a comment

Choose a reason for hiding this comment

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

Review completed. Posted 2 comments.

elif self.variance == Variance.Contravariant:
return self.base <= other.base and self.item >= other.item
elif self.variance == Variance.Invariant:
return self.base <= other.base and self.item == other.item
Copy link

Choose a reason for hiding this comment

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

Instead of raising a generic RuntimeError, it's better to throw a more specific error that details what the issue is (for instance, 'Unexpected value for variance')

runtype/pytypes.py Outdated Show resolved Hide resolved
@erezsh erezsh merged commit 7cd863d into master Mar 9, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant