Skip to content

Commit 18a2b15

Browse files
committed
Made type variables invariant (the default) in TypeOpsSuite.
1 parent 6a0ef53 commit 18a2b15

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

mypy/test/testtypes.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
UnboundType, AnyType, Void, CallableType, TupleType, TypeVarDef, Type,
1414
Instance, NoneTyp, ErrorType
1515
)
16-
from mypy.nodes import ARG_POS, ARG_OPT, ARG_STAR, CONTRAVARIANT, INVARIANT
16+
from mypy.nodes import ARG_POS, ARG_OPT, ARG_STAR, CONTRAVARIANT, INVARIANT, COVARIANT
1717
from mypy.replacetvars import replace_type_vars
1818
from mypy.subtypes import is_subtype, is_more_precise, is_proper_subtype
1919
from mypy.typefixture import TypeFixture, InterfaceTypeFixture
@@ -96,7 +96,9 @@ def test_generic_function_type(self):
9696

9797
class TypeOpsSuite(Suite):
9898
def set_up(self):
99-
self.fx = TypeFixture()
99+
self.fx = TypeFixture(INVARIANT)
100+
self.fx_co = TypeFixture(COVARIANT)
101+
self.fx_contra = TypeFixture(CONTRAVARIANT)
100102

101103
# expand_type
102104

@@ -220,16 +222,16 @@ def test_is_proper_subtype(self):
220222
assert_false(is_proper_subtype(fx.t, fx.s))
221223

222224
def test_is_proper_subtype_covariance(self):
223-
fx = self.fx
225+
fx_co = self.fx_co
224226

225-
assert_true(is_proper_subtype(fx.gsab, fx.gb))
226-
assert_true(is_proper_subtype(fx.gsab, fx.ga))
227-
assert_false(is_proper_subtype(fx.gsaa, fx.gb))
228-
assert_true(is_proper_subtype(fx.gb, fx.ga))
229-
assert_false(is_proper_subtype(fx.ga, fx.gb))
227+
assert_true(is_proper_subtype(fx_co.gsab, fx_co.gb))
228+
assert_true(is_proper_subtype(fx_co.gsab, fx_co.ga))
229+
assert_false(is_proper_subtype(fx_co.gsaa, fx_co.gb))
230+
assert_true(is_proper_subtype(fx_co.gb, fx_co.ga))
231+
assert_false(is_proper_subtype(fx_co.ga, fx_co.gb))
230232

231233
def test_is_proper_subtype_contravariance(self):
232-
fx_contra = TypeFixture(CONTRAVARIANT)
234+
fx_contra = self.fx_contra
233235

234236
assert_true(is_proper_subtype(fx_contra.gsab, fx_contra.gb))
235237
assert_false(is_proper_subtype(fx_contra.gsab, fx_contra.ga))
@@ -238,13 +240,13 @@ def test_is_proper_subtype_contravariance(self):
238240
assert_true(is_proper_subtype(fx_contra.ga, fx_contra.gb))
239241

240242
def test_is_proper_subtype_invariance(self):
241-
fx_inv = TypeFixture(INVARIANT)
243+
fx = self.fx
242244

243-
assert_true(is_proper_subtype(fx_inv.gsab, fx_inv.gb))
244-
assert_false(is_proper_subtype(fx_inv.gsab, fx_inv.ga))
245-
assert_false(is_proper_subtype(fx_inv.gsaa, fx_inv.gb))
246-
assert_false(is_proper_subtype(fx_inv.gb, fx_inv.ga))
247-
assert_false(is_proper_subtype(fx_inv.ga, fx_inv.gb))
245+
assert_true(is_proper_subtype(fx.gsab, fx.gb))
246+
assert_false(is_proper_subtype(fx.gsab, fx.ga))
247+
assert_false(is_proper_subtype(fx.gsaa, fx.gb))
248+
assert_false(is_proper_subtype(fx.gb, fx.ga))
249+
assert_false(is_proper_subtype(fx.ga, fx.gb))
248250

249251
# Helpers
250252

0 commit comments

Comments
 (0)