Last active
September 7, 2015 09:26
-
-
Save cocuh/8ffed1c9d3ad0f2fc0ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override = lambda f:f | |
class BaseData(object): | |
pass | |
class BaseApp(object): | |
def __init__(self): | |
self.data = self.build_data() | |
""":type: BaseData""" | |
def build_data(self): | |
return BaseData() | |
class SpamData(BaseData): | |
def get_spam(self): | |
return u'spam' | |
class SpamApp(BaseApp): | |
@override | |
def build_data(self): | |
return SpamData() | |
def hoge(self): | |
data = self.data | |
""":type: SpamData""" | |
継承したクラスSpamApp
が具象化したフィールドの型SpamData
をpydoc上で記述する方法がきになる
pycharmのtype hintingするためだけにこの一文を書くのやめたいだけなのでどっちかというとpycharm側のenhancementかも
class SpamApp(BaseApp):
def __init__(self):
super().__init__()
self.data = self.data
""":type: SpamData"""
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/cocuh/8ffed1c9d3ad0f2fc0ed#file-test-py-L26
でpydocにおいてアップキャストというか、がされてる。