You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
types.FunctionType is not included in builtin library #92316
Most of the types in types report themselves this way (a minority claim to be part of the types module instead). That said, they shouldn't be in the builtins module, because that would cause them all to be injected into the namespace of every script, and most of them are not nearly useful enough to justify cluttering every namespace with them. I suspect they claim to be from builtins because they are, in fact, built-in types (instances of them get created implicitly when you define Python level functions), but they're largely C API constructs that types is exposing for the rare case they're needed.
In short, no, they shouldn't be exposed the builtins module. Arguably, they should be changed to claim membership in the types module, but it's a little weird because types is merely exposing them; they exist independent of the types module, they're just not very discoverable otherwise.
Reacted by MengXiangge, Alex Waygood and Gouvernathor
Activity
MojoVampire commentedon May 5, 2022
Most of the types in
typesreport themselves this way (a minority claim to be part of thetypesmodule instead). That said, they shouldn't be in thebuiltinsmodule, because that would cause them all to be injected into the namespace of every script, and most of them are not nearly useful enough to justify cluttering every namespace with them. I suspect they claim to be frombuiltinsbecause they are, in fact, built-in types (instances of them get created implicitly when you define Python level functions), but they're largely C API constructs thattypesis exposing for the rare case they're needed.In short, no, they shouldn't be exposed the
builtinsmodule. Arguably, they should be changed to claim membership in thetypesmodule, but it's a little weird becausetypesis merely exposing them; they exist independent of thetypesmodule, they're just not very discoverable otherwise.serhiy-storchaka commentedon Jun 2, 2026
This is a duplicate of #100129 which has a PR.