🐛 fix(vscode): 代码阅读把 Python 赋值后面的字符串当变量说明,其余单独的字符串显示成注释

This commit is contained in:
cruldra committed 2026-09-26 18:57:07 +08:00
1 parent a51f90e34d
commit 1f86201373
14 files changed
+358 -59

No files matched your search

@@ -209,6 +209,35 @@ describe('sqlAlchemy 库规则', () => {
expect(user.children.map(child => [child.kind, child.startLine])).toEqual([['function', 20]])
})
it('字段的属性 docstring:没写 comment= 时当说明,写了以 comment= 为准;它并进卡片,编辑范围到最后一个字段的说明为止', async () => {
const source = [
'from sqlalchemy.orm import Mapped, mapped_column',
'',
'',
'class Case(Base):',
' __tablename__ = "case_library"',
'',
' title: Mapped[str] = mapped_column(String(120))',
' """案例标题, 用户可编辑"""',
' summary: Mapped[str] = mapped_column(Text, comment="案例描述")',
' """不显示"""',
' status = mapped_column(String(16))',
' """案例状态"""',
'',
' def label(self) -> str:',
' return self.title',
].join('\n')
const [, table] = await views(source)
expect(propertyLines(properties(table)).slice(-4)).toEqual([
'字段: 3 个',
' title | 字符串(120) | | 案例标题, 用户可编辑',
' summary | 长文本 | | 案例描述',
' status | 字符串(16) | 可空 | 案例状态',
])
expect([table.startLine, table.endLine]).toEqual([3, 11])
expect(table.children.map(child => [child.kind, child.startLine])).toEqual([['function', 13]])
})
it('没导入 SQLAlchemy 的文件不认', async () => {
const list = await views('class User(Base):\n __tablename__ = "users"\n')
expect(list.map(view => view.kind)).toEqual(['class'])