3b1b / 3b1b/manim

Python < 3.10 - TypeError: 'staticmethod' object is not callable

未關閉 適合新手
#2,263 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
Python
星號
93.9k
分支
7.7k
平均合併
2 天 13 小時
30 天內合併 PR
4

描述

### Describe the bug

It looks like ManimGL is no longer compatible with Python < 3.10, as, prior to this Python version, `@staticmethod` were not regular callable (hence, using them as a wrapper didn't work).

See here https://stackoverflow.com/a/76237739.

**Code**:

```python
from manimlib import *
```

**Wrong display or Error traceback**:

```
manim_slides/slide/manimlib.py:4: in
from manimlib import Scene, ThreeDCamera
.venv/lib/python3.9/site-packages/manimlib/__init__.py:12: in
from manimlib.window import *
.venv/lib/python3.9/site-packages/manimlib/window.py:20: in
class Window(PygletWindow):
.venv/lib/python3.9/site-packages/manimlib/window.py:117: in Window
def on_mouse_motion(self, x: int, y: int, dx: int, dy: int) -> None:
E TypeError: 'staticmethod' object is not callable
```

### Additional context

See:

> Static methods ([@staticmethod](https://docs.python.org/3/library/functions.html#staticmethod)) and class methods ([@classmethod](https://docs.python.org/3/library/functions.html#classmethod)) now inherit the method attributes (__module__, __name__, __qualname__, __doc__, __annotations__) and have a new __wrapped__ attribute. Moreover, static methods are now callable as regular functions. (Contributed by Victor Stinner in [bpo-43682](https://bugs.python.org/issue?@action=redirect&bpo=43682).)

from https://docs.python.org/3/whatsnew/3.10.html

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

錯誤發生在 manimlib/window.py 的第117行,其中 staticmethod 裝飾器以不相容 Python < 3.10 的方式使用。檢查 Window 類別和 on_mouse_motion 方法以瞭解裝飾器的用法。檢查程式碼庫中其他地方是否有類似的 @staticmethod 用法。修正可能涉及替換裝飾器或調整調用模式,以便與較舊版本的 Python 相容。變更後在 Python 3.9 環境中執行 import 測試。

由索引模型根據 Issue 內容生成。

評估

領域
backend
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
描述清楚
新手友好度
65/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。