[Bf-blender-cvs] [f29a738e23c] master: PyAPI: use keyword only arguments
Campbell Barton
noreply at git.blender.org
Tue Jun 8 19:09:49 CEST 2021
Commit: f29a738e23ce487fc9ae759326fc3409b82f8b26
Author: Campbell Barton
Date: Tue Jun 8 18:03:14 2021 +1000
Branches: master
https://developer.blender.org/rBf29a738e23ce487fc9ae759326fc3409b82f8b26
PyAPI: use keyword only arguments
Use keyword only arguments for the following functions.
- addon_utils.module_bl_info 2nd arg `info_basis`.
- addon_utils.modules 1st `module_cache`, 2nd arg `refresh`.
- addon_utils.modules_refresh 1st arg `module_cache`.
- bl_app_template_utils.activate 1nd arg `template_id`.
- bl_app_template_utils.import_from_id 2nd arg `ignore_not_found`.
- bl_app_template_utils.import_from_path 2nd arg `ignore_not_found`.
- bl_keymap_utils.keymap_from_toolbar.generate 2nd & 3rd args `use_fallback_keys` & `use_reset`.
- bl_keymap_utils.platform_helpers.keyconfig_data_oskey_from_ctrl 2nd arg `filter_fn`.
- bl_ui_utils.bug_report_url.url_prefill_from_blender 1st arg `addon_info`.
- bmesh.types.BMFace.copy 1st & 2nd args `verts`, `edges`.
- bmesh.types.BMesh.calc_volume 1st arg `signed`.
- bmesh.types.BMesh.from_mesh 2nd..4th args `face_normals`, `use_shape_key`, `shape_key_index`.
- bmesh.types.BMesh.from_object 3rd & 4th args `cage`, `face_normals`.
- bmesh.types.BMesh.transform 2nd arg `filter`.
- bmesh.types.BMesh.update_edit_mesh 2nd & 3rd args `loop_triangles`, `destructive`.
- bmesh.types.{BMVertSeq,BMEdgeSeq,BMFaceSeq}.sort 1st & 2nd arg `key`, `reverse`.
- bmesh.utils.face_split 4th..6th args `coords`, `use_exist`, `example`.
- bpy.data.libraries.load 2nd..4th args `link`, `relative`, `assets_only`.
- bpy.data.user_map 1st..3rd args `subset`, `key_types, `value_types`.
- bpy.msgbus.subscribe_rna 5th arg `options`.
- bpy.path.abspath 2nd & 3rd args `start` & `library`.
- bpy.path.clean_name 2nd arg `replace`.
- bpy.path.ensure_ext 3rd arg `case_sensitive`.
- bpy.path.module_names 2nd arg `recursive`.
- bpy.path.relpath 2nd arg `start`.
- bpy.types.EditBone.transform 2nd & 3rd arg `scale`, `roll`.
- bpy.types.Operator.as_keywords 1st arg `ignore`.
- bpy.types.Struct.{keyframe_insert,keyframe_delete} 2nd..5th args `index`, `frame`, `group`, `options`.
- bpy.types.WindowManager.popup_menu 2nd & 3rd arg `title`, `icon`.
- bpy.types.WindowManager.popup_menu_pie 3rd & 4th arg `title`, `icon`.
- bpy.utils.app_template_paths 1st arg `subdir`.
- bpy.utils.app_template_paths 1st arg `subdir`.
- bpy.utils.blend_paths 1st..3rd args `absolute`, `packed`, `local`.
- bpy.utils.execfile 2nd arg `mod`.
- bpy.utils.keyconfig_set 2nd arg `report`.
- bpy.utils.load_scripts 1st & 2nd `reload_scripts` & `refresh_scripts`.
- bpy.utils.preset_find 3rd & 4th args `display_name`, `ext`.
- bpy.utils.resource_path 2nd & 3rd arg `major`, `minor`.
- bpy.utils.script_paths 1st..4th args `subdir`, `user_pref`, `check_all`, `use_user`.
- bpy.utils.smpte_from_frame 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.smpte_from_seconds 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.system_resource 2nd arg `subdir`.
- bpy.utils.time_from_frame 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.time_to_frame 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.units.to_string 4th..6th `precision`, `split_unit`, `compatible_unit`.
- bpy.utils.units.to_value 4th arg `str_ref_unit`.
- bpy.utils.user_resource 2nd & 3rd args `subdir`, `create`
- bpy_extras.view3d_utils.location_3d_to_region_2d 4th arg `default`.
- bpy_extras.view3d_utils.region_2d_to_origin_3d 4th arg `clamp`.
- gpu.offscreen.unbind 1st arg `restore`.
- gpu_extras.batch.batch_for_shader 4th arg `indices`.
- gpu_extras.batch.presets.draw_circle_2d 4th arg `segments`.
- gpu_extras.presets.draw_circle_2d 4th arg `segments`.
- imbuf.types.ImBuf.resize 2nd arg `resize`.
- imbuf.write 2nd arg `filepath`.
- mathutils.kdtree.KDTree.find 2nd arg `filter`.
- nodeitems_utils.NodeCategory 3rd & 4th arg `descriptions`, `items`.
- nodeitems_utils.NodeItem 2nd..4th args `label`, `settings`, `poll`.
- nodeitems_utils.NodeItemCustom 1st & 2nd arg `poll`, `draw`.
- rna_prop_ui.draw 5th arg `use_edit`.
- rna_prop_ui.rna_idprop_ui_get 2nd arg `create`.
- rna_prop_ui.rna_idprop_ui_prop_clear 3rd arg `remove`.
- rna_prop_ui.rna_idprop_ui_prop_get 3rd arg `create`.
- rna_xml.xml2rna 2nd arg `root_rna`.
- rna_xml.xml_file_write 4th arg `skip_typemap`.
===================================================================
M doc/python_api/examples/gpu.7.py
M doc/python_api/examples/gpu.8.py
M intern/cycles/blender/addon/engine.py
M release/scripts/modules/addon_utils.py
M release/scripts/modules/bl_app_template_utils.py
M release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
M release/scripts/modules/bl_keymap_utils/platform_helpers.py
M release/scripts/modules/bl_ui_utils/bug_report_url.py
M release/scripts/modules/bpy/path.py
M release/scripts/modules/bpy/utils/__init__.py
M release/scripts/modules/bpy_extras/io_utils.py
M release/scripts/modules/bpy_extras/view3d_utils.py
M release/scripts/modules/bpy_types.py
M release/scripts/modules/console/complete_calltip.py
M release/scripts/modules/console/complete_import.py
M release/scripts/modules/console/complete_namespace.py
M release/scripts/modules/console/intellisense.py
M release/scripts/modules/gpu_extras/batch.py
M release/scripts/modules/gpu_extras/presets.py
M release/scripts/modules/nodeitems_utils.py
M release/scripts/modules/rna_prop_ui.py
M release/scripts/modules/rna_xml.py
M release/scripts/startup/bl_operators/mesh.py
M release/scripts/startup/bl_operators/presets.py
M release/scripts/startup/bl_operators/userpref.py
M release/scripts/startup/bl_operators/uvcalc_follow_active.py
M release/scripts/startup/bl_operators/wm.py
M release/scripts/startup/bl_ui/space_text.py
M release/scripts/startup/bl_ui/space_toolsystem_common.py
M release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M release/scripts/startup/bl_ui/space_userpref.py
M release/scripts/startup/bl_ui/space_view3d.py
M release/scripts/startup/nodeitems_builtins.py
M release/scripts/templates_py/bmesh_simple_editmode.py
M source/blender/python/bmesh/bmesh_py_api.c
M source/blender/python/bmesh/bmesh_py_types.c
M source/blender/python/bmesh/bmesh_py_utils.c
M source/blender/python/generic/imbuf_py_api.c
M source/blender/python/gpu/gpu_py_offscreen.c
M source/blender/python/intern/bpy.c
M source/blender/python/intern/bpy_library_load.c
M source/blender/python/intern/bpy_msgbus.c
M source/blender/python/intern/bpy_rna_anim.c
M source/blender/python/intern/bpy_rna_id_collection.c
M source/blender/python/intern/bpy_utils_units.c
M source/blender/python/mathutils/mathutils_kdtree.c
M tests/python/bl_load_addons.py
M tests/python/bl_pyapi_bpy_path.py
===================================================================
diff --git a/doc/python_api/examples/gpu.7.py b/doc/python_api/examples/gpu.7.py
index 01082e7b6fe..9d881831c21 100644
--- a/doc/python_api/examples/gpu.7.py
+++ b/doc/python_api/examples/gpu.7.py
@@ -29,7 +29,7 @@ with offscreen.bind():
amount = 10
for i in range(-amount, amount + 1):
x_pos = i / amount
- draw_circle_2d((x_pos, 0.0), (1, 1, 1, 1), 0.5, 200)
+ draw_circle_2d((x_pos, 0.0), (1, 1, 1, 1), 0.5, segments=200)
# Drawing the generated texture in 3D space
diff --git a/doc/python_api/examples/gpu.8.py b/doc/python_api/examples/gpu.8.py
index 664f14a23ca..86a242b0258 100644
--- a/doc/python_api/examples/gpu.8.py
+++ b/doc/python_api/examples/gpu.8.py
@@ -34,7 +34,9 @@ with offscreen.bind():
for i in range(RING_AMOUNT):
draw_circle_2d(
(random.uniform(-1, 1), random.uniform(-1, 1)),
- (1, 1, 1, 1), random.uniform(0.1, 1), 20)
+ (1, 1, 1, 1), random.uniform(0.1, 1),
+ segments=20,
+ )
buffer = fb.read_color(0, 0, WIDTH, HEIGHT, 4, 0, 'UBYTE')
diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py
index d8398772a84..dc53c4db48f 100644
--- a/intern/cycles/blender/addon/engine.py
+++ b/intern/cycles/blender/addon/engine.py
@@ -132,7 +132,7 @@ def init():
_workaround_buggy_drivers()
path = os.path.dirname(__file__)
- user_path = os.path.dirname(os.path.abspath(bpy.utils.user_resource('CONFIG', '')))
+ user_path = os.path.dirname(os.path.abspath(bpy.utils.user_resource('CONFIG', path='')))
_cycles.init(path, user_path, bpy.app.background)
_parse_command_line()
diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py
index 1e308dc9602..239dd1cf79b 100644
--- a/release/scripts/modules/addon_utils.py
+++ b/release/scripts/modules/addon_utils.py
@@ -49,16 +49,16 @@ def _initialize():
def paths():
# RELEASE SCRIPTS: official scripts distributed in Blender releases
- addon_paths = _bpy.utils.script_paths("addons")
+ addon_paths = _bpy.utils.script_paths(subdir="addons")
# CONTRIB SCRIPTS: good for testing but not official scripts yet
# if folder addons_contrib/ exists, scripts in there will be loaded too
- addon_paths += _bpy.utils.script_paths("addons_contrib")
+ addon_paths += _bpy.utils.script_paths(subdir="addons_contrib")
return addon_paths
-def modules_refresh(module_cache=addons_fake_modules):
+def modules_refresh(*, module_cache=addons_fake_modules):
global error_encoding
import os
@@ -203,9 +203,9 @@ def modules_refresh(module_cache=addons_fake_modules):
del modules_stale
-def modules(module_cache=addons_fake_modules, *, refresh=True):
+def modules(*, module_cache=addons_fake_modules, refresh=True):
if refresh or ((module_cache is addons_fake_modules) and modules._is_first):
- modules_refresh(module_cache)
+ modules_refresh(module_cache=module_cache)
modules._is_first = False
mod_list = list(module_cache.values())
@@ -512,7 +512,7 @@ def _blender_manual_url_prefix():
return "https://docs.blender.org/manual/en/" + manual_version
-def module_bl_info(mod, info_basis=None):
+def module_bl_info(mod, *, info_basis=None):
if info_basis is None:
info_basis = {
"name": "",
diff --git a/release/scripts/modules/bl_app_template_utils.py b/release/scripts/modules/bl_app_template_utils.py
index 7db084a9a29..43c0c571cb0 100644
--- a/release/scripts/modules/bl_app_template_utils.py
+++ b/release/scripts/modules/bl_app_template_utils.py
@@ -134,7 +134,7 @@ def _disable(template_id, *, handle_error=None):
print("\tapp_template_utils.disable", template_id)
-def import_from_path(path, ignore_not_found=False):
+def import_from_path(path, *, ignore_not_found=False):
import os
from importlib import import_module
base_module, template_id = path.rsplit(os.sep, 2)[-2:]
@@ -148,9 +148,9 @@ def import_from_path(path, ignore_not_found=False):
raise ex
-def import_from_id(template_id, ignore_not_found=False):
+def import_from_id(template_id, *, ignore_not_found=False):
import os
- path = next(iter(_bpy.utils.app_template_paths(template_id)), None)
+ path = next(iter(_bpy.utils.app_template_paths(path=template_id)), None)
if path is None:
if ignore_not_found:
return None
@@ -163,7 +163,7 @@ def import_from_id(template_id, ignore_not_found=False):
return import_from_path(path, ignore_not_found=ignore_not_found)
-def activate(template_id=None):
+def activate(*, template_id=None):
template_id_prev = _app_template["id"]
# not needed but may as well avoids redundant
@@ -190,4 +190,4 @@ def reset(*, reload_scripts=False):
# TODO reload_scripts
- activate(template_id)
+ activate(template_id=template_id)
diff --git a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
index ef398d5e08f..aff1108568b 100644
--- a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
+++ b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
@@ -26,7 +26,7 @@ __all__ = (
)
-def generate(context, space_type, use_fallback_keys=True, use_reset=True):
+def generate(context, space_type, *, use_fallback_keys=True, use_reset=True):
"""
Keymap for popup toolbar, currently generated each time.
"""
diff --git a/release/scripts/modules/bl_keymap_utils/platform_helpers.py b/release/scripts/modules/bl_keymap_utils/platform_helpers.py
index a6058b993d5..848eb4e10c4 100644
--- a/release/scripts/modules/bl_keymap_utils/platform_helpers.py
+++ b/release/scripts/modules/bl_keymap_utils/platform_helpers.py
@@ -17,7 +17,7 @@
# ##### END GPL LICENSE BLOCK #####
-def keyconfig_data_oskey_from_ctrl(keyconfig_data_src, filter_fn=None):
+def keyconfig_data_oskey_from_ctrl(keyconfig_data_src, *, filter_fn=None):
keyconfig_data_dst = []
for km_name, km_parms, km_items_data_src in keyconfig_data_src:
km_items_data_dst = km_items_data_src.copy()
@@ -61,4 +61,4 @@ def keyconfig_data_oskey_from_ctrl_for_macos(keyconfig_data_src):
return False
return True
- return keyconfig_data_oskey_from_ctrl(keyconfig_data_src, filter_fn)
+ return keyconfig_data_oskey_from_ctrl(keyconfig_data_src, filter_fn=filter_fn)
diff --git a/release/scripts/modules/bl_ui_utils/bug_report_url.py b/release/scripts/modules/bl_ui_utils/bug_report_url.py
index 3fc57467dac..ef6a261f776 100644
--- a/release/scripts/modules/bl_ui_utils/bug_report_url.py
+++ b/release/scripts/modules/bl_ui_utils/bug_report_url.py
@@ -19,7 +19,7 @@
# <pep8-80 compliant>
-def url_prefill_from_blender(addon_info=None):
+def url_prefill_from_blender(*, addon_info=None):
import bpy
import gpu
import struct
diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py
index 1de4542e69e..30f93d051e5 100644
--- a/release/scripts/modules/bpy/path.py
+++ b/release/scripts/modules/bpy/path.py
@@ -56,7 +56,7 @@ def _getattr_bytes(var, attr):
return var.path_resolve(attr, False).as_bytes()
-def abspath(path, start=None, library=None):
+def abspath(path, *, start=None, library=None):
"""
Returns the absolute path relative to the current blend file
using the "//" prefix.
@@ -92,7 +92,7 @@ def abspath(path, start=None, library=None):
return path
-def relpath(path, start=None):
+def relpath(path, *, start=None):
"""
Returns the path relative to the current blend file using the "//" prefix.
@@ -134,7 +134,7 @@ def is_subdir(path, directory):
return False
-def clean_name(name, replace="_"):
+def clean_name(name, *, replace="_"):
"""
Returns a name with characters replaced that
may cause problems under various circumstances,
@@ -311,7 +311,7 @@ def resolve_ncase(path):
return ncase_path if found else path
-def ensure_ext(filepath, ext, case_sensitive=False):
+def ensure_ext(filepath, ext, *, case_sensitive=False):
"""
Return the path with the extension added if it is not already set.
@@ -332,7 +332,7 @@ def ensure_ext(filepath, ext, case_sensitive=False):
return filepath + ext
-def module_names(path, recursive=False):
+def module_names(path, *, recursive=False):
"""
Return a list of modules which can be imported from *path*.
@@ -361,7 +361,7 @@ def module_names(path, recursive=False):
if isfile(fullpath):
modules.append((filename, fullpath))
if recursive:
- for mod_name, mod_path in module_names(directory, True):
+ for mod_name, mod_path in module_names(directory, recursive=True):
modules.append(("%s.%s" % (filename, mod_name),
mod_path,
))
diff --git a/release/scripts/modules/bpy/utils/__init__.py b/release/scripts/modules/bpy/utils/__init__.py
index 2b19d23a367..e6c7bca3e3c 100644
--- a/release/scripts/modules/bpy/utils/__init__.py
+++ b/release/scripts/modules/bpy/utils/__init__.py
@@ -81,7 +81,7 @@ _script_module_dirs = "startup", "modules"
_is_factory_startup = _bpy.app.factory_startup
-def execfile(filepath, mod=None):
+def execfile(filepath, *, mod=None):
"""
Execute a file path as a Python script.
@@ -193,7 +193,7 @@ _global_loaded_modules = [] # store loaded module names for reloading.
import bpy_types as _bpy_types # keep for comparisons, never ever reload this.
-def load_scripts(reload_scripts=False, refresh_scripts=False):
+def load_scripts(*, reload_scripts=False, refresh_scripts=False):
"""
Load scripts and run each modules register function.
@@ -357,7 +357,7 @@ def script_path_pref():
return _os.path.normpath(path) if path else None
-def script_paths(subdir=None, user_pref=True, check_all=False, use_user=True):
+def script_paths(*, subdir=None, user_pref=True, check_all=False, use_user=True):
"""
Returns
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list