From 39e73b626e52a1de962dd1ba46a3c3955f57752f Mon Sep 17 00:00:00 2001 From: Isamu Mogi Date: Thu, 20 Jun 2024 06:04:52 +0900 Subject: [PATCH] chore: include saturday06/starry-bpy-type-stubs https://github.com/saturday06/starry-bpy-type-stubs/tree/7b95f5d5819af39d0241180ecd641307a1608f5d --- .gitignore | 1 + poetry.lock | 19 +- pyproject.toml | 18 +- tools/format.bat | 5 +- tools/format.sh | 4 +- tools/lint.bat | 7 +- tools/lint.sh | 8 +- typings/bgl-stubs/__init__.pyi | 28 + typings/bmesh-stubs/__init__.pyi | 4 + typings/bmesh-stubs/ops/__init__.pyi | 8 + typings/bmesh-stubs/types/__init__.pyi | 110 + typings/bpy-stubs/__init__.pyi | 9 + typings/bpy-stubs/app/__init__.pyi | 27 + typings/bpy-stubs/app/handlers/__init__.pyi | 13 + typings/bpy-stubs/app/timers/__init__.pyi | 8 + .../bpy-stubs/app/translations/__init__.pyi | 10 + typings/bpy-stubs/context/__init__.pyi | 1 + .../context/preferences/__init__.pyi | 1 + .../context/preferences/view/__init__.pyi | 1 + typings/bpy-stubs/msgbus/__init__.pyi | 10 + typings/bpy-stubs/ops/__init__.pyi | 10 + .../bpy-stubs/ops/export_scene/__init__.pyi | 95 + typings/bpy-stubs/ops/icyp/__init__.pyi | 7 + .../bpy-stubs/ops/import_scene/__init__.pyi | 34 + typings/bpy-stubs/ops/mesh/__init__.pyi | 13 + typings/bpy-stubs/ops/object/__init__.pyi | 91 + typings/bpy-stubs/ops/outliner/__init__.pyi | 9 + .../bpy-stubs/ops/preferences/__init__.pyi | 17 + typings/bpy-stubs/ops/uv/__init__.pyi | 11 + typings/bpy-stubs/ops/vrm/__init__.pyi | 105 + typings/bpy-stubs/ops/wm/__init__.pyi | 136 ++ typings/bpy-stubs/props/__init__.pyi | 154 ++ typings/bpy-stubs/types/__init__.pyi | 1940 +++++++++++++++++ typings/bpy-stubs/utils/__init__.pyi | 46 + typings/bpy_extras-stubs/__init__.pyi | 2 + .../bpy_extras-stubs/io_utils/__init__.pyi | 19 + .../node_shader_utils/__init__.pyi | 274 +++ .../view3d_utils/__init__.pyi | 33 + typings/gpu-stubs/__init__.pyi | 1 + typings/gpu-stubs/types/__init__.pyi | 42 + typings/gpu_extras-stubs/__init__.pyi | 1 + typings/gpu_extras-stubs/batch/__init__.pyi | 8 + typings/idprop-stubs/__init__.pyi | 1 + typings/idprop-stubs/types/__init__.pyi | 4 + typings/mathutils-stubs/__init__.pyi | 139 ++ typings/ruff.toml | 17 + 46 files changed, 3469 insertions(+), 32 deletions(-) create mode 100644 typings/bgl-stubs/__init__.pyi create mode 100644 typings/bmesh-stubs/__init__.pyi create mode 100644 typings/bmesh-stubs/ops/__init__.pyi create mode 100644 typings/bmesh-stubs/types/__init__.pyi create mode 100644 typings/bpy-stubs/__init__.pyi create mode 100644 typings/bpy-stubs/app/__init__.pyi create mode 100644 typings/bpy-stubs/app/handlers/__init__.pyi create mode 100644 typings/bpy-stubs/app/timers/__init__.pyi create mode 100644 typings/bpy-stubs/app/translations/__init__.pyi create mode 100644 typings/bpy-stubs/context/__init__.pyi create mode 100644 typings/bpy-stubs/context/preferences/__init__.pyi create mode 100644 typings/bpy-stubs/context/preferences/view/__init__.pyi create mode 100644 typings/bpy-stubs/msgbus/__init__.pyi create mode 100644 typings/bpy-stubs/ops/__init__.pyi create mode 100644 typings/bpy-stubs/ops/export_scene/__init__.pyi create mode 100644 typings/bpy-stubs/ops/icyp/__init__.pyi create mode 100644 typings/bpy-stubs/ops/import_scene/__init__.pyi create mode 100644 typings/bpy-stubs/ops/mesh/__init__.pyi create mode 100644 typings/bpy-stubs/ops/object/__init__.pyi create mode 100644 typings/bpy-stubs/ops/outliner/__init__.pyi create mode 100644 typings/bpy-stubs/ops/preferences/__init__.pyi create mode 100644 typings/bpy-stubs/ops/uv/__init__.pyi create mode 100644 typings/bpy-stubs/ops/vrm/__init__.pyi create mode 100644 typings/bpy-stubs/ops/wm/__init__.pyi create mode 100644 typings/bpy-stubs/props/__init__.pyi create mode 100644 typings/bpy-stubs/types/__init__.pyi create mode 100644 typings/bpy-stubs/utils/__init__.pyi create mode 100644 typings/bpy_extras-stubs/__init__.pyi create mode 100644 typings/bpy_extras-stubs/io_utils/__init__.pyi create mode 100644 typings/bpy_extras-stubs/node_shader_utils/__init__.pyi create mode 100644 typings/bpy_extras-stubs/view3d_utils/__init__.pyi create mode 100644 typings/gpu-stubs/__init__.pyi create mode 100644 typings/gpu-stubs/types/__init__.pyi create mode 100644 typings/gpu_extras-stubs/__init__.pyi create mode 100644 typings/gpu_extras-stubs/batch/__init__.pyi create mode 100644 typings/idprop-stubs/__init__.pyi create mode 100644 typings/idprop-stubs/types/__init__.pyi create mode 100644 typings/mathutils-stubs/__init__.pyi create mode 100644 typings/ruff.toml diff --git a/.gitignore b/.gitignore index c25977838..7dac92802 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ !/tools/*.wsb !/tests/ruff.toml !/tests/resources +!/typings/ruff.toml *.blend1 *~ diff --git a/poetry.lock b/poetry.lock index 7bc043165..cb964e121 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "bpy" @@ -563,21 +563,6 @@ files = [ {file = "ruff-0.4.9.tar.gz", hash = "sha256:f1cb0828ac9533ba0135d148d214e284711ede33640465e706772645483427e3"}, ] -[[package]] -name = "starry-bpy-type-stubs" -version = "1.0.0" -description = "" -optional = false -python-versions = ">=3.9" -files = [] -develop = false - -[package.source] -type = "git" -url = "https://github.com/saturday06/starry-bpy-type-stubs.git" -reference = "HEAD" -resolved_reference = "7b95f5d5819af39d0241180ecd641307a1608f5d" - [[package]] name = "tomli" version = "2.0.1" @@ -712,4 +697,4 @@ cffi = ["cffi (>=1.11)"] [metadata] lock-version = "2.0" python-versions = "3.10.*" -content-hash = "418c53a236bfdb889742537e4e8de07a8134c599d3788bb3423758a994a5bdbe" +content-hash = "e4fc7e6c81ae219cd2a93c57fe0ac75383ce983ee92abbd5c419887dd183f8f4" diff --git a/pyproject.toml b/pyproject.toml index b1992a9ca..deacb9873 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,6 +8,18 @@ description = "" authors = ["Isamu Mogi ", "iCyP"] license = "MIT" +packages = [ + { include = "*", from = "src" }, + { include = "bgl-stubs", from = "typings" }, + { include = "bmesh-stubs", from = "typings" }, + { include = "bpy-stubs", from = "typings" }, + { include = "bpy_extras-stubs", from = "typings" }, + { include = "gpu-stubs", from = "typings" }, + { include = "gpu_extras-stubs", from = "typings" }, + { include = "idprop-stubs", from = "typings" }, + { include = "mathutils-stubs", from = "typings" }, +] + [tool.poetry.dependencies] python = "3.10.*" # I actually want to use 3.9, but bpy 3.6.* doesn't allow it. @@ -25,12 +37,11 @@ dulwich = "*" mypy = "*" pyright = "*" ruff = "*" -starry-bpy-type-stubs = { git = "https://github.com/saturday06/starry-bpy-type-stubs.git" } tqdm = "*" types-tqdm = "*" [tool.ruff] -src = ["src"] +src = ["typings", "src"] [tool.ruff.lint] allowed-confusables = [ @@ -122,7 +133,7 @@ ignore-regex = ".* # codespell-ignore" [tool.mypy] python_version = "3.9" -mypy_path = "$MYPY_CONFIG_FILE_DIR/src" +mypy_path = "$MYPY_CONFIG_FILE_DIR/typings:$MYPY_CONFIG_FILE_DIR/src" strict = true disallow_any_unimported = true disallow_any_decorated = true @@ -145,7 +156,6 @@ typeCheckingMode = "strict" reportMissingModuleSource = false reportCallInDefaultInitializer = true reportImplicitStringConcatenation = true -reportPropertyTypeMismatch = true reportShadowedImports = true [build-system] diff --git a/tools/format.bat b/tools/format.bat index e93db24b5..84d42228c 100644 --- a/tools/format.bat +++ b/tools/format.bat @@ -3,8 +3,9 @@ setlocal enabledelayedexpansion pushd "%~dp0.." set PYTHONUTF8=1 for /f "tokens=* usebackq" %%f in (`git ls-files "*.py"`) do ( set py_files=!py_files! %%f ) -call poetry run ruff format %py_files% -call poetry run ruff check --fix %py_files% +for /f "tokens=* usebackq" %%f in (`git ls-files "*.pyi"`) do ( set pyi_files=!pyi_files! %%f ) +call poetry run ruff format %py_files% %pyi_files% +call poetry run ruff check --fix %py_files% %pyi_files% echo on popd endlocal diff --git a/tools/format.sh b/tools/format.sh index ad0e0842a..db8eb7558 100755 --- a/tools/format.sh +++ b/tools/format.sh @@ -4,6 +4,6 @@ set -eux cd "$(dirname "$0")/.." -git ls-files "*.py" | xargs poetry run ruff format -git ls-files "*.py" | xargs poetry run ruff check --fix +git ls-files "*.py" "*.pyi" | xargs poetry run ruff format +git ls-files "*.py" "*.pyi" | xargs poetry run ruff check --fix git ls-files "*.sh" | xargs shfmt -w -s diff --git a/tools/lint.bat b/tools/lint.bat index 1c86356d6..a2c83cbf6 100644 --- a/tools/lint.bat +++ b/tools/lint.bat @@ -6,14 +6,15 @@ set PYTHONUTF8=1 echo ### poetry check ### poetry check for /f "tokens=* usebackq" %%f in (`git ls-files "*.py"`) do ( set py_files=!py_files! %%f ) +for /f "tokens=* usebackq" %%f in (`git ls-files "*.pyi"`) do ( set pyi_files=!pyi_files! %%f ) echo ### ruff ### -call poetry run ruff check %py_files% +call poetry run ruff check %py_files% %pyi_files% echo ### codespell ### call poetry run codespell %py_files% echo ### mypy ### -call poetry run mypy --show-error-codes %py_files% +call poetry run mypy --show-error-codes %py_files% %pyi_files% echo ### pyright ### -call poetry run pyright %py_files% +call poetry run pyright %py_files% %pyi_files% popd endlocal endlocal diff --git a/tools/lint.sh b/tools/lint.sh index ec73b3877..c3b39021c 100755 --- a/tools/lint.sh +++ b/tools/lint.sh @@ -6,9 +6,9 @@ cd "$(dirname "$0")/.." poetry check git ls-files "*.sh" | xargs shellcheck -git ls-files "*.py" | xargs poetry run ruff check -git ls-files "*.py" | xargs poetry run codespell -git ls-files "*.py" | xargs poetry run mypy --show-error-codes -git ls-files "*.py" | xargs poetry run pyright +git ls-files "*.py" "*.pyi" | xargs poetry run ruff check +git ls-files "*.py" "*.pyi" | xargs poetry run codespell +git ls-files "*.py" "*.pyi" | xargs poetry run mypy --show-error-codes +git ls-files "*.py" "*.pyi" | xargs poetry run pyright git ls-files "*.sh" | xargs shfmt -d -s git ls-files "*/Dockerfile" "*.dockerfile" | xargs hadolint diff --git a/typings/bgl-stubs/__init__.pyi b/typings/bgl-stubs/__init__.pyi new file mode 100644 index 000000000..4a0c52aee --- /dev/null +++ b/typings/bgl-stubs/__init__.pyi @@ -0,0 +1,28 @@ +GL_BACK: int +GL_BLEND: int +GL_CLAMP_TO_EDGE: int +GL_COLOR_BUFFER_BIT: int +GL_CULL_FACE: int +GL_DEPTH_BUFFER_BIT: int +GL_DEPTH_TEST: int +GL_ONE: int +GL_ONE_MINUS_SRC_ALPHA: int +GL_SRC_ALPHA: int +GL_TEXTURE0: int +GL_TEXTURE1: int +GL_TEXTURE_2D: int +GL_TEXTURE_WRAP_S: int +GL_TEXTURE_WRAP_T: int +GL_TRUE: int +GL_ZERO: int + +def glClearColor(red: float, green: float, blue: float, alpha: float) -> None: ... +def glClear(mask: int) -> None: ... +def glEnable(cap: int) -> None: ... +def glDisable(cap: int) -> None: ... +def glBlendFunc(sfactor: int, dfactor: int) -> None: ... +def glDepthMask(flag: int) -> None: ... +def glCullFace(mode: int) -> None: ... +def glActiveTexture(texture: int) -> None: ... +def glBindTexture(target: int, texture: int) -> None: ... +def glTexParameteri(target: int, pname: int, param: int) -> None: ... diff --git a/typings/bmesh-stubs/__init__.pyi b/typings/bmesh-stubs/__init__.pyi new file mode 100644 index 000000000..2485a6006 --- /dev/null +++ b/typings/bmesh-stubs/__init__.pyi @@ -0,0 +1,4 @@ +from . import ops as ops +from . import types as types + +def new(use_operators: bool = True) -> types.BMesh: ... diff --git a/typings/bmesh-stubs/ops/__init__.pyi b/typings/bmesh-stubs/ops/__init__.pyi new file mode 100644 index 000000000..378b665b3 --- /dev/null +++ b/typings/bmesh-stubs/ops/__init__.pyi @@ -0,0 +1,8 @@ +from bmesh.types import BMesh, BMFaceSeq + +def recalc_face_normals( + bm: BMesh, + /, + *, + faces: BMFaceSeq = ..., +) -> set[str]: ... diff --git a/typings/bmesh-stubs/types/__init__.pyi b/typings/bmesh-stubs/types/__init__.pyi new file mode 100644 index 000000000..a73b3b073 --- /dev/null +++ b/typings/bmesh-stubs/types/__init__.pyi @@ -0,0 +1,110 @@ +from collections.abc import Iterator, Sequence +from typing import Generic, Optional, TypeVar + +from bpy.types import Mesh +from mathutils import Vector + +__BMElemSeqElement = TypeVar("__BMElemSeqElement") + +class BMElemSeq(Generic[__BMElemSeqElement]): + def __len__(self) -> int: ... + def __getitem__(self, key: int) -> __BMElemSeqElement: ... + def __iter__(self) -> Iterator[__BMElemSeqElement]: ... + +class BMLoopUV: + uv: Vector + +class BMVert: + index: int + co: Vector + + def __getitem__( + self, + value: BMLoopUV, + ) -> Vector: ... # ドキュメントには存在しない + +class BMLayerItem: + def copy_from(self, other: BMLayerItem) -> None: ... + @property + def name(self) -> str: ... + +class BMLayerCollection: + def __getitem__(self, key: str) -> BMLoopUV: ... # ドキュメントに記載はない? + def keys(self) -> Iterator[str]: ... + def values(self) -> Iterator[BMLayerItem]: ... + def items(self) -> Iterator[tuple[str, BMLayerItem]]: ... + +class BMLayerAccessLoop: + uv: BMLayerCollection + +class BMLayerAccessVert: + shape: BMLayerCollection + +class BMVertSeq: + def new( + self, + co: Sequence[float] = (0.0, 0.0, 0.0), + example: Optional[BMVert] = None, + ) -> BMVert: ... + @property + def layers(self) -> BMLayerAccessVert: ... + +class BMEdge: ... + +class BMEdgeSeq: + def new( + self, + verts: tuple[ + BMVert, + BMVert, + ], # 実際にはSequenceだと思うが、2要素チェックをしたいのでtuple + example: Optional[BMEdge] = None, + ) -> BMEdge: ... + +class BMLoop: + index: int + @property + def face(self) -> BMFace: ... + @property + def vert(self) -> BMVert: ... + def __getitem__( + self, + uv: BMLoopUV, + ) -> BMLoopUV: ... # TODO: ドキュメントに存在しない + +class BMLoopSeq: + @property + def layers(self) -> BMLayerAccessLoop: ... + +class BMFace: + material_index: int + @property + def loops(self) -> BMElemSeq[BMLoop]: ... + +class BMFaceSeq: + def new( + self, + verts: Sequence[BMVert], + example: Optional[BMFace] = None, + ) -> BMFace: ... + def __iter__(self) -> Iterator[BMFace]: ... + +class BMesh: + @property + def faces(self) -> BMFaceSeq: ... + @property + def edges(self) -> BMEdgeSeq: ... + @property + def verts(self) -> BMVertSeq: ... + @property + def loops(self) -> BMLoopSeq: ... + def free(self) -> None: ... + def to_mesh(self, mesh: Mesh) -> None: ... + def from_mesh( + self, + mesh: Mesh, + face_normals: bool = True, + use_shape_key: bool = False, + shape_key_index: int = 0, + ) -> None: ... + def calc_loop_triangles(self) -> list[tuple[BMLoop, ...]]: ... # TODO: 正しい型 diff --git a/typings/bpy-stubs/__init__.pyi b/typings/bpy-stubs/__init__.pyi new file mode 100644 index 000000000..99f966980 --- /dev/null +++ b/typings/bpy-stubs/__init__.pyi @@ -0,0 +1,9 @@ +from . import app as app +from . import msgbus as msgbus +from . import ops as ops +from . import props as props +from . import types as types +from . import utils as utils + +context: types.Context +data: types.BlendData diff --git a/typings/bpy-stubs/app/__init__.pyi b/typings/bpy-stubs/app/__init__.pyi new file mode 100644 index 000000000..a67626b72 --- /dev/null +++ b/typings/bpy-stubs/app/__init__.pyi @@ -0,0 +1,27 @@ +from . import handlers as handlers +from . import timers as timers +from . import translations as translations + +debug: bool +debug_depsgraph: bool +debug_depsgraph_build: bool +debug_depsgraph_eval: bool +debug_depsgraph_pretty: bool +debug_depsgraph_tag: bool +debug_depsgraph_time: bool +debug_events: bool +debug_ffmpeg: bool +debug_freestyle: bool +debug_handlers: bool +debug_io: bool +debug_python: bool +debug_simdata: bool +debug_value: bool +debug_wm: bool +tempdir: str +use_event_simulate: bool +build_platform: bytes +build_type: bytes +version_cycle: str +version: tuple[int, int, int] +binary_path: str diff --git a/typings/bpy-stubs/app/handlers/__init__.pyi b/typings/bpy-stubs/app/handlers/__init__.pyi new file mode 100644 index 000000000..2be7ac145 --- /dev/null +++ b/typings/bpy-stubs/app/handlers/__init__.pyi @@ -0,0 +1,13 @@ +from collections.abc import MutableSequence +from typing import Callable + +def persistent(function: Callable[[object], None]) -> Callable[[object], None]: ... + +# TODO: 引数の型を調べる +depsgraph_update_pre: MutableSequence[Callable[[object], None]] +depsgraph_update_post: MutableSequence[Callable[[object], None]] + +save_pre: MutableSequence[Callable[[object], None]] +frame_change_pre: MutableSequence[Callable[[object], None]] +frame_change_post: MutableSequence[Callable[[object], None]] +load_post: MutableSequence[Callable[[object], None]] diff --git a/typings/bpy-stubs/app/timers/__init__.pyi b/typings/bpy-stubs/app/timers/__init__.pyi new file mode 100644 index 000000000..3c4f88ae9 --- /dev/null +++ b/typings/bpy-stubs/app/timers/__init__.pyi @@ -0,0 +1,8 @@ +from typing import Callable, Optional + +def register( + function: Callable[[], Optional[float]], + first_interval: float = 0, + persistent: bool = False, +) -> None: ... +def is_registered(function: Callable[[], Optional[float]]) -> bool: ... diff --git a/typings/bpy-stubs/app/translations/__init__.pyi b/typings/bpy-stubs/app/translations/__init__.pyi new file mode 100644 index 000000000..14c44b05f --- /dev/null +++ b/typings/bpy-stubs/app/translations/__init__.pyi @@ -0,0 +1,10 @@ +from typing import Optional + +locale: str + +def pgettext(msgid: str, msgctxt: Optional[str] = None) -> str: ... +def unregister(module_name: str) -> None: ... +def register( + module_name: str, + dictionary: dict[str, dict[tuple[str, str], str]], +) -> None: ... diff --git a/typings/bpy-stubs/context/__init__.pyi b/typings/bpy-stubs/context/__init__.pyi new file mode 100644 index 000000000..6c08139ce --- /dev/null +++ b/typings/bpy-stubs/context/__init__.pyi @@ -0,0 +1 @@ +from . import preferences as preferences diff --git a/typings/bpy-stubs/context/preferences/__init__.pyi b/typings/bpy-stubs/context/preferences/__init__.pyi new file mode 100644 index 000000000..1b5b69dfd --- /dev/null +++ b/typings/bpy-stubs/context/preferences/__init__.pyi @@ -0,0 +1 @@ +from . import view as view diff --git a/typings/bpy-stubs/context/preferences/view/__init__.pyi b/typings/bpy-stubs/context/preferences/view/__init__.pyi new file mode 100644 index 000000000..afdeb2edd --- /dev/null +++ b/typings/bpy-stubs/context/preferences/view/__init__.pyi @@ -0,0 +1 @@ +use_translate_interface: bool diff --git a/typings/bpy-stubs/msgbus/__init__.pyi b/typings/bpy-stubs/msgbus/__init__.pyi new file mode 100644 index 000000000..ae8825887 --- /dev/null +++ b/typings/bpy-stubs/msgbus/__init__.pyi @@ -0,0 +1,10 @@ +# TODO: 正しい型 +def subscribe_rna( + key: object, + owner: object, + args: object, + notify: object, + options: set[str] = ..., +) -> None: ... +def publish_rna(key: object) -> None: ... +def clear_by_owner(owner: object) -> None: ... diff --git a/typings/bpy-stubs/ops/__init__.pyi b/typings/bpy-stubs/ops/__init__.pyi new file mode 100644 index 000000000..1e7962c9b --- /dev/null +++ b/typings/bpy-stubs/ops/__init__.pyi @@ -0,0 +1,10 @@ +from . import export_scene as export_scene +from . import icyp as icyp +from . import import_scene as import_scene +from . import mesh as mesh +from . import object as object +from . import outliner as outliner +from . import preferences as preferences +from . import uv as uv +from . import vrm as vrm +from . import wm as wm diff --git a/typings/bpy-stubs/ops/export_scene/__init__.pyi b/typings/bpy-stubs/ops/export_scene/__init__.pyi new file mode 100644 index 000000000..c6c692146 --- /dev/null +++ b/typings/bpy-stubs/ops/export_scene/__init__.pyi @@ -0,0 +1,95 @@ +def vrm( + execution_context: str = "EXEC_DEFAULT", + /, + *, + filepath: str = "", + use_addon_preferences: bool = False, + ignore_warning: bool = True, + armature_object_name: str = "", +) -> set[str]: ... +def vrma( + execution_context: str = "EXEC_DEFAULT", + /, + *, + filepath: str = "", + armature_object_name: str = "", +) -> set[str]: ... +def gltf( + execution_context: str = "EXEC_DEFAULT", + /, + *, + filepath: str = "", + check_existing: bool = True, + export_import_convert_lighting_mode: str = "SPEC", + gltf_export_id: str = "", + export_format: str = "GLB", + ui_tab: str = "GENERAL", + export_copyright: str = "", + export_image_format: str = "AUTO", + export_image_add_webp: bool = False, + export_image_webp_fallback: bool = False, + export_texture_dir: str = "", + export_jpeg_quality: int = 75, + export_image_quality: int = 75, + export_keep_originals: int = False, + export_texcoords: bool = True, + export_normals: bool = True, + export_draco_mesh_compression_enable: bool = False, + export_draco_mesh_compression_level: int = 6, + export_draco_position_quantization: int = 14, + export_draco_normal_quantization: int = 10, + export_draco_texcoord_quantization: int = 12, + export_draco_color_quantization: int = 10, + export_draco_generic_quantization: int = 12, + export_tangents: bool = False, + export_materials: str = "EXPORT", + export_colors: bool = True, + export_attributes: bool = False, + use_mesh_edges: bool = False, + use_mesh_vertices: bool = False, + export_cameras: bool = False, + use_selection: bool = False, + use_visible: bool = False, + use_renderable: bool = False, + use_active_collection_with_nested: bool = True, + use_active_collection: bool = False, + use_active_scene: bool = False, + export_extras: bool = False, + export_yup: bool = True, + export_apply: bool = False, + export_animations: bool = True, + export_frame_range: bool = False, + export_frame_step: int = 1, + export_force_sampling: bool = True, + export_animation_mode: str = "ACTIONS", + export_nla_strips_merged_animation_name: str = "Animation", + export_def_bones: bool = False, + export_hierarchy_flatten_bones: bool = False, + export_optimize_animation_size: bool = True, + export_optimize_animation_keep_anim_armature: bool = True, + export_optimize_animation_keep_anim_object: bool = False, + export_negative_frame: str = "SLIDE", + export_anim_slide_to_zero: bool = False, + export_bake_animation: bool = False, + export_anim_single_armature: bool = True, + export_reset_pose_bones: bool = True, + export_current_frame: bool = False, + export_rest_position_armature: bool = True, + export_anim_scene_split_object: bool = True, + export_skins: bool = True, + export_influence_nb: int = 4, + export_all_influences: bool = False, + export_morph: bool = True, + export_morph_normal: bool = True, + export_morph_tangent: bool = False, + export_morph_animation: bool = True, + export_morph_reset_sk_data: bool = True, + export_lights: bool = False, + export_try_sparse_sk: bool = True, + export_try_omit_sparse_sk: bool = False, + export_gpu_instances: bool = False, + export_nla_strips: bool = True, + export_original_specular: bool = False, + will_save_settings: bool = False, + filter_glob: str = "*.glb", +) -> set[str]: ... diff --git a/typings/bpy-stubs/ops/icyp/__init__.pyi b/typings/bpy-stubs/ops/icyp/__init__.pyi new file mode 100644 index 000000000..34062edb8 --- /dev/null +++ b/typings/bpy-stubs/ops/icyp/__init__.pyi @@ -0,0 +1,7 @@ +def make_basic_armature( + execution_context: str = "EXEC_DEFAULT", + /, + *, + WIP_with_template_mesh: bool = False, # noqa: N803 + custom_property_name: str = "", +) -> set[str]: ... diff --git a/typings/bpy-stubs/ops/import_scene/__init__.pyi b/typings/bpy-stubs/ops/import_scene/__init__.pyi new file mode 100644 index 000000000..f84f41e81 --- /dev/null +++ b/typings/bpy-stubs/ops/import_scene/__init__.pyi @@ -0,0 +1,34 @@ +from typing import Optional + +from bpy.types import OperatorFileListElement, bpy_prop_collection + +def vrm( + execution_context: str = "EXEC_DEFAULT", + /, + *, + filepath: str = "", + use_addon_preferences: bool = False, + extract_textures_into_folder: bool = True, + make_new_texture_folder: bool = True, +) -> set[str]: ... +def gltf( + execution_context: str = "EXEC_DEFAULT", + /, + *, + filepath: str = "", + filter_glob: str = "*.glb;*.gltf", + files: Optional[bpy_prop_collection[OperatorFileListElement]] = None, + loglevel: int = 0, + import_pack_images: bool = True, + merge_vertices: bool = False, + import_shading: str = "NORMALS", + bone_heuristic: str = "TEMPERANCE", + guess_original_bind_pose: bool = True, +) -> set[str]: ... +def vrma( + execution_context: str = "EXEC_DEFAULT", + /, + *, + filepath: str = "", + armature_object_name: str = "", +) -> set[str]: ... diff --git a/typings/bpy-stubs/ops/mesh/__init__.pyi b/typings/bpy-stubs/ops/mesh/__init__.pyi new file mode 100644 index 000000000..5c12a1cc5 --- /dev/null +++ b/typings/bpy-stubs/ops/mesh/__init__.pyi @@ -0,0 +1,13 @@ +def select_all( + execution_context: str = "EXEC_DEFAULT", + /, + *, + action: str = "TOGGLE", +) -> set[str]: ... +def quads_convert_to_tris( + execution_context: str = "EXEC_DEFAULT", + /, + *, + quad_method: str = "BEAUTY", + ngon_method: str = "BEAUTY", +) -> set[str]: ... diff --git a/typings/bpy-stubs/ops/object/__init__.pyi b/typings/bpy-stubs/ops/object/__init__.pyi new file mode 100644 index 000000000..9e68f2b2e --- /dev/null +++ b/typings/bpy-stubs/ops/object/__init__.pyi @@ -0,0 +1,91 @@ +def delete( + execution_context: str = "EXEC_DEFAULT", + /, + *, + use_global: bool = False, + confirm: bool = True, +) -> set[str]: ... +def mode_set( + execution_context: str = "EXEC_DEFAULT", + /, + *, + mode: str = "OBJECT", + toggle: bool = False, +) -> set[str]: ... +def select_all( + execution_context: str = "EXEC_DEFAULT", + /, + *, + action: str = "TOGGLE", +) -> set[str]: ... +def shade_smooth( + execution_context: str = "EXEC_DEFAULT", + /, +) -> set[str]: ... +def modifier_add( + execution_context: str = "EXEC_DEFAULT", + /, + *, + type: str = "SUBSURF", +) -> set[str]: ... +def transform_apply( + execution_context: str = "EXEC_DEFAULT", + /, + *, + location: bool = True, + rotation: bool = True, + scale: bool = True, + properties: bool = True, +) -> set[str]: ... +def add( + execution_context: str = "EXEC_DEFAULT", + /, + *, + radius: float = 1.0, + type: str = "EMPTY", + enter_editmode: bool = False, + align: str = "WORLD", + location: tuple[float, float, float] = (0.0, 0.0, 0.0), + rotation: tuple[float, float, float] = (0.0, 0.0, 0.0), + scale: tuple[float, float, float] = (0.0, 0.0, 0.0), +) -> set[str]: ... +def convert( + execution_context: str = "EXEC_DEFAULT", + /, + *, + target: str = "MESH", + keep_original: bool = False, + angle: float = 1.22173, + thickness: int = 5, + seams: bool = False, + faces: bool = True, + offset: float = 0.01, +) -> set[str]: ... +def origin_set( + execution_context: str = "EXEC_DEFAULT", + /, + *, + type: str = "GEOMETRY_ORIGIN", + center: str = "MEDIAN", +) -> set[str]: ... +def shape_key_add( + execution_context: str = "EXEC_DEFAULT", + /, + *, + from_mix: bool = True, +) -> set[str]: ... +def parent_set( + execution_context: str = "EXEC_DEFAULT", + /, + *, + type: str = "OBJECT", + xmirror: bool = False, + keep_transform: bool = False, +) -> set[str]: ... +def vertex_group_limit_total( + execution_context: str = "EXEC_DEFAULT", + /, + *, + group_select_mode: str = "", + limit: int = 4, +) -> set[str]: ... diff --git a/typings/bpy-stubs/ops/outliner/__init__.pyi b/typings/bpy-stubs/ops/outliner/__init__.pyi new file mode 100644 index 000000000..c73bbe271 --- /dev/null +++ b/typings/bpy-stubs/ops/outliner/__init__.pyi @@ -0,0 +1,9 @@ +def orphans_purge( + execution_context: str = "EXEC_DEFAULT", + /, + *, + num_deleted: int = 0, + do_local_ids: bool = True, + do_linked_ids: bool = True, + do_recursive: bool = False, +) -> set[str]: ... diff --git a/typings/bpy-stubs/ops/preferences/__init__.pyi b/typings/bpy-stubs/ops/preferences/__init__.pyi new file mode 100644 index 000000000..11eee6cfd --- /dev/null +++ b/typings/bpy-stubs/ops/preferences/__init__.pyi @@ -0,0 +1,17 @@ +def addon_install( + execution_context: str = "EXEC_DEFAULT", + /, + *, + overwrite: bool = True, + target: str = "DEFAULT", + filepath: str = "", + filter_folder: bool = True, + filter_python: bool = True, + filter_glob: str = "*.py;*.zip", +) -> set[str]: ... +def addon_enable( + execution_context: str = "EXEC_DEFAULT", + /, + *, + module: str = "", +) -> set[str]: ... diff --git a/typings/bpy-stubs/ops/uv/__init__.pyi b/typings/bpy-stubs/ops/uv/__init__.pyi new file mode 100644 index 000000000..b95ce1d1f --- /dev/null +++ b/typings/bpy-stubs/ops/uv/__init__.pyi @@ -0,0 +1,11 @@ +def smart_project( + execution_context: str = "EXEC_DEFAULT", + /, + *, + angle_limit: float = 1.15192, + margin_method: str = "SCALED", + island_margin: float = 0.0, + area_weight: float = 0.0, + correct_aspect: bool = True, + scale_to_bounds: bool = False, +) -> bool: ... diff --git a/typings/bpy-stubs/ops/vrm/__init__.pyi b/typings/bpy-stubs/ops/vrm/__init__.pyi new file mode 100644 index 000000000..be2691383 --- /dev/null +++ b/typings/bpy-stubs/ops/vrm/__init__.pyi @@ -0,0 +1,105 @@ +def refresh_mtoon1_outline( + execution_context: str = "EXEC_DEFAULT", + /, + *, + material_name: str, + create_modifier: bool = False, +) -> set[str]: ... +def update_spring_bone1_animation( + execution_context: str = "EXEC_DEFAULT", + /, + *, + delta_time: float = 1, +) -> set[str]: ... +def add_spring_bone1_spring( + execution_context: str = "EXEC_DEFAULT", + /, + *, + armature_name: str, +) -> set[str]: ... +def add_spring_bone1_spring_joint( + execution_context: str = "EXEC_DEFAULT", + /, + *, + armature_name: str, + spring_index: int, +) -> set[str]: ... +def bones_rename( + execution_context: str = "EXEC_DEFAULT", + /, + *, + armature_name: str, +) -> set[str]: ... +def load_human_bone_mappings( + execution_context: str = "EXEC_DEFAULT", + /, + *, + filepath: str, +) -> set[str]: ... +def save_human_bone_mappings( + execution_context: str = "EXEC_DEFAULT", + /, + *, + filepath: str, +) -> set[str]: ... +def model_validate( + execution_context: str = "EXEC_DEFAULT", + /, + *, + show_successful_message: bool = False, + armature_object_name: str = "", +) -> set[str]: ... +def assign_vrm0_humanoid_human_bones_automatically( + execution_context: str = "EXEC_DEFAULT", + /, + *, + armature_name: str, +) -> set[str]: ... +def assign_vrm1_humanoid_human_bones_automatically( + execution_context: str = "EXEC_DEFAULT", + /, + *, + armature_name: str, +) -> set[str]: ... +def add_spring_bone1_collider( + execution_context: str = "EXEC_DEFAULT", + /, + *, + armature_name: str, +) -> set[str]: ... +def add_spring_bone1_collider_group( + execution_context: str = "EXEC_DEFAULT", + /, + *, + armature_name: str, +) -> set[str]: ... +def add_spring_bone1_collider_group_collider( + execution_context: str = "EXEC_DEFAULT", + /, + *, + armature_name: str, + collider_group_index: int, +) -> set[str]: ... +def add_spring_bone1_spring_collider_group( + execution_context: str = "EXEC_DEFAULT", + /, + *, + armature_name: str, + spring_index: int, +) -> set[str]: ... +def convert_mtoon1_to_bsdf_principled( + execution_context: str = "EXEC_DEFAULT", + /, + *, + material_name: str, +) -> set[str]: ... +def convert_material_to_mtoon1( + execution_context: str = "EXEC_DEFAULT", + /, + *, + material_name: str, +) -> set[str]: ... +def update_vrm1_expression_ui_list_elements( + execution_context: str = "EXEC_DEFAULT", + /, +) -> set[str]: ... diff --git a/typings/bpy-stubs/ops/wm/__init__.pyi b/typings/bpy-stubs/ops/wm/__init__.pyi new file mode 100644 index 000000000..a224b68e2 --- /dev/null +++ b/typings/bpy-stubs/ops/wm/__init__.pyi @@ -0,0 +1,136 @@ +from typing import Optional + +from bpy.types import OperatorFileListElement, bpy_prop_collection + +def save_as_mainfile( + execution_context: str = "EXEC_DEFAULT", + /, + *, + filepath: str, + copy: bool = False, + check_existing: bool = False, +) -> set[str]: ... +def quit_blender( + execution_context: str = "EXEC_DEFAULT", + /, +) -> None: ... +def open_mainfile( + execution_context: str = "EXEC_DEFAULT", + /, + *, + filepath: str = "", + hide_props_region: bool = True, + filter_blender: bool = True, + filter_backup: bool = False, + filter_image: bool = False, + filter_movie: bool = False, + filter_python: bool = False, + filter_font: bool = False, + filter_sound: bool = False, + filter_text: bool = False, + filter_archive: bool = False, + filter_btx: bool = False, + filter_collada: bool = False, + filter_alembic: bool = False, + filter_usd: bool = False, + filter_volume: bool = False, + filter_folder: bool = True, + filter_blenlib: bool = False, + filemode: int = 8, + display_type: str = "DEFAULT", + sort_method: str = "", + load_ui: bool = True, + use_scripts: bool = True, + display_file_selector: bool = True, + state: int = 0, +) -> set[str]: ... +def append( + execution_context: str = "EXEC_DEFAULT", + /, + *, + filepath: str = "", + directory: str = "", + filename: str = "", + files: Optional[bpy_prop_collection[OperatorFileListElement]] = None, + filter_blender: bool = True, + filter_backup: bool = False, + filter_image: bool = False, + filter_movie: bool = False, + filter_python: bool = False, + filter_font: bool = False, + filter_sound: bool = False, + filter_text: bool = False, + filter_archive: bool = False, + filter_btx: bool = False, + filter_collada: bool = False, + filter_alembic: bool = False, + filter_usd: bool = False, + filter_volume: bool = False, + filter_folder: bool = True, + filter_blenlib: bool = True, + filemode: int = 1, + display_type: str = "DEFAULT", + sort_method: str = "", + link: bool = False, + autoselect: bool = True, + active_collection: bool = True, + instance_collections: bool = False, + instance_object_data: bool = True, + set_fake: bool = False, + use_recursive: bool = True, +) -> set[str]: ... +def redraw_timer( + execution_context: str = "EXEC_DEFAULT", + /, + *, + type: str = "DRAW", + iterations: int = 10, + time_limit: float = 0.0, +) -> None: ... +def vrm_export_human_bones_assignment( + execution_context: str = "EXEC_DEFAULT", + /, + *, + armature_object_name: str, +) -> set[str]: ... +def vrm_export_confirmation( + execution_context: str = "EXEC_DEFAULT", + /, + *, + armature_object_name: str, +) -> set[str]: ... +def vrm_export_armature_selection( + execution_context: str, + /, +) -> set[str]: ... +def vrm_license_warning( + execution_context: str = "EXEC_DEFAULT", + /, + *, + import_anyway: bool, + license_confirmations: list[dict[str, str]], + filepath: str, + extract_textures_into_folder: bool, + make_new_texture_folder: bool, + set_shading_type_to_material_on_import: bool, + set_view_transform_to_standard_on_import: bool, + set_armature_display_to_wire: bool, + set_armature_display_to_show_in_front: bool, + set_armature_bone_shape_to_default: bool, +) -> set[str]: ... +def vrm_gltf2_addon_disabled_warning( + execution_context: str = "EXEC_DEFAULT", + /, +) -> set[str]: ... +def vrma_import_prerequisite( + execution_context: str = "EXEC_DEFAULT", + /, + *, + armature_object_name: str, +) -> set[str]: ... +def vrma_export_prerequisite( + execution_context: str = "EXEC_DEFAULT", + /, + *, + armature_object_name: str, +) -> set[str]: ... diff --git a/typings/bpy-stubs/props/__init__.pyi b/typings/bpy-stubs/props/__init__.pyi new file mode 100644 index 000000000..80c0eb023 --- /dev/null +++ b/typings/bpy-stubs/props/__init__.pyi @@ -0,0 +1,154 @@ +from collections.abc import Sequence +from typing import Callable, Optional, TypeVar, Union + +from bpy.types import Context, Operator, PropertyGroup +from mathutils import Vector + +__PointerPropertyTarget = TypeVar("__PointerPropertyTarget", bound=type) +__CollectionPropertyElement = TypeVar("__CollectionPropertyElement", bound=type) +__CallbackSelf = TypeVar("__CallbackSelf", bound=Union[PropertyGroup, Operator]) + +def BoolProperty( + *, + name: str = "", + description: str = "", + default: bool = False, + options: set[str] = ..., + override: set[str] = ..., + tags: set[str] = ..., # TODO: 型がわからない + subtype: str = "NONE", + update: Optional[Callable[[__CallbackSelf, Context], None]] = None, + get: Optional[Callable[[__CallbackSelf], bool]] = None, + set: Optional[Callable[[__CallbackSelf, bool], None]] = None, +) -> bool: ... +def CollectionProperty( + *, + type: __CollectionPropertyElement, + name: str = "", + description: str = "", + options: set[str] = ..., + override: set[str] = ..., + tags: set[str] = ..., +) -> __CollectionPropertyElement: ... +def EnumProperty( + *, + items: Union[ + Sequence[tuple[str, str, str, int]], + Sequence[tuple[str, str, str, str, int]], + ], + name: str = "", + description: str = "", + default: Optional[ + Union[str, int] + ] = None, # setも受け取れるらしいが仕様が読み取れなかった + options: set[str] = ..., + override: set[str] = ..., + tags: set[str] = ..., + update: Optional[Callable[[__CallbackSelf, Context], None]] = None, + get: Optional[Callable[[__CallbackSelf], int]] = None, + set: Optional[Callable[[__CallbackSelf, int], None]] = None, +) -> str: ... +def FloatProperty( + *, + name: str = "", + description: str = "", + default: float = 0.0, + min: float = ..., + max: float = ..., + soft_min: float = ..., + soft_max: float = ..., + step: int = 3, + precision: int = 2, + options: set[str] = ..., + override: set[str] = ..., + tags: set[str] = ..., + subtype: str = "NONE", + unit: str = "NONE", + update: Optional[Callable[[__CallbackSelf, Context], None]] = None, + get: Optional[Callable[[__CallbackSelf], float]] = None, + set: Optional[Callable[[__CallbackSelf, float], None]] = None, +) -> float: ... +def FloatVectorProperty( + *, + name: str = "", + description: str = "", + default: tuple[float, ...] = (0.0, 0.0, 0.0), + min: float = ..., + max: float = ..., + soft_min: float = ..., + soft_max: float = ..., + step: int = 3, + precision: int = 2, + options: set[str] = ..., + override: set[str] = ..., + tags: set[str] = ..., + subtype: str = "NONE", + unit: str = "NONE", + size: int = 3, + update: Optional[Callable[[__CallbackSelf, Context], None]] = None, + get: Optional[Callable[[__CallbackSelf], tuple[float, ...]]] = None, + set: Optional[Callable[[__CallbackSelf, Sequence[float]], None]] = None, +) -> Vector: ... # TODO: たしかVectorが返ったけど自信がない +def IntProperty( + *, + name: str = "", + description: str = "", + default: int = 0, + min: int = ..., + max: int = ..., + soft_min: int = ..., + soft_max: int = ..., + step: int = 1, + options: set[str] = ..., + override: set[str] = ..., + tags: set[str] = ..., + subtype: str = "NONE", + update: Optional[Callable[[__CallbackSelf, Context], None]] = None, + get: Optional[Callable[[__CallbackSelf], int]] = None, + set: Optional[Callable[[__CallbackSelf, int], None]] = None, +) -> int: ... +def IntVectorProperty( + *, + name: str = "", + description: str = "", + translation_context: str = "*", + default: tuple[int, ...] = (0, 0, 0), + min: int = ..., + max: int = ..., + soft_min: int = ..., + soft_max: int = ..., + step: int = 1, + options: set[str] = ..., + override: set[str] = ..., + tags: set[str] = ..., + subtype: str = "NONE", + size: int = ..., + update: Optional[Callable[[__CallbackSelf, Context], None]] = None, + get: Optional[Callable[[__CallbackSelf], tuple[int, ...]]] = None, + set: Optional[Callable[[__CallbackSelf, Sequence[int]], None]] = None, +) -> Vector: ... # TODO: たしかVectorが返ったけど自信がない +def PointerProperty( + *, + type: __PointerPropertyTarget, + name: str = "", + description: str = "", + options: set[str] = ..., + override: set[str] = ..., + tags: set[str] = ..., # TODO: 型がわからない + poll: Optional[Callable[[__CallbackSelf, object], bool]] = None, + update: Optional[Callable[[__CallbackSelf, Context], None]] = None, +) -> __PointerPropertyTarget: ... +def StringProperty( + *, + name: str = "", + description: str = "", + default: str = "", + maxlen: int = 0, + options: set[str] = ..., + override: set[str] = ..., + tags: set[str] = ..., # TODO: 型がわからない + subtype: str = "NONE", + update: Optional[Callable[[__CallbackSelf, Context], None]] = None, + get: Optional[Callable[[__CallbackSelf], str]] = None, + set: Optional[Callable[[__CallbackSelf, str], None]] = None, +) -> str: ... diff --git a/typings/bpy-stubs/types/__init__.pyi b/typings/bpy-stubs/types/__init__.pyi new file mode 100644 index 000000000..b7f9f75d4 --- /dev/null +++ b/typings/bpy-stubs/types/__init__.pyi @@ -0,0 +1,1940 @@ +import contextlib +from collections.abc import ( + ItemsView, + Iterable, + Iterator, + KeysView, + MutableSequence, + Sequence, + ValuesView, +) +from typing import Callable, Generic, Optional, TypeVar, Union, overload + +import typing_extensions +from mathutils import Euler, Matrix, Quaternion, Vector + +# pyright: reportMissingImports=false, reportUnknownVariableType=false +from io_scene_vrm.editor.extension import ( + VrmAddonArmatureExtensionPropertyGroup, + VrmAddonBoneExtensionPropertyGroup, + VrmAddonMaterialExtensionPropertyGroup, + VrmAddonNodeTreeExtensionPropertyGroup, + VrmAddonObjectExtensionPropertyGroup, + VrmAddonSceneExtensionPropertyGroup, +) + +class bpy_struct: + def as_pointer(self) -> int: ... + id_data: Optional[ID] + def path_from_id(self, property: str = "") -> str: ... + def keyframe_insert( + self, + data_path: str, + index: int = -1, + frame: float = ..., + group: str = "", + options: set[str] = ..., + ) -> bool: ... + + bl_rna: BlenderRNA # ドキュメントには存在しない。TODO: read only + +__BpyPropCollectionElement = TypeVar("__BpyPropCollectionElement") + +class bpy_prop_collection(Generic[__BpyPropCollectionElement]): + def get( + self, + key: str, + default: Optional[__BpyPropCollectionElement] = None, + ) -> Optional[__BpyPropCollectionElement]: ... + def __contains__(self, key: str) -> bool: ... + def __iter__(self) -> Iterator[__BpyPropCollectionElement]: ... + @overload + def __getitem__(self, key: Union[int, str]) -> __BpyPropCollectionElement: ... + @overload + def __getitem__(self, index: slice) -> tuple[__BpyPropCollectionElement, ...]: ... + def __len__(self) -> int: ... + def keys(self) -> KeysView[str]: ... + def values(self) -> ValuesView[__BpyPropCollectionElement]: ... + def items(self) -> ItemsView[str, __BpyPropCollectionElement]: ... + +# ドキュメントには存在しない +__BpyPropArrayElement = TypeVar("__BpyPropArrayElement") + +class bpy_prop_array(Generic[__BpyPropArrayElement]): + def __iter__(self) -> Iterator[__BpyPropArrayElement]: ... + @overload + def __getitem__(self, index: int) -> __BpyPropArrayElement: ... + @overload + def __getitem__(self, index: slice) -> tuple[__BpyPropArrayElement, ...]: ... + def __setitem__(self, index: int, value: __BpyPropArrayElement) -> None: ... + +# カスタムプロパティ対応クラス。2.93ではID,Bone,PoseBoneのみ +# https://docs.blender.org/api/2.93/bpy.types.bpy_struct.html#bpy.types.bpy_struct.values +class __CustomProperty: + def __getitem__(self, key: str) -> object: ... + def __setitem__(self, key: str, value: object) -> None: ... + def __delitem__(self, key: str) -> None: ... + def __contains__(self, key: str) -> bool: ... + def get(self, key: str, default: object = None) -> object: ... + def keys(self) -> KeysView[str]: ... + def items(self) -> ItemsView[str, object]: ... + def pop(self, key: str, default: object = None) -> object: ... + +class ID(bpy_struct, __CustomProperty): + name: str + is_evaluated: bool + users: int + use_fake_user: bool + + def animation_data_create(self) -> Optional[AnimData]: ... + +class Property(bpy_struct): + @property + def name(self) -> str: ... + @property + def identifier(self) -> str: ... + +class PointerProperty(Property): + @property + def fixed_type(self) -> type[bpy_struct]: ... # TODO: ここの正しい定義を調べる + +class FloatProperty(Property): + @property + def is_array(self) -> bool: ... + +class IntProperty(Property): + @property + def is_array(self) -> bool: ... + +class BoolProperty(Property): + @property + def is_array(self) -> bool: ... + +class EnumPropertyItem(bpy_struct): + @property + def identifier(self) -> str: ... + +class EnumProperty(Property): + @property + def enum_items(self) -> bpy_prop_collection[EnumPropertyItem]: ... + +class StringProperty(Property): ... + +class CollectionProperty(Property): + def fixed_type(self) -> type: ... # TODO: 正しい実装を調べる必要がある + def add(self) -> Property: ... # TODO: undocumented + def __len__(self) -> int: ... # TODO: undocumented + def __iter__(self) -> Iterator[Property]: ... # TODO: undocumented + def clear(self) -> None: ... # TODO: undocumented + @overload + def __getitem__(self, index: int) -> Property: ... # TODO: undocumented + @overload + def __getitem__( + self, + index: slice, + ) -> tuple[Property, ...]: ... # TODO: undocumented + def remove(self, index: int) -> None: ... # TODO: undocumented + def values(self) -> ValuesView[Property]: ... # TODO: undocumented + def move(self, from_index: int, to_index: int) -> None: ... # TODO: undocumented + +class PropertyGroup(bpy_struct): + name: str + + # TODO: 本当はbpy_structのメソッド + def get(self, key: str, default: object = None) -> object: ... + # TODO: 本当はbpy_structのメソッド + def __setitem__(self, key: str, value: object) -> None: ... + # TODO: 本当はbpy_structのメソッド + def __delitem__(self, key: str) -> None: ... + # TODO: 多分本当はbpy_structのメソッド + def __contains__(self, key: str) -> bool: ... + # TODO: 多分本当はbpy_structのメソッド + def pop(self, key: str, default: object = None) -> object: ... + +class BlenderRNA(bpy_struct): + @property + def properties( + self, + ) -> bpy_prop_collection[ + Property # TODO: これがbpy.types.Propertyと一致するかは要検証 + ]: ... # ドキュメントには存在しない。 + +class Gizmo(bpy_struct): + alpha: float + alpha_highlight: float + color: tuple[float, float, float] + color_highlight: tuple[float, float, float] + matrix_basis: Matrix # TODO: 型はMatrix? + scale_basis: float + + def target_set_prop( + self, + target: str, + data: AnyType, + property: str, + index: int = -1, + ) -> None: ... + + # GIZMO_GT_move_3d + draw_style: str + draw_options: set[str] + +class Gizmos(bpy_prop_collection[Gizmo]): + def new(self, type: str) -> Gizmo: ... + +class GizmoGroup(bpy_struct): + @property + def gizmos(self) -> Gizmos: ... + +class ColorManagedInputColorspaceSettings(bpy_struct): + name: str + +class Event(bpy_struct): + @property + def type(self) -> str: ... + @property + def value(self) -> str: ... + @property + def mouse_x(self) -> int: ... + @property + def mouse_y(self) -> int: ... + +class ImageUser(bpy_struct): ... + +class PackedFile(bpy_struct): + @property + def data(self) -> bytes: ... # ドキュメントにはstrと書いてあるが、実際にはbytes + @property + def size(self) -> int: ... + +class Image(ID): + colorspace_settings: ColorManagedInputColorspaceSettings + size: bpy_prop_array[float] + alpha_mode: str + generated_color: tuple[float, float, float, float] # Vectorかもしれない + depth: int + file_format: str + filepath: str + filepath_raw: str + generated_height: int + generated_width: int + is_dirty: bool + bindcode: int + source: str + @property + def packed_file(self) -> Optional[PackedFile]: ... # Optionalっぽい + def filepath_from_user(self, image_user: Optional[ImageUser] = None) -> str: ... + def update(self) -> None: ... + def gl_load(self, frame: int = 0) -> None: ... + def unpack(self, method: str = "USE_LOCAL") -> None: ... + def pack(self, data: str = "", data_len: int = 0) -> None: ... + def reload(self) -> None: ... + +class TimelineMarker(bpy_struct): + name: str + frame: int + +class ActionPoseMarkers(bpy_prop_collection[TimelineMarker]): ... + +class FCurve(bpy_struct): + mute: bool + is_valid: bool + data_path: str + array_index: int + + def evaluate(self, frame: int) -> float: ... + +class ActionFCurves(bpy_prop_collection[FCurve]): ... + +class Action(ID): + @property + def fcurves(self) -> ActionFCurves: ... + @property + def pose_markers(self) -> ActionPoseMarkers: ... + +class Texture(ID): ... + +class LayerObjects(bpy_prop_collection["Object"]): + active: Optional[Object] + +class Space(bpy_struct): + @property + def type(self) -> str: ... + +class View3DShading(bpy_struct): + type: str + +class SpaceView3D(Space): + @property + def shading(self) -> View3DShading: ... + @staticmethod # TODO: 本当にstaticなのか確認 + def draw_handler_add( + callback: Callable[[], None], + args: tuple[object, ...], + region_type: str, + draw_type: str, + ) -> object: ... + @staticmethod # TODO: 本当にstaticなのか確認 + def draw_handler_remove( + handler: object, + region_type: str, + ) -> None: ... + +class Depsgraph(bpy_struct): + def update(self) -> None: ... + +class ViewLayer(bpy_struct): + @property + def objects(self) -> LayerObjects: ... + @property + def depsgraph(self) -> Depsgraph: ... + def update(self) -> None: ... + +class Bone(bpy_struct, __CustomProperty): + name: str + parent: Optional[Bone] + use_inherit_rotation: bool + select: bool + tail_radius: float + + @property + def head(self) -> Vector: ... # TODO: 型が正しいか? + @head.setter + def head(self, value: Sequence[float]) -> None: ... # TODO: 型が正しいか? + @property + def tail(self) -> Vector: ... # TODO: 型が正しいか? + @tail.setter + def tail(self, value: Sequence[float]) -> None: ... # TODO: 型が正しいか? + + head_local: Vector # TODO: 型が正しいか? + head_radius: float + + # ドキュメントには3要素のfloat配列と書いてあるが、実際にはVector + tail_local: Vector + + # ドキュメントには二次元のfloat配列と書いてあるが、実際にはMatrix + matrix_local: Matrix + + @property + def length(self) -> float: ... + @property + def children(self) -> bpy_prop_collection[Bone]: ... + def translate(self, vec: Vector) -> None: ... + @property + def vrm_addon_extension(self) -> VrmAddonBoneExtensionPropertyGroup: ... + def convert_local_to_pose( + self, + matrix: Iterable[Iterable[float]], + matrix_local: Iterable[Iterable[float]], + parent_matrix: Iterable[Iterable[float]] = ..., + parent_matrix_local: Iterable[Iterable[float]] = ..., + invert: bool = False, + ) -> Matrix: ... + +class EditBone(bpy_struct): + name: str + @property + def head( + self, + ) -> Vector: ... # ドキュメントには3要素のfloat配列と書いてあるが、実際にはVector + @head.setter + def head(self, value: Iterable[float]) -> None: ... + @property + def tail( + self, + ) -> Vector: ... # ドキュメントには3要素のfloat配列と書いてあるが、実際にはVector + @tail.setter + def tail(self, value: Iterable[float]) -> None: ... + + parent: Optional[EditBone] + length: float + roll: float + use_local_location: bool + use_connect: bool + head_radius: float + tail_radius: float + envelope_distance: float + matrix: Matrix + + @property + def children(self) -> Sequence[EditBone]: ... + def transform( + self, + matrix: Matrix, + *, + scale: bool = True, + roll: bool = True, + ) -> None: ... + +class PoseBoneConstraints(bpy_prop_collection["Constraint"]): + def new(self, type: str) -> Constraint: ... + +class PoseBone(bpy_struct, __CustomProperty): + name: str + bbone_curveinx: float + bbone_curveinz: float + bbone_curveoutx: float + bbone_curveoutz: float + custom_shape: Optional[Object] + + @property + def parent(self) -> Optional[PoseBone]: ... + @property + def constraints(self) -> PoseBoneConstraints: ... + @property + def head( + self, + ) -> Vector: ... # ドキュメントには3要素のfloat配列と書いてあるが、実際にはVector + rotation_mode: str + rotation_quaternion: Quaternion + @property + def bone(self) -> Bone: ... + matrix: Matrix # これもドキュメントと異なりMatrix + matrix_basis: Matrix # これもドキュメントと異なりMatrix + @property + def children(self) -> Sequence[PoseBone]: ... + @property + def location(self) -> Vector: ... # TODO: 本当にVectorなのか確認 + @location.setter + def location(self, value: Iterable[float]) -> None: ... + @property + def scale(self) -> Vector: ... # TODO: 本当にVectorなのか確認 + @scale.setter + def scale(self, value: Iterable[float]) -> None: ... + +class ArmatureBones(bpy_prop_collection[Bone]): + active: Optional[Bone] # TODO: Noneになるか? + +class OperatorProperties(bpy_struct): ... + +class UILayout(bpy_struct): + def box(self) -> UILayout: ... + def column( + self, + /, + *, + align: bool = False, + heading: str = "", + heading_ctxt: str = "", + translate: bool = True, + ) -> UILayout: ... + def row( + self, + /, + *, + align: bool = False, + heading: str = "", + heading_ctxt: str = "", + translate: bool = True, + ) -> UILayout: ... + def prop( + self, + data: bpy_struct, # TODO: AnyType + property: str, + /, + *, + text: str = "", + text_ctxt: str = "", + translate: bool = True, + icon: str = "NONE", + expand: bool = False, + slider: bool = False, + toggle: int = -1, + icon_only: bool = False, + event: bool = False, + full_event: bool = False, + emboss: bool = True, + index: int = -1, + icon_value: int = 0, + invert_checkbox: bool = False, + ) -> UILayout: ... + def label( + self, + /, + *, + text: str = "", + text_ctxt: str = "", + translate: bool = True, + icon: str = "NONE", + icon_value: int = 0, + ) -> UILayout: ... + def split( + self, + /, + *, + factor: float = 0.0, + align: bool = False, + ) -> UILayout: ... + def operator( + self, + operator: str, + /, + *, + text: str = "", + text_ctxt: str = "", + translate: bool = True, + icon: str = "NONE", + emboss: bool = True, + depress: bool = False, + icon_value: int = 0, + ) -> OperatorProperties: ... + def separator( + self, + /, + *, + factor: float = 1.0, + ) -> None: ... + def prop_search( + self, + data: AnyType, + property: str, + search_data: AnyType, + search_property: str, + /, + *, + text: str = "", + text_ctxt: str = "", + translate: bool = True, + icon: str = "NONE", + results_are_suggestions: bool = False, + ) -> UILayout: ... + def template_ID_preview( + self, + data: AnyType, + property: str, + new: str = "", + open: str = "", + unlink: str = "", + rows: int = 0, + cols: int = 0, + filter: str = "ALL", + hide_buttons: bool = False, + ) -> None: ... + def template_list( + self, + listtype_name: str, + list_id: str, + dataptr: AnyType, + propname: str, + active_dataptr: AnyType, + active_propname: str, + item_dyntip_propname: str = "", + rows: int = 5, + maxrows: int = 5, + type: str = "DEFAULT", + columns: int = 9, + sort_reverse: bool = False, + sort_lock: bool = False, + ) -> None: ... + + alignment: str + scale_x: float + emboss: str + enabled: bool + alert: bool + +class AddonPreferences(bpy_struct): + layout: UILayout # TODO: No documentation + +class Addon(bpy_struct): + @property + def preferences(self) -> AddonPreferences: ... + +class Addons(bpy_prop_collection[Addon]): ... + +class MeshUVLoop(bpy_struct): + uv: Vector # TODO: 正しい方を調べる + +class MeshUVLoopLayer(bpy_struct): + name: str + data: bpy_prop_collection[MeshUVLoop] + active_render: bool + +class UVLoopLayers(bpy_prop_collection[MeshUVLoopLayer]): + def new(self, name: str = "UVMap", do_init: bool = True) -> MeshUVLoopLayer: ... + +class MeshLoopTriangle(bpy_struct): + vertices: tuple[int, int, int] + material_index: int + split_normals: tuple[ + tuple[float, float, float], + tuple[float, float, float], + tuple[float, float, float], + ] # TODO: 正しい型を調べる + loops: tuple[int, int, int] # TODO: 正しい型を調べる + +class MeshLoop(bpy_struct): + tangent: Vector # TODO: 正しい型を調べる + vertex_index: int + normal: Vector + +class MeshLoops(bpy_prop_collection[MeshLoop]): ... +class MeshLoopTriangles(bpy_prop_collection[MeshLoopTriangle]): ... + +class VertexGroupElement(bpy_struct): + weight: float + @property + def group(self) -> int: ... + +class MeshVertex(bpy_struct): + co: tuple[float, float, float] # Vectorかも? + normal: Vector # TODO: 正しい型を調べる + @property + def groups(self) -> bpy_prop_collection[VertexGroupElement]: ... + @property + def index(self) -> int: ... + +class MeshVertices(bpy_prop_collection[MeshVertex]): ... +class UnknownType(bpy_struct): ... + +class ShapeKey(bpy_struct): + name: str + value: float + @property + def data(self) -> bpy_prop_collection[UnknownType]: ... # TODO: 多分書き漏れ + def normals_split_get(self) -> Sequence[float]: ... # TODO: 正しい型 + +class Key(ID): + @property + def key_blocks(self) -> bpy_prop_collection[ShapeKey]: ... + @property + def reference_key(self) -> ShapeKey: ... + +class MeshPolygon(bpy_struct): + material_index: int + use_smooth: bool + vertices: tuple[int, int, int] # TODO: 正しい型を調べる + @property + def loop_total(self) -> int: ... + +class MeshPolygons(bpy_prop_collection[MeshPolygon]): ... + +class MeshLoopColor(bpy_struct): + color: Sequence[float] # TODO: 正しい型を調べる + +class MeshLoopColorLayer(bpy_struct): + @property + def data(self) -> bpy_prop_collection[MeshLoopColor]: ... + +class LoopColors(bpy_prop_collection[MeshLoopColorLayer]): + def new(self, name: str = "Col", do_init: bool = True) -> MeshLoopColorLayer: ... + +class Mesh(ID): + use_auto_smooth: bool + + @property + def materials(self) -> IDMaterials: ... + @property + def uv_layers(self) -> UVLoopLayers: ... + @property + def loops(self) -> MeshLoops: ... + @property + def loop_triangles(self) -> MeshLoopTriangles: ... + @property + def vertices(self) -> MeshVertices: ... + @property + def shape_keys(self) -> Optional[Key]: ... # Optional + @property + def polygons(self) -> MeshPolygons: ... + @property + def vertex_colors(self) -> LoopColors: ... + + has_custom_normals: bool + def calc_tangents(self, uvmap: str = "") -> None: ... + def calc_loop_triangles(self) -> None: ... + def copy(self) -> Mesh: ... # ID.copy() + def transform(self, matrix: Matrix, shape_keys: bool = False) -> None: ... + def calc_normals_split(self) -> None: ... + def update( + self, + calc_edges: bool = False, + calc_edges_loose: bool = False, + ) -> None: ... + def from_pydata( + self, + vertices: Iterable[Iterable[float]], + edges: Iterable[Iterable[float]], + faces: Iterable[Iterable[float]], + ) -> None: ... + def create_normals_split(self) -> None: ... + def normals_split_custom_set_from_vertices( + self, + normals: Iterable[Iterable[float]], + ) -> None: ... + def validate( + self, + verbose: bool = False, + clean_customdata: bool = True, + ) -> bool: ... + +class ArmatureEditBones(bpy_prop_collection[EditBone]): + def new(self, name: str) -> EditBone: ... + def remove(self, bone: EditBone) -> None: ... + +class AnimData(bpy_struct): + action: Optional[Action] # TODO: 本当にOptionalか確認 + +class Armature(ID): + pose_position: str + + @property + def animation_data(self) -> Optional[AnimData]: ... # TODO: 本当にOptionalか確認 + @property + def bones(self) -> ArmatureBones: ... + @property + def edit_bones(self) -> ArmatureEditBones: ... + @property + def vrm_addon_extension(self) -> VrmAddonArmatureExtensionPropertyGroup: ... + +class TextLine(bpy_struct): + body: str + +class Text(ID): + @property + def lines(self) -> bpy_prop_collection[TextLine]: ... + def write(self, text: str) -> None: ... + +class NodeSocketInterface(bpy_struct): + bl_socket_idname: str + description: str + hide_value: bool + @property + def identifier(self) -> str: ... + @property + def is_output(self) -> bool: ... + name: str + + # bpy.app.version >= (3, 0, 0) + attribute_domain: str + bl_label: str + +class NodeSocketInterfaceStandard(NodeSocketInterface): + @property + def type(self) -> str: ... + +class NodeSocketInterfaceFloat(NodeSocketInterfaceStandard): + default_value: float + max_value: float + min_value: float + +class NodeSocketInterfaceFloatAngle(NodeSocketInterfaceStandard): + default_value: float + max_value: float + min_value: float + +class NodeSocketInterfaceFloatDistance(NodeSocketInterfaceStandard): + default_value: float + max_value: float + min_value: float + +class NodeSocketInterfaceFloatFactor(NodeSocketInterfaceStandard): + default_value: float + max_value: float + min_value: float + +class NodeSocketInterfaceFloatPercentage(NodeSocketInterfaceStandard): + default_value: float + max_value: float + min_value: float + +class NodeSocketInterfaceFloatTime(NodeSocketInterfaceStandard): + default_value: float + max_value: float + min_value: float + +class NodeSocketInterfaceFloatUnsigned(NodeSocketInterfaceStandard): + default_value: float + max_value: float + min_value: float + +class NodeSocketInterfaceColor(NodeSocketInterfaceStandard): + default_value: tuple[float, float, float, float] # TODO: これはカラー? + +class NodeSocketInterfaceVector(NodeSocketInterfaceStandard): + default_value: tuple[float, float, float] + max_value: float + min_value: float + +class NodeSocketInterfaceVectorAcceleration(NodeSocketInterfaceStandard): + default_value: tuple[float, float, float] + max_value: float + min_value: float + +class NodeSocketInterfaceVectorDirection(NodeSocketInterfaceStandard): + default_value: tuple[float, float, float] + max_value: float + min_value: float + +class NodeSocketInterfaceVectorEuler(NodeSocketInterfaceStandard): + default_value: tuple[float, float, float] + max_value: float + min_value: float + +class NodeSocketInterfaceVectorTranslation(NodeSocketInterfaceStandard): + default_value: tuple[float, float, float] + max_value: float + min_value: float + +class NodeSocketInterfaceVectorVelocity(NodeSocketInterfaceStandard): + default_value: tuple[float, float, float] + max_value: float + min_value: float + +class NodeSocketInterfaceVectorXYZ(NodeSocketInterfaceStandard): + default_value: tuple[float, float, float] + max_value: float + min_value: float + +class NodeSocket(bpy_struct): + display_shape: str + enabled: bool + hide: bool + hide_value: bool + link_limit: int + name: str + show_expanded: bool + type: str + @property + def links(self) -> list[NodeLink]: ... + @property + def node(self) -> Node: ... + +class NodeSocketStandard(NodeSocket): ... + +class NodeSocketBool(NodeSocketStandard): + default_value: bool + +class NodeSocketFloat(NodeSocketStandard): + default_value: float + +class NodeSocketFloatAngle(NodeSocketStandard): + default_value: float + +class NodeSocketFloatDistance(NodeSocketStandard): + default_value: float + +class NodeSocketFloatFactor(NodeSocketStandard): + default_value: float + +class NodeSocketFloatPercentage(NodeSocketStandard): + default_value: float + +class NodeSocketFloatTime(NodeSocketStandard): + default_value: float + +class NodeSocketFloatUnsigned(NodeSocketStandard): + default_value: float + +class NodeSocketInt(NodeSocketStandard): + default_value: int + +class NodeSocketIntFactor(NodeSocketStandard): + default_value: int + +class NodeSocketIntPercentage(NodeSocketStandard): + default_value: int + +class NodeSocketIntUnsigned(NodeSocketStandard): + default_value: int + +class NodeSocketString(NodeSocketStandard): + default_value: str + +class NodeSocketVector(NodeSocketStandard): + default_value: tuple[float, float, float] # TODO: Vector? + +class NodeSocketVectorAcceleration(NodeSocketStandard): + default_value: tuple[float, float, float] # TODO: Vector? + +class NodeSocketVectorDirection(NodeSocketStandard): + default_value: tuple[float, float, float] # TODO: Vector? + +class NodeSocketVectorEuler(NodeSocketStandard): + default_value: tuple[float, float, float] # TODO: Vector? + +class NodeSocketVectorTranslation(NodeSocketStandard): + default_value: tuple[float, float, float] # TODO: Vector? + +class NodeSocketVectorVelocity(NodeSocketStandard): + default_value: tuple[float, float, float] # TODO: Vector? + +class NodeSocketVectorXYZ(NodeSocketStandard): + default_value: tuple[float, float, float] # TODO: Vector? + +class NodeSocketColor(NodeSocketStandard): + default_value: tuple[float, float, float, float] # TODO: Color? + +class NodeOutputs(bpy_prop_collection[NodeSocket]): ... +class NodeInputs(bpy_prop_collection[NodeSocket]): ... + +class Node(bpy_struct): + bl_idname: str + outputs: NodeOutputs + inputs: NodeInputs + color: tuple[float, float, float] # TODO: Color? + height: float + hide: bool + label: str + location: tuple[float, float] + mute: bool + name: str + parent: Optional[Node] + select: bool + show_options: bool + show_preview: bool + show_texture: bool + use_custom_color: bool + width: float + type: str + + # bpy.app.version < (4, 0): + width_hidden: bool + +class NodeInternal(Node): ... +class NodeReroute(NodeInternal): ... + +class NodeFrame(NodeInternal): + shrink: bool + label_size: int + text: Text + +class NodeGroup(NodeInternal): ... + +class NodeGroupOutput(NodeInternal): + is_active_output: bool + +class ColorRamp(bpy_struct): + color_mode: str + elements: object # TODO: object + +class ColorMapping(bpy_struct): + blend_color: tuple[float, float, float] # TODO: Color? + blend_factor: float + blend_type: str + brightness: float + color_ramp: ColorRamp + contrast: float + saturation: float + use_color_ramp: bool + +class TexMapping(bpy_struct): + @property + def translation(self) -> Vector: ... + @translation.setter + def translation(self, value: Iterable[float]) -> None: ... + @property + def scale(self) -> Vector: ... + @scale.setter + def scale(self, value: Iterable[float]) -> None: ... + + mapping: str + mapping_x: str + mapping_y: str + mapping_z: str + +class ShaderNode(NodeInternal): ... # x +class ShaderNodeAddShader(ShaderNode): ... # x + +class ShaderNodeAmbientOcclusion(ShaderNode): + inside: bool + only_local: bool + samples: int + +class ShaderNodeAttribute(ShaderNode): + attribute_name: str + attribute_type: str + +class ShaderNodeBackground(ShaderNode): ... + +class ShaderNodeBevel(ShaderNode): + samples: int + +class ShaderNodeBlackbody(ShaderNode): ... +class ShaderNodeBrightContrast(ShaderNode): ... + +class ShaderNodeBsdfAnisotropic(ShaderNode): + distribution: str + +class ShaderNodeBsdfDiffuse(ShaderNode): ... + +class ShaderNodeBsdfGlass(ShaderNode): + distribution: str + +class ShaderNodeBsdfGlossy(ShaderNode): # bpy.app.version < (4, 0): + distribution: str + +class ShaderNodeBsdfHair(ShaderNode): + component: str + +class ShaderNodeBsdfHairPrincipled(ShaderNode): + parametrization: str + +class ShaderNodeBsdfPrincipled(ShaderNode): + distribution: str + subsurface_method: str + +class ShaderNodeBsdfRefraction(ShaderNode): + distribution: str + +class ShaderNodeBsdfToon(ShaderNode): + component: str + +class ShaderNodeBsdfTranslucent(ShaderNode): ... +class ShaderNodeBsdfTransparent(ShaderNode): ... +class ShaderNodeBsdfVelvet(ShaderNode): ... + +class ShaderNodeBump(ShaderNode): + invert: bool + +class ShaderNodeCameraData(ShaderNode): ... + +class ShaderNodeClamp(ShaderNode): + clamp_type: str + +class ShaderNodeCombineColor(ShaderNode): # bpy.app.version >= (3, 3): + mode: str + +class ShaderNodeCombineHSV(ShaderNode): ... +class ShaderNodeCombineRGB(ShaderNode): ... +class ShaderNodeCombineXYZ(ShaderNode): ... +class ShaderNodeCustomGroup(ShaderNode): ... + +class ShaderNodeDisplacement(ShaderNode): + space: str + +class ShaderNodeEeveeSpecular(ShaderNode): ... +class ShaderNodeEmission(ShaderNode): ... +class ShaderNodeFresnel(ShaderNode): ... +class ShaderNodeGamma(ShaderNode): ... + +class ShaderNodeGroup(ShaderNode): + # https://github.com/KhronosGroup/glTF-Blender-IO/issues/1797 + node_tree: Optional[NodeTree] + +class ShaderNodeHairInfo(ShaderNode): ... +class ShaderNodeHoldout(ShaderNode): ... +class ShaderNodeHueSaturation(ShaderNode): ... +class ShaderNodeInvert(ShaderNode): ... +class ShaderNodeLayerWeight(ShaderNode): ... +class ShaderNodeLightFalloff(ShaderNode): ... +class ShaderNodeLightPath(ShaderNode): ... + +class ShaderNodeMapRange(ShaderNode): + clamp: bool + interpolation_type: str + +class ShaderNodeMapping(ShaderNode): + vector_type: str + +class ShaderNodeMath(ShaderNode): + operation: str + use_clamp: bool + +class ShaderNodeMix(ShaderNode): # bpy.app.version >= (3, 4): + blend_type: str + clamp_factor: bool + clamp_result: bool + data_type: str + factor_mode: str + +class ShaderNodeMixRGB(ShaderNode): + blend_type: str + use_alpha: bool + use_clamp: bool + +class ShaderNodeMixShader(ShaderNode): ... +class ShaderNodeNewGeometry(ShaderNode): ... +class ShaderNodeNormal(ShaderNode): ... + +class ShaderNodeNormalMap(ShaderNode): + space: str + uv_map: str + +class ShaderNodeObjectInfo(ShaderNode): ... + +class ShaderNodeOutputAOV(ShaderNode): + name: str + +class ShaderNodeOutputLight(ShaderNode): + is_active_output: str + target: str + +class ShaderNodeOutputLineStyle(ShaderNode): + blend_type: str + is_active_output: bool + target: str + use_alpha: bool + use_clamp: bool + +class ShaderNodeOutputMaterial(ShaderNode): + is_active_output: bool + target: str + +class ShaderNodeOutputWorld(ShaderNode): + is_active_output: bool + target: str + +class ShaderNodeParticleInfo(ShaderNode): ... +class ShaderNodeRGB(ShaderNode): ... +class ShaderNodeRGBCurve(ShaderNode): ... +class ShaderNodeRGBToBW(ShaderNode): ... + +class ShaderNodeScript(ShaderNode): + bytecode: str + bytecode_hash: str + filepath: str + mode: str + script: Text + use_auto_update: bool + +class ShaderNodeSeparateColor(ShaderNode): # bpy.app.version >= (3, 3): + mode: str + +class ShaderNodeSeparateHSV(ShaderNode): ... +class ShaderNodeSeparateRGB(ShaderNode): ... +class ShaderNodeSeparateXYZ(ShaderNode): ... +class ShaderNodeShaderToRGB(ShaderNode): ... +class ShaderNodeSqueeze(ShaderNode): ... + +class ShaderNodeSubsurfaceScattering(ShaderNode): + falloff: str + +class ShaderNodeTangent(ShaderNode): + axis: str + direction_type: str + uv_map: str + +class ShaderNodeTexBrick(ShaderNode): + offset: float + offset_frequency: int + squash: float + squash_frequency: int + +class ShaderNodeTexChecker(ShaderNode): ... + +class ShaderNodeTexCoord(ShaderNode): + from_instancer: bool + object: Optional[Object] + +class ShaderNodeTexEnvironment(ShaderNode): + image: Optional[Image] + interpolation: str + projection: str + +class ShaderNodeTexGradient(ShaderNode): + gradient_type: str + +class ShaderNodeTexIES(ShaderNode): + filepath: str + ies: Text + mode: str + +class ShaderNodeTexImage(ShaderNode): + extension: str + image: Optional[Image] + interpolation: str + projection: str + projection_blend: float + @property + def texture_mapping(self) -> TexMapping: ... + +class ShaderNodeTexMagic(ShaderNode): + turbulence_depth: int + +class ShaderNodeTexMusgrave(ShaderNode): + musgrave_dimensions: str + musgrave_type: str + +class ShaderNodeTexNoise(ShaderNode): + noise_dimensions: str + +class ShaderNodeTexPointDensity(ShaderNode): + interpolation: str + object: Optional[Object] + particle_color_source: str + point_source: str + radius: float + resolution: int + space: str + vertex_attribute_name: str + vertex_color_source: str + +class ShaderNodeTexSky(ShaderNode): + air_density: float + altitude: float + color_mapping: ColorMapping + dust_density: float + ground_albedo: float + ozone_density: float + sky_type: str + sun_direction: tuple[float, float, float] # TODO: Vector? + turbidity: float + +class ShaderNodeTexVoronoi(ShaderNode): + color_mapping: ColorMapping + distance: str + feature: str + texture_mapping: object # TODO: 型をつける + voronoi_dimensions: str + +class ShaderNodeTexWave(ShaderNode): + bands_direction: str + color_mapping: ColorMapping + rings_direction: str + texture_mapping: object # TODO: 型をつける + wave_profile: str + wave_type: str + +class ShaderNodeTexWhiteNoise(ShaderNode): + noise_dimensions: str + +class ShaderNodeTree(NodeTree): ... + +class ShaderNodeUVAlongStroke(ShaderNode): + use_tips: bool + +class ShaderNodeUVMap(ShaderNode): + from_instancer: bool + uv_map: str + +class ShaderNodeValToRGB(ShaderNode): ... +class ShaderNodeValue(ShaderNode): ... +class ShaderNodeVectorCurve(ShaderNode): ... + +class ShaderNodeVectorDisplacement(ShaderNode): + space: str + +class ShaderNodeVectorMath(ShaderNode): + operation: str + +class ShaderNodeVectorRotate(ShaderNode): + invert: bool + rotation_type: str + +class ShaderNodeVectorTransform(ShaderNode): + convert_from: str + convert_to: str + vector_type: str + +class ShaderNodeVertexColor(ShaderNode): + layer_name: str + +class ShaderNodeVolumeAbsorption(ShaderNode): ... +class ShaderNodeVolumeInfo(ShaderNode): ... +class ShaderNodeVolumePrincipled(ShaderNode): ... +class ShaderNodeVolumeScatter(ShaderNode): ... +class ShaderNodeWavelength(ShaderNode): ... + +class ShaderNodeWireframe(ShaderNode): + use_pixel_size: bool + +class GeometryNode(NodeInternal): ... + +class GeometryNodeExtrudeMesh(GeometryNode): + mode: str + +class GeometryNodeDeleteGeometry(GeometryNode): + domain: str + mode: str + +class GeometryNodeSeparateGeometry(GeometryNode): + domain: str + +# bpy.app.version >= (3, 3): +class GeometryNodeSwitch(GeometryNode): + input_type: str + +class Pose(bpy_struct): + bones: bpy_prop_collection[PoseBone] + @classmethod + def apply_pose_from_action( + cls, + action: Action, + evaluation_time: float = 0.0, + ) -> None: ... + +class MaterialSlot(bpy_struct): + @property + def name(self) -> str: ... + material: Optional[ + Material + ] # マテリアル一覧の+を押したまま何も選ばないとNoneになる + +class ObjectModifiers(bpy_prop_collection["Modifier"]): + def new(self, name: str, type: str) -> Modifier: ... + def remove(self, modifier: Modifier) -> None: ... + def clear(self) -> None: ... + +class VertexGroup(bpy_struct): + name: str + def add(self, index: Sequence[int], weight: float, type: str) -> None: ... + +class VertexGroups(bpy_prop_collection[VertexGroup]): + def new(self, name: str = "Group") -> VertexGroup: ... + def clear(self) -> None: ... + +class Object(ID): + name: str + type: str + data: Optional[ID] # ドキュメントにはIDと書いてあるがtypeがemptyの場合はNoneになる + @property + def mode(self) -> str: ... + @property + def pose(self) -> Pose: ... + def select_set( + self, + state: bool, + view_layer: Optional[ViewLayer] = None, + ) -> None: ... + + hide_render: bool + hide_select: bool + hide_viewport: bool + @property + def material_slots(self) -> bpy_prop_collection[MaterialSlot]: ... + @property + def users_collection(self) -> bpy_prop_collection[Collection]: ... + parent: Optional[Object] + def visible_get( + self, + view_layer: Optional[ViewLayer] = None, + viewport: Optional[SpaceView3D] = None, + ) -> bool: ... + @property + def constraints(self) -> ObjectConstraints: ... + parent_type: str + parent_bone: str + empty_display_size: float + empty_display_type: str + display_type: str + show_in_front: bool + + rotation_mode: str + rotation_quaternion: Quaternion # TODO: 型あってる? + rotation_euler: Euler + + @property + def bound_box(self) -> bpy_prop_array[bpy_prop_array[float]]: ... + + # ドキュメントには4x4の2次元配列って書いてあるけど実際にはMatrix + matrix_basis: Matrix + # ドキュメントには4x4の2次元配列って書いてあるけど実際にはMatrix + matrix_world: Matrix + # ドキュメントには4x4の2次元配列って書いてあるけど実際にはMatrix + matrix_local: Matrix + # ドキュメントには3要素のfloat配列って書いてあるけど実際にはVector + scale: Vector + + @property + def vertex_groups(self) -> VertexGroups: ... + @property + def location( + self, + ) -> ( + # ドキュメントには3要素のfloat配列と書いてあるが、実際にはVector + Vector + ): ... + @location.setter + def location(self, value: Iterable[float]) -> None: ... + def evaluated_get(self, depsgraph: Depsgraph) -> Object: ... # 本当はIDのメソッド + def to_mesh( + self, + preserve_all_data_layers: bool = False, + depsgraph: Optional[Depsgraph] = None, + ) -> Mesh: ... + @property + def modifiers(self) -> ObjectModifiers: ... + @property + def animation_data(self) -> Optional[AnimData]: ... # TODO: 本当にOptionalか確認 + @property + def vrm_addon_extension(self) -> VrmAddonObjectExtensionPropertyGroup: ... + def shape_key_add(self, name: str = "Key", from_mix: bool = True) -> ShapeKey: ... + def select_get(self, view_layer: Optional[ViewLayer] = None) -> bool: ... + def hide_get(self, view_layer: Optional[ViewLayer] = None) -> bool: ... + def hide_set(self, state: bool, view_layer: Optional[ViewLayer] = None) -> bool: ... + @property + def children(self) -> Sequence[Object]: ... # ドキュメントでは型が不明瞭 + +class PreferencesView: + use_translate_interface: bool + +class Preferences(bpy_struct): + view: PreferencesView + addons: Addons + +class UIList(bpy_struct): + layout_type: str + +class NodeLink(bpy_struct): + is_valid: bool + to_socket: NodeSocket + from_socket: NodeSocket + from_node: Node + to_node: Node + +class NodeLinks(bpy_prop_collection[NodeLink]): + def new( + self, + input: NodeSocket, + output: NodeSocket, + verify_limits: bool = True, + ) -> NodeLink: ... + def remove(self, link: NodeLink) -> None: ... + +class Nodes(bpy_prop_collection[Node]): + def new(self, type: str) -> Node: ... + def remove(self, node: Node) -> None: ... + +class NodeTreeInputs(bpy_prop_collection[NodeSocketInterface]): + def new(self, type: str, name: str) -> NodeSocketInterface: ... + def remove(self, socket: NodeSocketInterface) -> None: ... + +class NodeTreeOutputs(bpy_prop_collection[NodeSocketInterface]): + def new(self, type: str, name: str) -> NodeSocketInterface: ... + def remove(self, socket: NodeSocketInterface) -> None: ... + +class NodeTreeInterfaceItem(bpy_struct): + @property + def item_type(self) -> str: ... + +class NodeTreeInterfaceSocket(NodeTreeInterfaceItem): + attribute_domain: str + bl_socket_idname: str + default_attribute_name: str + description: str + force_non_field: bool + hide_in_modifier: bool + hide_value: bool + @property + def identifier(self) -> str: ... + in_out: str + name: str + socket_type: str + +class NodeTreeInterfaceSocketFloat(NodeTreeInterfaceSocket): + default_value: float + max_value: float + min_value: float + +class NodeTreeInterfaceSocketFloatAngle(NodeTreeInterfaceSocket): + default_value: float + max_value: float + min_value: float + +class NodeTreeInterfaceSocketFloatDistance(NodeTreeInterfaceSocket): + default_value: float + max_value: float + min_value: float + +class NodeTreeInterfaceSocketFloatFactor(NodeTreeInterfaceSocket): + default_value: float + max_value: float + min_value: float + +class NodeTreeInterfaceSocketFloatPercentage(NodeTreeInterfaceSocket): + default_value: float + max_value: float + min_value: float + +class NodeTreeInterfaceSocketFloatTime(NodeTreeInterfaceSocket): + default_value: float + max_value: float + min_value: float + +class NodeTreeInterfaceSocketFloatTimeAbsolute(NodeTreeInterfaceSocket): + default_value: float + max_value: float + min_value: float + +class NodeTreeInterfaceSocketFloatUnsigned(NodeTreeInterfaceSocket): + default_value: float + max_value: float + min_value: float + +class NodeTreeInterfaceSocketColor(NodeTreeInterfaceSocket): + default_value: tuple[float, float, float, float] + +class NodeTreeInterfaceSocketVector(NodeTreeInterfaceSocket): + default_value: tuple[float, float, float] + max_value: float + min_value: float + +class NodeTreeInterfaceSocketVectorAcceleration(NodeTreeInterfaceSocket): + default_value: Vector + max_value: float + min_value: float + +class NodeTreeInterfaceSocketVectorDirection(NodeTreeInterfaceSocket): + default_value: Vector + max_value: float + min_value: float + +class NodeTreeInterfaceSocketVectorEuler(NodeTreeInterfaceSocket): + default_value: Euler + max_value: float + min_value: float + +class NodeTreeInterfaceSocketVectorTranslation(NodeTreeInterfaceSocket): + default_value: Vector + max_value: float + min_value: float + +class NodeTreeInterfaceSocketVectorVelocity(NodeTreeInterfaceSocket): + default_value: Vector + max_value: float + min_value: float + +class NodeTreeInterfaceSocketVectorXYZ(NodeTreeInterfaceSocket): + default_value: Vector + max_value: float + min_value: float + +class NodeTreeInterfaceSocketInt(NodeTreeInterfaceSocket): + default_value: int + max_value: int + min_value: int + subtype: str + +class NodeTreeInterfaceSocketIntFactor(NodeTreeInterfaceSocket): + default_value: int + max_value: int + min_value: int + subtype: str + +class NodeTreeInterfaceSocketIntPercentage(NodeTreeInterfaceSocket): + default_value: int + max_value: int + min_value: int + subtype: str + +class NodeTreeInterfacePanel(NodeTreeInterfaceItem): ... + +class NodeTreeInterface(bpy_struct): + @property + def items_tree(self) -> bpy_prop_collection[NodeTreeInterfaceItem]: ... + def new_socket( + self, + name: str, + *, # キーワード専用とはドキュメントに記載は無いが? + description: str = "", + in_out: str = ..., + socket_type: str = "DEFAULT", + parent: Optional[NodeTreeInterfacePanel] = None, + ) -> NodeTreeInterfaceSocket: ... + def clear(self) -> None: ... + def remove( + self, + item: NodeTreeInterfaceItem, + move_content_to_parent: bool = True, + ) -> None: ... + +class NodeTree(ID): + @property + def links(self) -> NodeLinks: ... + @property + def nodes(self) -> Nodes: ... + @property + def type(self) -> str: ... + @property + def vrm_addon_extension(self) -> VrmAddonNodeTreeExtensionPropertyGroup: ... + + # bpy.app.version < (4, 0) + @property + def inputs(self) -> NodeTreeInputs: ... + @property + def outputs(self) -> NodeTreeOutputs: ... + + # bpy.app.version >= (4, 0) + @property + def interface(self) -> NodeTreeInterface: ... + +class Material(ID): + name: str + blend_method: str + + @property + def node_tree(self) -> Optional[NodeTree]: ... + + use_nodes: bool + alpha_threshold: float + shadow_method: str + use_backface_culling: bool + show_transparent_back: bool + alpha_method: str + diffuse_color: bpy_prop_array[float] + roughness: float + + @property + def vrm_addon_extension(self) -> VrmAddonMaterialExtensionPropertyGroup: ... + +class IDMaterials(bpy_prop_collection[Optional[Material]]): + def append(self, value: Material) -> None: ... # TODO: ドキュメントには存在しない + +class Curve(ID): + @property + def materials(self) -> IDMaterials: ... + +class Modifier(bpy_struct): + name: str + show_expanded: bool + show_in_editmode: bool + show_viewport: bool + show_render: bool + + @property + def type(self) -> str: ... + + # TODO: 本当はbpy_structのメソッド + def get(self, key: str, default: object = None) -> object: ... + # TODO: 本当はbpy_structのメソッド + def __setitem__(self, key: str, value: object) -> None: ... + +class ArmatureModifier(Modifier): + object: Optional[Object] + +class NodesModifier(Modifier): + node_group: Optional[NodeTree] # Noneになるかは要検証 + +class OperatorFileListElement(PropertyGroup): ... + +class Constraint(bpy_struct): + name: str + is_valid: bool + mute: bool + influence: float + +class ObjectConstraints(bpy_prop_collection[Constraint]): + def new(self, type: str) -> Constraint: ... + +class DampedTrackConstraint(Constraint): + head_tail: float + subtarget: str + target: Optional[Object] + track_axis: str + +class CopyRotationConstraint(Constraint): + target: Optional[Object] + mix_mode: str + use_x: bool + use_y: bool + use_z: bool + invert_x: bool + invert_y: bool + invert_z: bool + owner_space: str + target_space: str + subtarget: str + +class ViewLayers(bpy_prop_collection[ViewLayer]): + def update(self) -> None: ... # TODO: ドキュメントに記載されていない + +class ColorManagedViewSettings(bpy_struct): + view_transform: str + +class View3DCursor(bpy_struct): + matrix: Matrix + +class RenderSettings(bpy_struct): + fps: int + fps_base: float + +class Scene(ID): + frame_start: int + frame_current: int + frame_end: int + + @property + def collection(self) -> Collection: ... + @property + def view_layers(self) -> ViewLayers: ... + @property + def view_settings(self) -> ColorManagedViewSettings: ... + @property + def cursor(self) -> View3DCursor: ... + @property + def render(self) -> RenderSettings: ... + @property + def vrm_addon_extension(self) -> VrmAddonSceneExtensionPropertyGroup: ... + +class AreaSpaces(bpy_prop_collection[Space]): ... + +class Area(bpy_struct): + @property + def x(self) -> int: ... + @property + def y(self) -> int: ... + @property + def width(self) -> int: ... + @property + def height(self) -> int: ... + @property + def spaces(self) -> AreaSpaces: ... + @property + def regions(self) -> bpy_prop_collection[Region]: ... + type: str + show_menus: bool + +class Screen(ID): + @property + def areas(self) -> bpy_prop_collection[Area]: ... + +class Window(bpy_struct): + screen: Screen + +class Timer(bpy_struct): ... + +class WindowManager(ID): + @property + def windows(self) -> bpy_prop_collection[Window]: ... + @classmethod + def invoke_props_dialog(cls, operator: Operator, width: int = 300) -> set[str]: ... + @classmethod + def modal_handler_add(cls, operator: Operator) -> bool: ... + def progress_begin(self, min: float, max: float) -> None: ... + def progress_update(self, value: float) -> None: ... + def progress_end(self) -> None: ... + def event_timer_add( + self, + time_step: float, + window: Optional[Window] = None, + ) -> Timer: ... + +class SpaceFileBrowser(Space): + active_operator: Operator + +class View2D(bpy_struct): ... + +class Region(bpy_struct): + def alignment(self) -> str: ... + def data(self) -> AnyType: ... + def height(self) -> int: ... + def type(self) -> str: ... + def view2d(self) -> View2D: ... + def width(self) -> int: ... + def x(self) -> int: ... + def y(self) -> int: ... + +class RegionView3D(bpy_struct): + # ドキュメントには二次元配列と書いてあるので要確認 + perspective_matrix: Matrix + # ドキュメントには二次元配列と書いてあるので要確認 + view_matrix: Matrix + # ドキュメントには二次元配列と書いてあるので要確認 + window_matrix: Matrix + +class Context(bpy_struct): + def evaluated_depsgraph_get(self) -> Depsgraph: ... + + # https://docs.blender.org/api/2.93/bpy.context.html + # https://docs.blender.org/api/2.93/bpy.types.Context.html + + # Global Context + @property + def area(self) -> Area: ... + @property + def blend_data(self) -> BlendData: ... + @property + def mode(self) -> str: ... + @property + def preferences(self) -> Preferences: ... + @property + def region_data(self) -> RegionView3D: ... + @property + def scene(self) -> Scene: ... + @property + def screen(self) -> Screen: ... + @property + def space_data(self) -> Space: ... + @property + def view_layer(self) -> ViewLayer: ... + @property + def window(self) -> Window: ... + @property + def window_manager(self) -> WindowManager: ... + + # Screen Context + object: Optional[Object] + active_object: Optional[Object] + selectable_objects: Sequence[Object] + selected_objects: Sequence[Object] + + # Buttons Context or Node Context + material: Optional[Material] + +class CollectionObjects(bpy_prop_collection[Object]): + def link(self, obj: Object) -> None: ... + def unlink(self, obj: Object) -> None: ... + +class CollectionChildren(bpy_prop_collection["Collection"]): + def link(self, child: Collection) -> None: ... + +class Collection(ID): + objects: CollectionObjects + children: CollectionChildren + +class BlendDataCollections(bpy_prop_collection[Collection]): + def new(self, name: str) -> Collection: ... + def remove( + self, + collection: Collection, + do_unlink: bool = True, + do_id_user: bool = True, + do_ui_user: bool = True, + ) -> None: ... + active: Optional[Object] + +class BlendDataObjects(bpy_prop_collection[Object]): + def new(self, name: str, object_data: Optional[ID]) -> Object: ... + def remove( + self, + element: Object, + do_unlink: bool = True, + do_id_user: bool = True, + do_ui_user: bool = True, + ) -> None: ... + +class Library(ID): ... + +class BlendDataMaterials(bpy_prop_collection[Material]): + def new(self, name: str) -> Material: ... + def remove( + self, + material: Material, + do_unlink: bool = True, + do_id_user: bool = True, + do_ui_user: bool = True, + ) -> None: ... + +class BlendDataImages(bpy_prop_collection[Image]): + def new( + self, + name: str, + width: int, + height: int, + alpha: bool = False, + float_buffer: bool = False, + stereo3d: bool = False, + is_data: bool = False, + tiled: bool = False, + ) -> Image: ... + def load(self, filepath: str, check_existing: bool = False) -> Image: ... + +class BlendDataArmatures(bpy_prop_collection[Armature]): + def new(self, name: str) -> Armature: ... + +class BlendDataTexts(bpy_prop_collection[Text]): + def new(self, name: str) -> Text: ... + +class BlendDataMeshes(bpy_prop_collection[Mesh]): + def new(self, name: str) -> Mesh: ... + def remove( + self, + mesh: Mesh, + do_unlink: bool = True, + do_id_user: bool = True, + do_ui_user: bool = True, + ) -> None: ... + +class BlendDataLibraries(bpy_prop_collection[Library]): + def load( + self, + filepath: str, + link: bool, + ) -> contextlib.AbstractContextManager[ + tuple[BlendData, BlendData] + ]: ... # ドキュメントに存在しない + +class BlendDataNodeTrees(bpy_prop_collection[NodeTree]): + def new(self, name: str, type: str) -> NodeTree: ... + def remove( + self, + tree: NodeTree, + do_unlink: bool = True, + do_id_user: bool = True, + do_ui_user: bool = True, + ) -> None: ... + def append(self, value: NodeTree) -> None: ... # ドキュメントに存在しない + +class BlendDataActions(bpy_prop_collection[Action]): + def new(self, name: str) -> Action: ... + +class BlendDataScenes(bpy_prop_collection[Scene]): ... + +class MetaElement(bpy_struct): + co: Vector + hide: bool + radius: float + rotation: Quaternion + +class MetaBallElements(bpy_prop_collection[MetaElement]): + def new(self, type: str = "BALL") -> MetaElement: ... + +class MetaBall(ID): + threshold: float + resolution: float + + @property + def elements(self) -> MetaBallElements: ... + +class BlendDataMetaBalls(bpy_prop_collection[MetaBall]): + def new(self, name: str) -> MetaBall: ... + def remove( + self, + metaball: MetaBall, + do_unlink: bool = True, + do_id_user: bool = True, + do_ui_user: bool = True, + ) -> None: ... + +class BlendData: + @property + def actions(self) -> BlendDataActions: ... + @property + def filepath(self) -> str: ... + @property + def collections(self) -> BlendDataCollections: ... + @property + def objects(self) -> BlendDataObjects: ... + @property + def materials(self) -> BlendDataMaterials: ... + @property + def images(self) -> BlendDataImages: ... + @property + def armatures(self) -> BlendDataArmatures: ... + @property + def texts(self) -> BlendDataTexts: ... + @property + def meshes(self) -> BlendDataMeshes: ... + @property + def libraries(self) -> BlendDataLibraries: ... + @property + def node_groups(self) -> BlendDataNodeTrees: ... + @property + def scenes(self) -> BlendDataScenes: ... + @property + def shape_keys(self) -> bpy_prop_collection[Key]: ... + @property + def metaballs(self) -> BlendDataMetaBalls: ... + +class Operator(bpy_struct): + bl_idname: str + bl_label: str + @property + def layout(self) -> UILayout: ... + +# この型はUILayout.prop_searchで使うけど、ドキュメントが曖昧なためいまいちな定義になる +AnyType: typing_extensions.TypeAlias = Union[ID, BlendData, Operator, PropertyGroup] + +class Panel(bpy_struct): + bl_idname: str + @property + def layout(self) -> UILayout: ... + +class Menu(bpy_struct): ... +class Header(bpy_struct): ... +class KeyingSetInfo(bpy_struct): ... +class RenderEngine(bpy_struct): ... + +TOPBAR_MT_file_import: MutableSequence[Callable[[Operator, Context], None]] +TOPBAR_MT_file_export: MutableSequence[Callable[[Operator, Context], None]] +VIEW3D_MT_armature_add: MutableSequence[Callable[[Operator, Context], None]] diff --git a/typings/bpy-stubs/utils/__init__.pyi b/typings/bpy-stubs/utils/__init__.pyi new file mode 100644 index 000000000..f25242218 --- /dev/null +++ b/typings/bpy-stubs/utils/__init__.pyi @@ -0,0 +1,46 @@ +from typing import Union + +from bpy.types import ( + AddonPreferences, + Header, + KeyingSetInfo, + Menu, + Operator, + Panel, + PropertyGroup, + RenderEngine, + UIList, +) + +def register_class( + t: type[ + Union[ + Panel, + UIList, + Menu, + Header, + Operator, + KeyingSetInfo, + RenderEngine, + # 以下、ドキュメントには存在しないもの + AddonPreferences, + PropertyGroup, + ] + ], +) -> None: ... +def unregister_class( + t: type[ + Union[ + Panel, + UIList, + Menu, + Header, + Operator, + KeyingSetInfo, + RenderEngine, + # 以下、ドキュメントには存在しないもの + AddonPreferences, + PropertyGroup, + ] + ], +) -> None: ... diff --git a/typings/bpy_extras-stubs/__init__.pyi b/typings/bpy_extras-stubs/__init__.pyi new file mode 100644 index 000000000..08c2ae440 --- /dev/null +++ b/typings/bpy_extras-stubs/__init__.pyi @@ -0,0 +1,2 @@ +from . import io_utils as io_utils +from . import node_shader_utils as node_shader_utils diff --git a/typings/bpy_extras-stubs/io_utils/__init__.pyi b/typings/bpy_extras-stubs/io_utils/__init__.pyi new file mode 100644 index 000000000..973deb6fc --- /dev/null +++ b/typings/bpy_extras-stubs/io_utils/__init__.pyi @@ -0,0 +1,19 @@ +from bpy.types import Context, Event + +class ImportHelper: + filepath: str # ドキュメントには記載がない + + def invoke( + self, + context: Context, + event: Event, + ) -> set[str]: ... + +class ExportHelper: + filepath: str # ドキュメントには記載がない + + def invoke( + self, + context: Context, + event: Event, + ) -> set[str]: ... diff --git a/typings/bpy_extras-stubs/node_shader_utils/__init__.pyi b/typings/bpy_extras-stubs/node_shader_utils/__init__.pyi new file mode 100644 index 000000000..737bf2ced --- /dev/null +++ b/typings/bpy_extras-stubs/node_shader_utils/__init__.pyi @@ -0,0 +1,274 @@ +from collections.abc import Iterable, Sequence +from typing import Optional, overload + +import typing_extensions +from bpy.types import ( + Image, + Material, + NodeSocket, + ShaderNode, + ShaderNodeBsdfPrincipled, + ShaderNodeMapping, + ShaderNodeNormalMap, + ShaderNodeOutputMaterial, + ShaderNodeTexCoord, + ShaderNodeTexImage, +) +from mathutils import Color + +__all__ = ("PrincipledBSDFWrapper",) + +def rgb_to_rgba(rgb: Sequence[float]) -> list[float]: ... +def rgba_to_rgb(rgba: Sequence[float]) -> Color: ... +@overload +def values_clamp( + val: Iterable[float], minv: Iterable[float], maxv: Iterable[float] +) -> tuple[float, ...]: ... +@overload +def values_clamp(val: float, minv: float, maxv: float) -> float: ... + +class ShaderWrapper: + NODES_LIST: tuple[str, ...] + __slots__ = ( + "is_readonly", + "material", + "_textures", + "_grid_locations", + "node_out", + "_node_texcoords", + ) + is_readonly: bool + material: Material + node_out: Optional[ShaderNodeOutputMaterial] + + def __init__( + self, + material: Material, + is_readonly: bool = True, + use_nodes: bool = True, + ) -> None: ... + def update(self) -> None: ... + def use_nodes_get(self) -> bool: ... + def use_nodes_set(self, val: bool) -> None: ... + @property + def use_nodes(self) -> bool: ... + @use_nodes.setter + def use_nodes(self, val: bool) -> None: ... + def node_texcoords_get(self) -> Optional[ShaderNodeTexCoord]: ... + @property + def node_texcoords(self) -> Optional[ShaderNodeTexCoord]: ... + +class PrincipledBSDFWrapper(ShaderWrapper): + NODES_LIST: tuple[str, ...] + __slots__ = ( + "is_readonly", + "material", + "node_out", + "node_principled_bsdf", + "_node_normalmap", + "_node_texcoords", + ) + + node_principled_bsdf: Optional[ShaderNodeBsdfPrincipled] + + def __init__( + self, + material: Material, + is_readonly: bool = True, + use_nodes: bool = True, + ) -> None: ... + def node_normalmap_get(self) -> Optional[ShaderNodeNormalMap]: ... + @property + def node_normalmap(self) -> Optional[ShaderNodeNormalMap]: ... + def base_color_get(self) -> Sequence[float]: ... + def base_color_set(self, color: Sequence[float]) -> None: ... + @property + def base_color(self) -> Sequence[float]: ... + @base_color.setter + def base_color(self, color: Sequence[float]) -> None: ... + def base_color_texture_get(self) -> Optional[ShaderImageTextureWrapper]: ... + @property + def base_color_texture(self) -> Optional[ShaderImageTextureWrapper]: ... + def specular_get(self) -> float: ... + def specular_set(self, value: float) -> None: ... + @property + def specular(self) -> float: ... + @specular.setter + def specular(self, value: float) -> None: ... + def specular_tint_get(self) -> float: ... + def specular_tint_set(self, value: float) -> None: ... + @property + def specular_tint(self) -> float: ... + @specular_tint.setter + def specular_tint(self, value: float) -> None: ... + def specular_texture_get(self) -> Optional[ShaderImageTextureWrapper]: ... + @property + def specular_texture(self) -> Optional[ShaderImageTextureWrapper]: ... + def roughness_get(self) -> float: ... + def roughness_set(self, value: float) -> None: ... + @property + def roughness(self) -> float: ... + @roughness.setter + def roughness(self, value: float) -> None: ... + def roughness_texture_get(self) -> Optional[ShaderImageTextureWrapper]: ... + @property + def roughness_texture(self) -> Optional[ShaderImageTextureWrapper]: ... + def metallic_get(self) -> float: ... + def metallic_set(self, value: float) -> None: ... + @property + def metallic(self) -> float: ... + @metallic.setter + def metallic(self, value: float) -> None: ... + def metallic_texture_get(self) -> Optional[ShaderImageTextureWrapper]: ... + @property + def metallic_texture(self) -> Optional[ShaderImageTextureWrapper]: ... + def ior_get(self) -> float: ... + def ior_set(self, value: float) -> None: ... + @property + def ior(self) -> float: ... + @ior.setter + def ior(self, value: float) -> None: ... + def ior_texture_get(self) -> Optional[ShaderImageTextureWrapper]: ... + @property + def ior_texture(self) -> Optional[ShaderImageTextureWrapper]: ... + def transmission_get(self) -> float: ... + def transmission_set(self, value: float) -> None: ... + @property + def transmission(self) -> float: ... + @transmission.setter + def transmission(self, value: float) -> None: ... + def transmission_texture_get(self) -> Optional[ShaderImageTextureWrapper]: ... + @property + def transmission_texture(self) -> Optional[ShaderImageTextureWrapper]: ... + def alpha_get(self) -> float: ... + def alpha_set(self, value: float) -> None: ... + @property + def alpha(self) -> float: ... + @alpha.setter + def alpha(self, value: float) -> None: ... + def alpha_texture_get(self) -> Optional[ShaderImageTextureWrapper]: ... + @property + def alpha_texture(self) -> Optional[ShaderImageTextureWrapper]: ... + def emission_color_get(self) -> Sequence[float]: ... + def emission_color_set(self, color: Sequence[float]) -> None: ... + @property + def emission_color(self) -> Sequence[float]: ... + @emission_color.setter + def emission_color(self, color: Sequence[float]) -> None: ... + def emission_color_texture_get(self) -> Optional[ShaderImageTextureWrapper]: ... + @property + def emission_color_texture(self) -> Optional[ShaderImageTextureWrapper]: ... + def emission_strength_get(self) -> float: ... + def emission_strength_set(self, value: float) -> None: ... + @property + def emission_strength(self) -> float: ... + @emission_strength.setter + def emission_strength(self, value: float) -> None: ... + def emission_strength_texture_get(self) -> Optional[ShaderImageTextureWrapper]: ... + @property + def emission_strength_texture(self) -> Optional[ShaderImageTextureWrapper]: ... + def normalmap_strength_get(self) -> float: ... + def normalmap_strength_set(self, value: float) -> None: ... + @property + def normalmap_strength(self) -> float: ... + @normalmap_strength.setter + def normalmap_strength(self, value: float) -> None: ... + def normalmap_texture_get(self) -> Optional[ShaderImageTextureWrapper]: ... + @property + def normalmap_texture(self) -> Optional[ShaderImageTextureWrapper]: ... + +class ShaderImageTextureWrapper: + NODES_LIST: typing_extensions.TypeAlias = tuple[str, ...] + __slots__ = ( + "owner_shader", + "is_readonly", + "grid_row_diff", + "use_alpha", + "colorspace_is_data", + "colorspace_name", + "node_dst", + "socket_dst", + "_node_image", + "_node_mapping", + ) + + owner_shader: ShaderWrapper + is_readonly: bool + grid_row_diff: float + use_alpha: bool + colorspace_is_data: Optional[bool] + colorspace_name: Optional[str] + node_dst: ShaderNode + socket_dst: NodeSocket + + def __new__( # noqa: PYI034 + cls, + owner_shader: ShaderWrapper, + node_dst: ShaderNode, + socket_dst: NodeSocket, + grid_row_diff: float = 0, + use_alpha: bool = False, + colorspace_is_data: bool = ..., + colorspace_name: str = ..., + ) -> ShaderImageTextureWrapper: ... + def __init__( + self, + owner_shader: ShaderWrapper, + node_dst: ShaderNode, + socket_dst: NodeSocket, + grid_row_diff: float = 0, + use_alpha: bool = False, + colorspace_is_data: bool = ..., + colorspace_name: str = ..., + ) -> None: ... + def copy_from(self, tex: ShaderImageTextureWrapper) -> None: ... + def copy_mapping_from(self, tex: ShaderImageTextureWrapper) -> None: ... + def node_image_get(self) -> Optional[ShaderNodeTexImage]: ... + @property + def node_image(self) -> Optional[ShaderNodeTexImage]: ... + def image_get(self) -> Optional[Image]: ... + def image_set(self, image: Image) -> None: ... + @property + def image(self) -> Optional[Image]: ... + @image.setter + def image(self, image: Image) -> None: ... + def projection_get(self) -> str: ... + def projection_set(self, projection: str) -> None: ... + @property + def projection(self) -> str: ... + @projection.setter + def projection(self, projection: str) -> None: ... + def texcoords_get(self) -> str: ... + def texcoords_set(self, texcoords: str) -> None: ... + @property + def texcoords(self) -> str: ... + @texcoords.setter + def texcoords(self, texcoords: str) -> None: ... + def extension_get(self) -> str: ... + def extension_set(self, extension: str) -> None: ... + @property + def extension(self) -> str: ... + @extension.setter + def extension(self, extension: str) -> None: ... + def has_mapping_node(self) -> bool: ... + def node_mapping_get(self) -> Optional[ShaderNodeMapping]: ... + @property + def node_mapping(self) -> Optional[ShaderNodeMapping]: ... + def translation_get(self) -> Sequence[float]: ... + def translation_set(self, translation: Sequence[float]) -> None: ... + @property + def translation(self) -> Sequence[float]: ... + @translation.setter + def translation(self, translation: Sequence[float]) -> None: ... + def rotation_get(self) -> Sequence[float]: ... + def rotation_set(self, rotation: Sequence[float]) -> None: ... + @property + def rotation(self) -> Sequence[float]: ... + @rotation.setter + def rotation(self, rotation: Sequence[float]) -> None: ... + def scale_get(self) -> Sequence[float]: ... + def scale_set(self, scale: Sequence[float]) -> None: ... + @property + def scale(self) -> Sequence[float]: ... + @scale.setter + def scale(self, scale: Sequence[float]) -> None: ... diff --git a/typings/bpy_extras-stubs/view3d_utils/__init__.pyi b/typings/bpy_extras-stubs/view3d_utils/__init__.pyi new file mode 100644 index 000000000..242c59046 --- /dev/null +++ b/typings/bpy_extras-stubs/view3d_utils/__init__.pyi @@ -0,0 +1,33 @@ +from collections.abc import Sequence +from typing import Optional, TypeVar, Union + +from bpy.types import Region, RegionView3D +from mathutils import Vector + +def region_2d_to_vector_3d( + region: Region, + rv3d: RegionView3D, + coord: Sequence[float], +) -> Vector: ... +def region_2d_to_origin_3d( + region: Region, + rv3d: RegionView3D, + coord: Sequence[float], + clamp: Optional[float] = None, +) -> Vector: ... +def region_2d_to_location_3d( + region: Region, + rv3d: RegionView3D, + coord: Sequence[float], + depth_location: Sequence[float], +) -> Vector: ... + +__Default = TypeVar("__Default") + +def location_3d_to_region_2d( + region: Region, + rv3d: RegionView3D, + coord: Sequence[float], + # https://github.com/python/mypy/issues/3737 + default: __Default = None, # type: ignore[assignment] +) -> Union[Vector, __Default]: ... diff --git a/typings/gpu-stubs/__init__.pyi b/typings/gpu-stubs/__init__.pyi new file mode 100644 index 000000000..978f197d7 --- /dev/null +++ b/typings/gpu-stubs/__init__.pyi @@ -0,0 +1 @@ +from . import types as types diff --git a/typings/gpu-stubs/types/__init__.pyi b/typings/gpu-stubs/types/__init__.pyi new file mode 100644 index 000000000..92d54bfb9 --- /dev/null +++ b/typings/gpu-stubs/types/__init__.pyi @@ -0,0 +1,42 @@ +import contextlib +from collections.abc import Sequence +from typing import Optional, Union + +from mathutils import Matrix + +class GPUOffScreen: + def __init__(self, width: int, height: int) -> None: ... + def bind(self) -> contextlib.AbstractContextManager[None]: ... + color_texture: int + +class GPUIndexBuf: + def __init__(self, type: str, seq: object) -> None: ... + +class GPUVertBuf: + def __init__(self, len: int, format: object) -> None: ... + +class GPUBatch: + def __init__( + self, + type: str, + buf: GPUVertBuf, + elem: Optional[GPUIndexBuf] = None, + ) -> None: ... + +class GPUShader: + def __init__( + self, + vertexcode: str, + fragcode: str, + geocode: Optional[str] = None, + libcode: Optional[str] = None, + defines: Optional[str] = None, + ) -> None: ... + def uniform_float( + self, + name: str, + # どうやらMatrixも直接渡せるようだが、要確認 + value: Union[float, Sequence[float], Matrix], + ) -> None: ... + def bind(self) -> None: ... + def uniform_int(self, name: str, seq: Union[int, Sequence[int]]) -> None: ... diff --git a/typings/gpu_extras-stubs/__init__.pyi b/typings/gpu_extras-stubs/__init__.pyi new file mode 100644 index 000000000..60075c934 --- /dev/null +++ b/typings/gpu_extras-stubs/__init__.pyi @@ -0,0 +1 @@ +from . import batch as batch diff --git a/typings/gpu_extras-stubs/batch/__init__.pyi b/typings/gpu_extras-stubs/batch/__init__.pyi new file mode 100644 index 000000000..99fdc8bc8 --- /dev/null +++ b/typings/gpu_extras-stubs/batch/__init__.pyi @@ -0,0 +1,8 @@ +from gpu.types import GPUBatch, GPUShader + +def batch_for_shader( + shader: GPUShader, + type: str, + content: object, + indices: object = None, +) -> GPUBatch: ... diff --git a/typings/idprop-stubs/__init__.pyi b/typings/idprop-stubs/__init__.pyi new file mode 100644 index 000000000..978f197d7 --- /dev/null +++ b/typings/idprop-stubs/__init__.pyi @@ -0,0 +1 @@ +from . import types as types diff --git a/typings/idprop-stubs/types/__init__.pyi b/typings/idprop-stubs/types/__init__.pyi new file mode 100644 index 000000000..dc83b863f --- /dev/null +++ b/typings/idprop-stubs/types/__init__.pyi @@ -0,0 +1,4 @@ +class IDPropertyGroup: + def clear(self) -> None: ... + def get(self, key: str, default: object = None) -> object: ... + def pop(self, key: str, default: object = None) -> object: ... diff --git a/typings/mathutils-stubs/__init__.pyi b/typings/mathutils-stubs/__init__.pyi new file mode 100644 index 000000000..7a38ff3de --- /dev/null +++ b/typings/mathutils-stubs/__init__.pyi @@ -0,0 +1,139 @@ +from collections.abc import Iterable, Iterator, Sequence +from typing import Optional, Union, overload + +# TODO: 引数のIterableは本当はSequenceだったりしないか? + +class Matrix: + def __init__(self, rows: Sequence[Sequence[float]] = ()) -> None: ... + def copy(self) -> Matrix: ... + @classmethod + def Translation(cls, vector: Iterable[float]) -> Matrix: ... + @classmethod + def Rotation(cls, angle: float, size: int, axis: Union[str, Vector]) -> Matrix: ... + @classmethod + def Identity(cls, size: int) -> Matrix: ... + @classmethod + def Diagonal(cls, vector: Iterable[float]) -> Matrix: ... + + # ドキュメントには"fallback"という引数がついているが、それを指定すると + # フォールバック時にそれが返るらしい。でもそれだと型が合わないので + # 使わないでほしいという気持ちを込めるため書かない。 + def inverted(self) -> Matrix: ... + @overload + def __matmul__(self, other: Matrix) -> Matrix: ... + @overload + def __matmul__(self, other: Vector) -> Vector: ... + def to_translation(self) -> Vector: ... + def transpose(self) -> None: ... + def __getitem__(self, index: int) -> Vector: ... + def __len__(self) -> int: ... + def inverted_safe(self) -> Matrix: ... + def transposed(self) -> Matrix: ... + def decompose(self) -> tuple[Vector, Quaternion, Vector]: ... + def to_4x4(self) -> Matrix: ... + @property + def translation(self) -> Vector: ... + def to_quaternion(self) -> Quaternion: ... + def to_scale(self) -> Vector: ... + def __iter__(self) -> Iterator[Vector]: ... + +class Vector(Sequence[float]): + x: float + y: float + z: float + + def __init__(self, seq: Iterable[Union[int, float]]) -> None: ... + def copy(self) -> Vector: ... + def __truediv__(self, other: float) -> Vector: ... + def __setitem__(self, index: int, value: float) -> None: ... + def __add__(self, other: Vector) -> Vector: ... + def __sub__(self, other: Vector) -> Vector: ... + def __mul__(self, other: float) -> Vector: ... + def __matmul__(self, other: Matrix) -> Vector: ... + @overload + def __getitem__(self, index: int) -> float: ... + @overload + def __getitem__(self, index: slice) -> tuple[float, ...]: ... + def __iter__(self) -> Iterator[float]: ... + @property + def length(self) -> float: ... + @property + def length_squared(self) -> float: ... + def cross(self, other: Vector) -> Vector: ... + def normalize(self) -> None: ... + def dot(self, other: Vector) -> float: ... + def __neg__(self) -> Vector: ... + def __len__(self) -> int: ... + def normalized(self) -> Vector: ... + def negate(self) -> None: ... + def rotate(self, other: Union[Euler, Quaternion, Matrix]) -> None: ... + def lerp(self, other: Vector, factor: float) -> Vector: ... + def angle( + self, + other: Vector, + fallback: Optional[float] = None, + ) -> float: ... # fallbackの型のドキュメントが曖昧 + @property + def magnitude(self) -> float: ... + +class Quaternion: + x: float + y: float + z: float + w: float + + angle: float + + @overload + def __init__( + self, + seq: Union[Vector, Iterable[Union[int, float]]], + angle: float, + ) -> None: ... + @overload + def __init__( + self, + wxyz: Union[Vector, Iterable[Union[int, float]]], + ) -> None: ... + @overload + def __init__(self) -> None: ... + def copy(self) -> Quaternion: ... + def rotate(self, other: Union[Euler, Quaternion, Matrix]) -> None: ... + def to_matrix(self) -> Matrix: ... + def normalized(self) -> Quaternion: ... + @overload + def __matmul__(self, other: Quaternion) -> Quaternion: ... + @overload + def __matmul__(self, other: Vector) -> Vector: ... + def __setitem__( + self, + index: int, + value: float, + ) -> None: ... # ドキュメントには存在しない? + def to_euler( + self, + order: str = "XYZ", + euler_compat: Optional[Euler] = None, + ) -> Euler: ... + def to_axis_angle(self) -> tuple[Vector, float]: ... + def inverted(self) -> Quaternion: ... + def slerp(self, other: Quaternion, factor: float) -> Quaternion: ... + def rotation_difference(self, other: Quaternion) -> Quaternion: ... + +class Color: + r: float + g: float + b: float + +class Euler: + def __init__(self, angles: Iterable[float], order: str = "XYZ") -> None: ... + def __setitem__( + self, + index: int, + value: float, + ) -> None: ... # ドキュメントには存在しない? + def to_quaternion(self) -> Quaternion: ... + @overload + def __getitem__(self, index: int) -> float: ... + @overload + def __getitem__(self, index: slice) -> tuple[float, ...]: ... diff --git a/typings/ruff.toml b/typings/ruff.toml new file mode 100644 index 000000000..45f10c906 --- /dev/null +++ b/typings/ruff.toml @@ -0,0 +1,17 @@ +extend = "../pyproject.toml" + +[lint] +extend-ignore = [ + # ----- ignored ----- + + "A001", # Variable `x` is shadowing a Python builtin + "A002", # Argument `x` is shadowing a Python builtin + "FBT001", # Boolean-typed positional argument in function definition + "FBT002", # Boolean default positional argument in function definition + "N801", # Class name `x` should use CapWords convention + "N802", # Function name `X` should be lowercase + "UP007", # Use `X | Y` for type annotations +] + +[lint.pylint] +max-args = 75