【问题标题】:python type documentation list of FoobarFoobar的python类型文档列表
【发布时间】:2017-08-03 17:34:01
【问题描述】:

我有这样的课

class Foobar(object):
    def add_bazzes(self, new_bazzes):
        # type (list(Baz)) -> object
        for new_baz in new_bazzes:
            self.__do_something__(new_baz)

现在,我的 IDE 无法推断 new_bazzesBaz 类型的列表。有没有办法在方法中添加一些类型文档?

pycharm 会自动提示

# type (object) -> object

但是在填充时

# type (list(Baz)) -> object

失败了。

【问题讨论】:

    标签: python-2.7 documentation pycharm type-hinting


    【解决方案1】:

    在intellij pycharm中,以下文档字符串帮助:

    class Foobar(object):
        def add_bazzes(self, new_bazzes):
            """
            @type new_bazzes: list[Baz]
            """
            for new_baz in new_bazzes:
                self.__do_something__(new_baz)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-02
      • 1970-01-01
      • 2023-03-06
      • 2012-08-07
      • 2010-11-20
      • 1970-01-01
      相关资源
      最近更新 更多