pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

Generated docstring should not include `:type` for unannotated parameters

Open debonte opened this issue 1 year ago • 3 comments

Environment data

  • Pylance version: 2024.9.102
  • OS and version: Windows 11
  • Python version: 3.9.12

Code Snippet

def foo(param1) -> int:
    """"""
    return 1

Repro Steps

  1. Trigger completion within """"""

Expected behavior

No :type for unannotated param1.

Actual behavior

    """Docstring for foo
    
    :param param1: Description
    :type param1:  """

debonte avatar Sep 27 '24 22:09 debonte

Would this truly be good/useful behaviour? A codebase not using type-hints might still want to, and often should, document the expected type.

laundmo avatar Dec 10 '24 12:12 laundmo

Thanks for posting this comment. We will hold on making this change. For other users, please upvote if you want this to be fixed.

KacieKK avatar Dec 18 '24 00:12 KacieKK

Also noticed that it doesn't generate docstring for annotated attributes without default values, will also fix this.

class A:
    """
    Docstring for A

    :var b: Description
    :vartype b: str
    :var c: Description
    :vartype c: float"""
    a : int
    b : str = "default"
    c = 2.2

    pass

StellaHuang95 avatar Jun 09 '25 21:06 StellaHuang95

This issue has been fixed in prerelease version 2025.6.100, which we've just released. You can find the changelog here: CHANGELOG.md

rchiodo avatar Jun 19 '25 21:06 rchiodo