Message384506
The documentation (https://docs.python.org/3/library/functions.html#type) shows type's signature as:
class type(object)
class type(name, bases, dict)
But the "actual" 2nd signature in CPython 3.6+ is:
class type(name, bases, dict, **kwargs)
**kwargs here gets passed to __init_subclass__ in the same way that keywords in a class statement do so that:
type("Bar", (Foo,), {}, spam='ham')
is equivalent to
class Bar(Foo, spam='ham'): pass
It's not clear to me whether this is behavior to rely on. I started using this intuitively, but found that my type checker reasonably complained.
Looking through the commit that implemented PEP 487 (d78448e9), it seems this may have been incidental. Additionally I haven't found mention of this in PEP 487 or the documentation and I can't seem to find any tests for it. |
|
Date |
User |
Action |
Args |
2021-01-06 15:21:21 | esoma | set | recipients:
+ esoma |
2021-01-06 15:21:21 | esoma | set | messageid: <1609946481.51.0.225785046936.issue42840@roundup.psfhosted.org> |
2021-01-06 15:21:21 | esoma | link | issue42840 messages |
2021-01-06 15:21:21 | esoma | create | |
|