You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Python library that analyzes module dependencies and performs recursive reloading. Designed specifically for Maya script development to instantly reflect module changes.
7
9
8
-
## 機能
10
+
## Features
9
11
10
-
-**深いリロード**: 深い階層でもリロードが可能
11
-
-**AST解析**: 静的解析により from-import文 を正確に検出
12
-
-**ワイルドカード対応**: `from module import *` もサポート
13
-
-**相対インポート対応**: パッケージ内の相対インポートを正しく処理
14
-
-**循環参照対応**: Pythonで動作する循環インポートを正しくリロード
12
+
-**Deep Reload**: Reloads modules at any depth level
13
+
-**AST Analysis**: Accurately detects from-import statements through static analysis
- Python 3.11.9+ (verified in current development environment)
98
+
- pytest 8.4.2+ (required for running tests)
80
99
81
-
# 全テスト実行
82
-
python -m pytest deep_reloader/tests/ -v
100
+
**Note**: The above is the environment used for library testing and development. It differs from the Maya execution environment. Supported Maya versions are not yet finalized.
### isinstance() Failure (Python Language Constraint)
89
105
90
-
# 簡潔な出力
91
-
python -m pytest deep_reloader/tests/ -q
106
+
Instances created before reload will fail `isinstance()` checks with the reloaded class. This is a constraint of the Python language specification and a common issue with all reload systems.
107
+
108
+
**Cause**: After reload, the class object ID changes.
109
+
110
+
**Example**:
111
+
```python
112
+
# Before reload
113
+
my_class = MyClass()
114
+
isinstance(my_class, MyClass) # True
115
+
116
+
deep_reload(MyClass) # Reload
117
+
118
+
isinstance(my_class, MyClass) # False (my_class is an instance of old MyClass, MyClass is the new class)
- Use string comparison with class name (`type(my_class).__name__ == 'MyClass'`)
124
+
- Restart Maya
125
+
126
+
### import Statement Not Supported (By Design)
127
+
128
+
`import xxx` style dependencies are not supported.
129
+
130
+
**Reason**: Restoring attributes automatically added to parent modules during reload adds complexity.
131
+
132
+
**Supported Forms**: from-import only
133
+
-`from xxx import yyy` style
134
+
-`from .xxx import yyy` style
135
+
-`from . import yyy` style
136
+
137
+
### Single Package Reload Only (By Design)
138
+
139
+
`deep_reload()` only reloads modules that belong to the same package as the passed module.
140
+
141
+
**Reason**: Prevents reloading of built-in modules (`sys`, etc.) and third-party libraries (`maya.cmds`, `PySide2`, etc.) to maintain system stability.
142
+
143
+
**Example**: Running `deep_reload(myutils)` will reload only modules in the package that `myutils` belongs to.
144
+
145
+
**When developing multiple custom packages**:
146
+
If there are dependencies between packages, reloading may not work correctly. It is recommended to use a single package.
147
+
If absolutely necessary, call `deep_reload()` multiple times considering dependency order.
148
+
```python
149
+
# When you need to reload multiple packages (not recommended)
150
+
deep_reload(myutils)
151
+
deep_reload(mytools)
152
+
```
153
+
154
+
### Package Structure Required (By Design)
155
+
156
+
`deep_reload()` only supports packaged modules.
157
+
158
+
**Reason**: Standalone modules cannot distinguish between standard library and user code, risking accidental system module reloads.
0 commit comments