Coder Social home page Coder Social logo

Comments (3)

sobolevn avatar sobolevn commented on August 16, 2024 2

I think that this would be really uncommon for a non-block statement to support docstrings this way.

Right now __doc__ is not even assignable on TypeAliasType instances:

>>> type A = int
>>> A.__doc__
'Type alias.\n\nType aliases are created through the type statement::\n\n    type Alias = int\n\nIn this example, Alias and int will be treated equivalently by static\ntype checkers.\n\nAt runtime, Alias is an instance of TypeAliasType. The __name__\nattribute holds the name of the type alias. The value of the type alias\nis stored in the __value__ attribute. It is evaluated lazily, so the\nvalue is computed only if the attribute is accessed.\n\nType aliases can also be generic::\n\n    type ListOrSet[T] = list[T] | set[T]\n\nIn this case, the type parameters of the alias are stored in the\n__type_params__ attribute.\n\nSee PEP 695 for more information.\n'
>>> A.__doc__ = 'My info'
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    A.__doc__ = 'My info'
    ^^^^^^^^^
AttributeError: 'typing.TypeAliasType' object attribute '__doc__' is read-only

from cpython.

AlexWaygood avatar AlexWaygood commented on August 16, 2024 1

I don't think it's unreasonable to want to add a docstring to a type alias, but I agree with @sobolevn that this specific proposal would be pretty unprecedented. So we'd need to have a discussion over exactly how we'd want to add the feature. In short, I agree with @nineteendo — this would need to first be discussed on Discourse to hash out design details of the feature in a community forum, before opening a GitHub issue

from cpython.

nineteendo avatar nineteendo commented on August 16, 2024

Major feature proposals should generally be discussed on Discourse before opening a GitHub issue.

from cpython.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.