Skip to content

Commit

Permalink
add completions test for dataclass field alias with invalid identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
DetachHead committed Nov 1, 2024
1 parent e2dbed6 commit 191cfc3
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions packages/pyright-internal/src/tests/completions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1410,3 +1410,47 @@ test('enum with regular base type', async () => {
},
});
});

test('dataclass field alias with invalid python identifier', async () => {
const code = `
// @filename: test.py
//// from typing import dataclass_transform
////
////
//// def field[T](*, init: bool = True, default: T | None = None, alias: str | None = None) -> T: ...
////
//// @dataclass_transform(field_specifiers=(field,))
//// class Foo(type):...
////
//// class Bar(metaclass=Foo):...
////
//// class Baz(Bar):
//// a: int = field(alias='foo bar')
//// b: str = field(alias='baz')
////
//// Baz([|/*marker*/|])
`;

const state = parseAndGetTestState(code).state;

await state.verifyCompletion('included', 'markdown', {
['marker']: {
completions: [
{
label: 'baz=',
kind: CompletionItemKind.Variable,
},
],
},
});
await state.verifyCompletion('excluded', 'markdown', {
['marker']: {
completions: [
{
label: 'foo bar=',
kind: CompletionItemKind.Variable,
},
],
},
});
});

0 comments on commit 191cfc3

Please sign in to comment.