Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

ENUM_OVERRIDES: dict[str, Literal['StrEnum', 'IntFlag']] = {
'WatchKind': 'IntFlag',
'ApplyKind': 'IntFlag',
}

ALIAS_OVERRIDES: dict[str, str] = {'LSPArray': "Sequence['LSPAny']", 'LSPObject': 'Mapping[str, Any]'}
Expand Down
4 changes: 2 additions & 2 deletions generated/lsp_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ class CompletionTriggerKind(IntEnum):
"""Completion was re-triggered as current completion list is incomplete"""


class ApplyKind(IntFlag):
class ApplyKind(IntEnum):
"""
Defines how values from a set of defaults and an individual item will be
merged.
Expand Down Expand Up @@ -4987,7 +4987,7 @@ class FileSystemWatcher(TypedDict):

@since 3.17.0 support for relative patterns.
"""
kind: NotRequired[Union[Uint, WatchKind]]
kind: NotRequired['WatchKind']
"""
The kind of events of interest. If omitted it defaults
to WatchKind.Create | WatchKind.Change | WatchKind.Delete
Expand Down
6 changes: 5 additions & 1 deletion utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ def format_type(typ: EveryType, context: FormatTypeContext) -> str:
return format_base_types(typ)
if typ['kind'] == 'reference':
literal_symbol_name = typ['name']
if (enum := context['enumerations'].get(literal_symbol_name)) and enum.get('supportsCustomValues'):
if (
(enum := context['enumerations'].get(literal_symbol_name))
and enum.get('supportsCustomValues')
and enum['type']['name'] == 'string' # only for string enums, number enums are handled fine by IntEnum
):
return f'Union[{format_type(enum["type"], context)}, {literal_symbol_name}]'
return f"'{literal_symbol_name}'"
if typ['kind'] == 'array':
Expand Down