How to document python function parameter types?

前端 未结 6 1331
名媛妹妹
名媛妹妹 2020-12-15 05:40

I know that the parameters can be any object but for the documentation it is quite important to specify what you would expect.

First is how to specify a parameter ty

6条回答
  •  隐瞒了意图╮
    2020-12-15 06:21

    Figured I'd post this little tidbit here since IDEA showed me this was possible, and I was never told nor read about this.

    >>> def test( arg: bool = False ) -> None: print( arg )
    
    >>> test(10)
    10
    

    When you type test(, IDLE's doc-tip appears with (arg: bool=False) -> None Which was something I thought only Visual Studio did.

    It's not exactly doxygen material, but it's good for documenting parameter-types for those using your code.

提交回复
热议问题