Skip to content

Commit

Permalink
fix: Make SubstitutionMap keys and vals covariant per pyright's recom…
Browse files Browse the repository at this point in the history
…mendation
  • Loading branch information
CallumJHays committed Oct 17, 2022
1 parent 462f670 commit 94ceba3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mathpad/algebra.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import ItemsView, KeysView, Protocol, TypeVar, Union, ValuesView, overload
import sympy

from mathpad.val import ValT, Val
from mathpad.val import Q, ValT, Val
from mathpad.vector import Vec, VecT
from mathpad.equation import Equation

Expand Down Expand Up @@ -117,13 +117,13 @@ def expand(
# Until a contravariant Map type is added to typing, we have to use this
# https://github.com/python/typing_extensions/issues/5#issue-1241825018

VecOrVal = TypeVar("VecOrVal", bound=Union[Val, Vec])
VecOrvalQ = TypeVar("VecOrvalQ", bound=Union[Q[Val], Vec])
VecOrVal = TypeVar("VecOrVal", bound=Union[Val, Vec], covariant=True)
VecOrValQ = TypeVar("VecOrValQ", bound=Union[Q[Val], Vec], covariant=True)

class SubstitutionMap(Protocol[VecOrVal, VecOrvalQ]):
class SubstitutionMap(Protocol[VecOrVal, VecOrValQ]):
def keys(self) -> KeysView[VecOrVal]: ...
def items(self) -> ItemsView[VecOrVal, VecOrvalQ]: ...
def values(self) -> ValuesView[VecOrvalQ]: ...
def items(self) -> ItemsView[VecOrVal, VecOrValQ]: ...
def values(self) -> ValuesView[VecOrValQ]: ...


@overload
Expand Down

0 comments on commit 94ceba3

Please sign in to comment.