避免为 classmethod 或 staticmethod 方法调用 __init__

作者: saluto创建于 2023年4月13日更新于 2026年3月16日

假设我们想要一个类似于 git 的 CLI,即在与仓库交互之前必须先调用 init。为此,我们希望实现以下(简化的/部分实现)类,其意图是与 GitPythonRepo 类相似(请参阅 这里):

python
from pathlib import Path
import fire

内容来源: google/python-fire