@@ -411,7 +411,7 @@ Vec2(0.0, 0.0)
411411
412412## ` super() ` is not supported in NamedTuple methods
413413
414- Using ` super() ` in a method of a ` NamedTuple ` subclass will raise an exception at runtime. In Python
414+ Using ` super() ` in a method of a ` NamedTuple ` class will raise an exception at runtime. In Python
4154153.14+, a ` TypeError ` is raised; in earlier versions, a confusing ` RuntimeError ` about
416416` __classcell__ ` is raised.
417417
@@ -422,35 +422,35 @@ class F(NamedTuple):
422422 x: int
423423
424424 def method (self ):
425- # error: [super-call-in-named-tuple-method] "Cannot use `super()` in a method of NamedTuple subclass `F`"
425+ # error: [super-call-in-named-tuple-method] "Cannot use `super()` in a method of NamedTuple class `F`"
426426 super ()
427427
428428 def method_with_args (self ):
429- # error: [super-call-in-named-tuple-method] "Cannot use `super()` in a method of NamedTuple subclass `F`"
429+ # error: [super-call-in-named-tuple-method] "Cannot use `super()` in a method of NamedTuple class `F`"
430430 super (F, self )
431431
432432 def method_with_different_pivot (self ):
433433 # Even passing a different pivot class fails.
434- # error: [super-call-in-named-tuple-method] "Cannot use `super()` in a method of NamedTuple subclass `F`"
434+ # error: [super-call-in-named-tuple-method] "Cannot use `super()` in a method of NamedTuple class `F`"
435435 super (tuple , self )
436436
437437 @ classmethod
438438 def class_method (cls ):
439- # error: [super-call-in-named-tuple-method] "Cannot use `super()` in a method of NamedTuple subclass `F`"
439+ # error: [super-call-in-named-tuple-method] "Cannot use `super()` in a method of NamedTuple class `F`"
440440 super ()
441441
442442 @ staticmethod
443443 def static_method ():
444- # error: [super-call-in-named-tuple-method] "Cannot use `super()` in a method of NamedTuple subclass `F`"
444+ # error: [super-call-in-named-tuple-method] "Cannot use `super()` in a method of NamedTuple class `F`"
445445 super ()
446446
447447 @ property
448448 def prop (self ):
449- # error: [super-call-in-named-tuple-method] "Cannot use `super()` in a method of NamedTuple subclass `F`"
449+ # error: [super-call-in-named-tuple-method] "Cannot use `super()` in a method of NamedTuple class `F`"
450450 return super ()
451451```
452452
453- However, classes that ** inherit from** a ` NamedTuple ` subclass (but don't directly inherit from
453+ However, classes that ** inherit from** a ` NamedTuple ` class (but don't directly inherit from
454454` NamedTuple ` ) can use ` super() ` normally:
455455
456456``` py
@@ -471,3 +471,14 @@ class Regular:
471471 def method (self ):
472472 super () # fine
473473```
474+
475+ Using ` super() ` on a ` NamedTuple ` class also works fine if it occurs outside the class:
476+
477+ ``` py
478+ from typing import NamedTuple
479+
480+ class F (NamedTuple ):
481+ x: int
482+
483+ super (F, F(42 )) # fine
484+ ```
0 commit comments