问题描述
1.py
from other_module import dynamic
BORDER_WIDTH = 15
class Window:
parent = dynamic()
def __init__(self, width, height):
self.width = width
self.height = height
def create_empty() -> Window:
return Window(0, 0)
解决方案
安装
pip install mypy
生成
stubgen 1.py
效果
from typing import Any
BORDER_WIDTH: int
class Window:
parent: Any
width: Any
height: Any
def __init__(self, width, height) -> None: ...
def create_empty() -> Window: ...