是否可以傳播類型提示重寫方法?重寫方法的類型提示傳播
說,我有以下類:
class Student:
def study():
pass
class Option:
self.option_value
class BaseChoice:
def make_choice(self, student, options):
"""
:type student: Student
:type options: list[Option]
"""
class RationalChoice(BaseChoice):
def make_choice(self, student, options):
pass
當我在裏面RationalChoice.make_choice
pycharm不會爲options
屬性/方法提示自動完成,但它選擇正確的提示爲student
。顯而易見的解決方法是隻複製文檔字符串,但我會有幾十個不同的BaseChoice
後代,所以這是不實際的。
我使用PyCharm 3.1.1,社區和專業版本都受到影響。
這是python本身完全缺失的東西,還是僅僅在PyCharm中?
我還使用PyCharm 3.1.1,我得到酒吧的內部make_foo_from_bar方法的建議。如果你從一個新項目開始,是否會發生同樣的問題? –
沒關係,看起來你的例子是關閉的--PyCharm推斷'bar'是Bar類型,即使沒有任何提示。 –
看起來我已經簡化了它,我會在一分鐘內更新這個問題。 – J0HN