🐛 fix(vscode): Pydantic 规则的类型检查收紧空节点和差异格子
This commit is contained in:
1 parent
7a06e37936
commit
ad5796787b
2 files changed
+6
-2
No files matched your search
@@ -262,8 +262,8 @@ describe('pydantic 库规则(Python)', () => {
|
||||
const traceFields = properties(trace).findIndex(row => row.label === '字段')
|
||||
const cell = traceChange.marks?.rows?.changed[traceFields].items?.changed[2].cells?.[2]
|
||||
expect(cell?.map(part => part.change)).toEqual(['del', 'add'])
|
||||
expect(cell?.[0].segments.map(segment => segment.text).join('')).toBe('空')
|
||||
expect(cell?.[1].segments.map(segment => segment.text).join('')).toBe('""')
|
||||
expect(flatSegments(cell?.[0].segments ?? []).map(segment => segment.text).join('')).toBe('空')
|
||||
expect(flatSegments(cell?.[1].segments ?? []).map(segment => segment.text).join('')).toBe('""')
|
||||
expect(diff.stats).toEqual({ add: 0, mod: 2, del: 0 })
|
||||
})
|
||||
})
|
||||
@@ -161,6 +161,8 @@ function namesInSource(root: Node): LibraryNames {
|
||||
for (const statement of syntaxChildren(root)) {
|
||||
if (statement.type === 'import_statement') {
|
||||
for (const item of statement.childrenForFieldName('name')) {
|
||||
if (!item)
|
||||
continue
|
||||
const original = item.type === 'aliased_import' ? item.childForFieldName('name') : item
|
||||
const alias = item.type === 'aliased_import' ? item.childForFieldName('alias') : null
|
||||
if (original && fromPydantic(original.text))
|
||||
@@ -173,6 +175,8 @@ function namesInSource(root: Node): LibraryNames {
|
||||
if (!module || !fromPydantic(module.text))
|
||||
continue
|
||||
for (const item of statement.childrenForFieldName('name')) {
|
||||
if (!item)
|
||||
continue
|
||||
const original = item.type === 'aliased_import' ? item.childForFieldName('name') : item
|
||||
const alias = item.type === 'aliased_import' ? item.childForFieldName('alias') : null
|
||||
if (original)
|
||||
|
||||
Reference in new issue
Block a user