Skip to content

Commit a064641

Browse files
committed
Don't generate union for IntEnums
1 parent 8c62a64 commit a064641

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

generated/lsp_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4987,7 +4987,7 @@ class FileSystemWatcher(TypedDict):
49874987
49884988
@since 3.17.0 support for relative patterns.
49894989
"""
4990-
kind: NotRequired[Union[Uint, WatchKind]]
4990+
kind: NotRequired['WatchKind']
49914991
"""
49924992
The kind of events of interest. If omitted it defaults
49934993
to WatchKind.Create | WatchKind.Change | WatchKind.Delete

utils/helpers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ def format_type(typ: EveryType, context: FormatTypeContext) -> str:
6565
return format_base_types(typ)
6666
if typ['kind'] == 'reference':
6767
literal_symbol_name = typ['name']
68-
if (enum := context['enumerations'].get(literal_symbol_name)) and enum.get('supportsCustomValues'):
68+
if (
69+
(enum := context['enumerations'].get(literal_symbol_name))
70+
and enum.get('supportsCustomValues')
71+
and enum['type']['name'] == 'string' # only for string enums, number enums are handled fine by IntEnum
72+
):
6973
return f'Union[{format_type(enum["type"], context)}, {literal_symbol_name}]'
7074
return f"'{literal_symbol_name}'"
7175
if typ['kind'] == 'array':

0 commit comments

Comments
 (0)