@@ -617,11 +617,10 @@ static_assert(is_assignable_to(Foo, HasX))
617617static_assert(not is_subtype_of(Foo, HasXY))
618618static_assert(not is_assignable_to(Foo, HasXY))
619619
620- # TODO : these should pass
621- static_assert(not is_subtype_of(HasXIntSub, HasX)) # error: [static-assert-error]
622- static_assert(not is_assignable_to(HasXIntSub, HasX)) # error: [static-assert-error]
623- static_assert(not is_subtype_of(HasX, HasXIntSub)) # error: [static-assert-error]
624- static_assert(not is_assignable_to(HasX, HasXIntSub)) # error: [static-assert-error]
620+ static_assert(not is_subtype_of(HasXIntSub, HasX))
621+ static_assert(not is_assignable_to(HasXIntSub, HasX))
622+ static_assert(not is_subtype_of(HasX, HasXIntSub))
623+ static_assert(not is_assignable_to(HasX, HasXIntSub))
625624
626625class FooSub (Foo ): ...
627626
@@ -2291,10 +2290,9 @@ class MethodPUnrelated(Protocol):
22912290
22922291static_assert(is_subtype_of(MethodPSub, MethodPSuper))
22932292
2294- # TODO : these should pass
2295- static_assert(not is_assignable_to(MethodPUnrelated, MethodPSuper)) # error: [static-assert-error]
2296- static_assert(not is_assignable_to(MethodPSuper, MethodPUnrelated)) # error: [static-assert-error]
2297- static_assert(not is_assignable_to(MethodPSuper, MethodPSub)) # error: [static-assert-error]
2293+ static_assert(not is_assignable_to(MethodPUnrelated, MethodPSuper))
2294+ static_assert(not is_assignable_to(MethodPSuper, MethodPUnrelated))
2295+ static_assert(not is_assignable_to(MethodPSuper, MethodPSub))
22982296```
22992297
23002298## Subtyping between protocols with method members and protocols with non-method members
@@ -2353,8 +2351,7 @@ And for the same reason, they are never assignable to attribute members (which a
23532351class Attribute (Protocol ):
23542352 f: Callable[[], bool ]
23552353
2356- # TODO : should pass
2357- static_assert(not is_assignable_to(Method, Attribute)) # error: [static-assert-error]
2354+ static_assert(not is_assignable_to(Method, Attribute))
23582355```
23592356
23602357Protocols with attribute members, meanwhile, cannot be assigned to protocols with method members,
@@ -2363,9 +2360,8 @@ this is not true for attribute members. The same principle also applies for prot
23632360members
23642361
23652362``` py
2366- # TODO : this should pass
2367- static_assert(not is_assignable_to(PropertyBool, Method)) # error: [static-assert-error]
2368- static_assert(not is_assignable_to(Attribute, Method)) # error: [static-assert-error]
2363+ static_assert(not is_assignable_to(PropertyBool, Method))
2364+ static_assert(not is_assignable_to(Attribute, Method))
23692365```
23702366
23712367But an exception to this rule is if an attribute member is marked as ` ClassVar ` , as this guarantees
@@ -2384,9 +2380,8 @@ static_assert(is_assignable_to(ClassVarAttribute, Method))
23842380class ClassVarAttributeBad (Protocol ):
23852381 f: ClassVar[Callable[[], str ]]
23862382
2387- # TODO : these should pass:
2388- static_assert(not is_subtype_of(ClassVarAttributeBad, Method)) # error: [static-assert-error]
2389- static_assert(not is_assignable_to(ClassVarAttributeBad, Method)) # error: [static-assert-error]
2383+ static_assert(not is_subtype_of(ClassVarAttributeBad, Method))
2384+ static_assert(not is_assignable_to(ClassVarAttributeBad, Method))
23902385```
23912386
23922387## Narrowing of protocols
@@ -2707,9 +2702,8 @@ class RecursiveNonFullyStatic(Protocol):
27072702 parent: RecursiveNonFullyStatic
27082703 x: Any
27092704
2710- # TODO : these should pass, once we take into account types of members
2711- static_assert(not is_subtype_of(RecursiveFullyStatic, RecursiveNonFullyStatic)) # error: [static-assert-error]
2712- static_assert(not is_subtype_of(RecursiveNonFullyStatic, RecursiveFullyStatic)) # error: [static-assert-error]
2705+ static_assert(not is_subtype_of(RecursiveFullyStatic, RecursiveNonFullyStatic))
2706+ static_assert(not is_subtype_of(RecursiveNonFullyStatic, RecursiveFullyStatic))
27132707
27142708static_assert(is_assignable_to(RecursiveNonFullyStatic, RecursiveNonFullyStatic))
27152709static_assert(is_assignable_to(RecursiveFullyStatic, RecursiveNonFullyStatic))
@@ -2727,9 +2721,7 @@ class RecursiveOptionalParent(Protocol):
27272721static_assert(is_assignable_to(RecursiveOptionalParent, RecursiveOptionalParent))
27282722
27292723# Due to invariance of mutable attribute members, neither is assignable to the other
2730- #
2731- # TODO : should pass
2732- static_assert(not is_assignable_to(RecursiveNonFullyStatic, RecursiveOptionalParent)) # error: [static-assert-error]
2724+ static_assert(not is_assignable_to(RecursiveNonFullyStatic, RecursiveOptionalParent))
27332725static_assert(not is_assignable_to(RecursiveOptionalParent, RecursiveNonFullyStatic))
27342726
27352727class Other (Protocol ):
0 commit comments