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

[common] generics, not Any for ComparisonExpression. #386

Merged
merged 1 commit into from Jan 22, 2023

Conversation

stonier
Copy link
Member

@stonier stonier commented Jan 22, 2023

Relates to #336.

Not entirely happy with this, but at least it removes the viral ramifications of Any.

One or Two Generics?

NB: if using both T and V:

    def __init__(
        self,
        variable: str,
        value: T,
        operator: typing.Callable[[T, V], bool]
    ):

this starts to get awkward. The user then must always place the value in the right hand side of the operator when checking. This is somewhat arbitrary.

If this is needed, we should rethink the way ComparisonExpression is handled (perhaps provide a method that facilitates this).

Covariant/Contravariant?

Certainly could be useful to widen the generics in this way. However, both ways make sense? Ultimately it depends on what the user's base and derived classes look like. There might be some common patterns with standard data structures that could be usefully accommodated though. However, since that is not known at this point, this PR is not making a decision on it yet.

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.

None yet

1 participant