Conversation
7aa44a7 to
a057c2f
Compare
a057c2f to
dd01d9c
Compare
| @since 3.17.0 support for relative patterns. | ||
| """ | ||
| kind: NotRequired['WatchKind'] | ||
| kind: NotRequired[Union[Uint, WatchKind]] |
There was a problem hiding this comment.
From the spec perspective it is probably correct because the value is a bitwise flag so not necessarily the exact value that matches one of the enums.
There was a problem hiding this comment.
I've probably should have written this before approving/merge, but didn't pay close attention to this comment.
Actually the type of a bitwise combination of IntFlag members is also considered to by that IntFlag. So unless WatchKind also supports custom values, this UInt is probably not needed.
There was a problem hiding this comment.
That's true, but I would say that is a good thing, because we should only use predefined values or combinations of the predefined values from the WatchKind IntFlag in the code.
There was a problem hiding this comment.
There are only two types from the LSP specs that use IntFlag in the generated types: WatchKind and ApplyKind.
lsp-python-types/lsprotocol/lsp.json
Lines 15438 to 15462 in 8c62a64
lsp-python-types/lsprotocol/lsp.json
Lines 15539 to 15559 in 8c62a64
But it seems that ApplyKind is not actually used as a bitwise flag, so that could be a bug in the generator? It also does not have supportsCustomValues set in the metaModel.
I would say the generator should not produce the union type for IntFlag, even if supportsCustomValues is set.
There was a problem hiding this comment.
But it seems that ApplyKind is not actually used as a bitwise flag, so that could be a bug in the generator?
Not sure what would you consider a bug. That we don't create an union or that we use IntEnum for it?
It also does not have
supportsCustomValuesset in the metaModel.
We only create union when supportsCustomValues is true.
There was a problem hiding this comment.
No, the bug is that we don't use IntEnum for it.
Currently it is IntFlag, but that is wrong:
https://github.com/sublimelsp/LSP/blob/50fa4b40a970e7e8e6f62520aba66c47bf4bb7fb/protocol/__init__.py#L733
It should be IntEnum instead.
There was a problem hiding this comment.
We had an override for it - addressed in #40
Also tested that LSP code base has no type issues with that change.

Enumerations that specify
supportsCustomValuesnow get the base type (str or int) included where those are referenced.It solves the use case that #37 was solving but in a different way.
Note that
root_symbol_namewas unused.