@@ -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
@@ -2286,10 +2285,9 @@ class MethodPUnrelated(Protocol):
22862285
22872286static_assert(is_subtype_of(MethodPSub, MethodPSuper))
22882287
2289- # TODO : these should pass
2290- static_assert(not is_assignable_to(MethodPUnrelated, MethodPSuper)) # error: [static-assert-error]
2291- static_assert(not is_assignable_to(MethodPSuper, MethodPUnrelated)) # error: [static-assert-error]
2292- static_assert(not is_assignable_to(MethodPSuper, MethodPSub)) # error: [static-assert-error]
2288+ static_assert(not is_assignable_to(MethodPUnrelated, MethodPSuper))
2289+ static_assert(not is_assignable_to(MethodPSuper, MethodPUnrelated))
2290+ static_assert(not is_assignable_to(MethodPSuper, MethodPSub))
22932291```
22942292
22952293## Subtyping between protocols with method members and protocols with non-method members
@@ -2348,8 +2346,7 @@ And for the same reason, they are never assignable to attribute members (which a
23482346class Attribute (Protocol ):
23492347 f: Callable[[], bool ]
23502348
2351- # TODO : should pass
2352- static_assert(not is_assignable_to(Method, Attribute)) # error: [static-assert-error]
2349+ static_assert(not is_assignable_to(Method, Attribute))
23532350```
23542351
23552352Protocols with attribute members, meanwhile, cannot be assigned to protocols with method members,
@@ -2358,9 +2355,8 @@ this is not true for attribute members. The same principle also applies for prot
23582355members
23592356
23602357``` py
2361- # TODO : this should pass
2362- static_assert(not is_assignable_to(PropertyBool, Method)) # error: [static-assert-error]
2363- static_assert(not is_assignable_to(Attribute, Method)) # error: [static-assert-error]
2358+ static_assert(not is_assignable_to(PropertyBool, Method))
2359+ static_assert(not is_assignable_to(Attribute, Method))
23642360```
23652361
23662362But an exception to this rule is if an attribute member is marked as ` ClassVar ` , as this guarantees
@@ -2379,9 +2375,8 @@ static_assert(is_assignable_to(ClassVarAttribute, Method))
23792375class ClassVarAttributeBad (Protocol ):
23802376 f: ClassVar[Callable[[], str ]]
23812377
2382- # TODO : these should pass:
2383- static_assert(not is_subtype_of(ClassVarAttributeBad, Method)) # error: [static-assert-error]
2384- static_assert(not is_assignable_to(ClassVarAttributeBad, Method)) # error: [static-assert-error]
2378+ static_assert(not is_subtype_of(ClassVarAttributeBad, Method))
2379+ static_assert(not is_assignable_to(ClassVarAttributeBad, Method))
23852380```
23862381
23872382## Narrowing of protocols
@@ -2702,9 +2697,8 @@ class RecursiveNonFullyStatic(Protocol):
27022697 parent: RecursiveNonFullyStatic
27032698 x: Any
27042699
2705- # TODO : these should pass, once we take into account types of members
2706- static_assert(not is_subtype_of(RecursiveFullyStatic, RecursiveNonFullyStatic)) # error: [static-assert-error]
2707- static_assert(not is_subtype_of(RecursiveNonFullyStatic, RecursiveFullyStatic)) # error: [static-assert-error]
2700+ static_assert(not is_subtype_of(RecursiveFullyStatic, RecursiveNonFullyStatic))
2701+ static_assert(not is_subtype_of(RecursiveNonFullyStatic, RecursiveFullyStatic))
27082702
27092703static_assert(is_assignable_to(RecursiveNonFullyStatic, RecursiveNonFullyStatic))
27102704static_assert(is_assignable_to(RecursiveFullyStatic, RecursiveNonFullyStatic))
@@ -2722,9 +2716,7 @@ class RecursiveOptionalParent(Protocol):
27222716static_assert(is_assignable_to(RecursiveOptionalParent, RecursiveOptionalParent))
27232717
27242718# Due to invariance of mutable attribute members, neither is assignable to the other
2725- #
2726- # TODO : should pass
2727- static_assert(not is_assignable_to(RecursiveNonFullyStatic, RecursiveOptionalParent)) # error: [static-assert-error]
2719+ static_assert(not is_assignable_to(RecursiveNonFullyStatic, RecursiveOptionalParent))
27282720static_assert(not is_assignable_to(RecursiveOptionalParent, RecursiveNonFullyStatic))
27292721
27302722class Other (Protocol ):
0 commit comments