Cleanup: declare __all__ for Python scripts

Declare all to make public public API's explicit and
help detect unused code.
This commit is contained in:
Campbell Barton
2025-01-06 16:45:36 +11:00
parent 6ac52551d3
commit 4f1817cc18
31 changed files with 285 additions and 140 deletions

View File

@@ -2,16 +2,19 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
"""
blender -b --factory-startup --python tests/python/bl_animation_drivers.py -- --testdir /path/to/tests/data/animation
"""
__all__ = (
"main",
)
import unittest
import bpy
import pathlib
import sys
from rna_prop_ui import rna_idprop_quote_path
"""
blender -b --factory-startup --python tests/python/bl_animation_drivers.py -- --testdir /path/to/tests/data/animation
"""
class AbstractEmptyDriverTest:
def setUp(self):

View File

@@ -2,7 +2,13 @@
#
# SPDX-License-Identifier: Apache-2.0
# ./blender.bin --background --python tests/python/bl_blendfile_liblink.py
"""
./blender.bin --background --python tests/python/bl_blendfile_liblink.py
"""
__all__ = (
"main",
)
import bpy
import os
import sys

View File

@@ -9,6 +9,10 @@
#
# This needs to be investigated!
__all__ = (
"main",
)
import os
import platform
import sys

View File

@@ -2,6 +2,10 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"main",
)
import os
import pathlib
import sys

View File

@@ -3,6 +3,10 @@
#
# SPDX-License-Identifier: Apache-2.0
__all__ = (
"main",
)
import argparse
import os
import sys

View File

@@ -7,6 +7,9 @@
"""
./blender.bin --background --factory-startup --python tests/python/bl_load_addons.py
"""
__all__ = (
"main",
)
import bpy
import addon_utils

View File

@@ -5,6 +5,10 @@
# Simple script to check mash validate code.
# XXX Should be extended with many more "wrong cases"!
__all__ = (
"main",
)
import bpy
import random

View File

@@ -3,6 +3,11 @@
# SPDX-License-Identifier: Apache-2.0
# ./blender.bin --background --python tests/python/bl_pyapi_bpy_utils_units.py -- --verbose
__all__ = (
"main",
)
import unittest
from bpy.utils import units
@@ -93,7 +98,11 @@ class UnitsTesting(unittest.TestCase):
)
if __name__ == '__main__':
def main():
import sys
sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])
unittest.main()
if __name__ == '__main__':
main()

View File

@@ -2,6 +2,10 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
__all__ = (
"AbstractImBufTest",
)
import os
import pathlib
import shutil