From 7e9acb06f265f73da8b5336a6f6d809541da21ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 11 Jun 2024 19:32:08 +0200 Subject: [PATCH] python: don't leak local __init__.py variables to python introspection. Causes pybind11-stubgen (and probably other tools as well) to include `i` in the output, which feels dirty. --- src/python/corrade/__init__.py.in | 4 ++++ src/python/magnum/__init__.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/python/corrade/__init__.py.in b/src/python/corrade/__init__.py.in index db77d70..b35f2f5 100644 --- a/src/python/corrade/__init__.py.in +++ b/src/python/corrade/__init__.py.in @@ -60,6 +60,10 @@ import sys for i in ['containers', 'pluginmanager', 'utility']: if i in globals(): sys.modules['corrade.' + i] = globals()[i] +# Just to not have the variable leak into stubs generated by pybind11-stubgen +# TODO any way to exclude it? +del i + # Prevent all submodules being pulled in when saying `from corrade import *` -- # this is consistent with behavior in magnum __all__ = [ diff --git a/src/python/magnum/__init__.py b/src/python/magnum/__init__.py index 9eb1135..c0282eb 100644 --- a/src/python/magnum/__init__.py +++ b/src/python/magnum/__init__.py @@ -52,6 +52,10 @@ if 'scenegraph' in globals(): for i in ['matrix', 'trs']: sys.modules['magnum.scenegraph.' + i] = getattr(scenegraph, i) +# Just to not have the variable leak into stubs generated by pybind11-stubgen +# TODO any way to exclude it? +del i + __all__ = [ 'Deg', 'Rad',