Skip to content

Commit

Permalink
TypeVar for Box has to be covariant
Browse files Browse the repository at this point in the history
  • Loading branch information
youtux committed Jun 11, 2022
1 parent 59050f7 commit 034f17c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pytest_factoryboy/fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
FactoryType: TypeAlias = Type[factory.Factory]
F = TypeVar("F", bound=FactoryType)
T = TypeVar("T")
T_co = TypeVar("T_co", covariant=True)
P = ParamSpec("P")

SEPARATOR = "__"
Expand All @@ -58,16 +59,16 @@ def __call__(self, request: SubRequest) -> Any:
return self.function(request)


class Box(Generic[T]):
class Box(Generic[T_co]):
"""Simple box class, used to hold a value.
The main purpose of this is to hold objects that we don't want to appear in stack traces.
For example, the "caller_locals" dict holding a lot of items.
"""

value: T
value: T_co

def __init__(self, value: T):
def __init__(self, value: T_co):
self.value = value


Expand Down

0 comments on commit 034f17c

Please sign in to comment.