microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.72k stars 766 forks source link

Doc string for sqlalchemy.column is misformatted #6004

Closed rchiodo closed 1 month ago

rchiodo commented 5 months ago

Enabled the new supportRestructuredText setting and hover over a Column:

from typing import ClassVar

import sqlalchemy as sa
from sqlalchemy.orm import declarative_base, declarative_mixin, declared_attr

base = declarative_base()

@declarative_mixin
class Foo(base):
    __abstract__ = True
    __tablename__ = "foo"

    id = sa.Column(sa.Integer, primary_key=True)

    @declared_attr
    def baz_id(self) -> ClassVar[sa.Column]:
        return sa.Column(
            sa.ForeignKey("baz.baz.id"),
            comment="Keys to baz.baz.id",
        )

class FooBar(Foo):
    __table_args__ = {"schema": "foo"}

The type_ parameter formats incorrectly: image

rchiodo commented 5 months ago

I would hazard a guess the automatic indent is off when the literal block is found:

Here's what that docstring looks like for that parameter:

        :param type\_: The column's type, indicated using an instance which
          subclasses :class:`~sqlalchemy.types.TypeEngine`.  If no arguments
          are required for the type, the class of the type can be sent
          as well, e.g.::

            # use a type with arguments
            Column('data', String(50))

            # use no arguments
            Column('level', Integer)

          The ``type`` argument may be the second positional argument
          or specified by keyword.
rchiodo commented 1 month ago

This was actually fixed.