You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm getting the following error (again, only the key part included):
cattrs.errors.StructureHandlerNotFoundError: Unsupported type: typing.Union[str, lsprotocol.types.NotebookDocumentFilterNotebookType, lsprotocol.types.NotebookDocumentFilterScheme, lsprotocol.types.NotebookDocumentFilterPattern, NoneType]. Register a structure hook for it.
I'm not sure, but thing that looks suspicious to me there is NoneType.
Not sure what's wrong yet, but I was able to repro the issue with the code below.
The issue seems to have something to do with handling NotebookDocumentFilterWithNotebook vs NotebookDocumentFilterWithCells. The input has cells, but the error is about parsing notebook (the NotebookDocumentFilter type).
noteook: Optional[Union[str, NotebookDocumentFilter]] =attrs.field(default=Nbone)
"""The notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook."""
for which there is no hook defined, because it is optional. There is only a hook for Union[str, NotebookDocumentFilter] which doesn't account for None.
This is the same root cause as #462, and #466 fixes it.
NotebookDocumentFilterWithCells.notebook is typed Optional[Union[str, NotebookDocumentFilterNotebookType, NotebookDocumentFilterScheme, NotebookDocumentFilterPattern]], but _hooks.py registers _notebook_filter_hook only for the non-optional union, so the optional form has no structure hook — which is the NoneType you spotted in the message.
Checked against your payload on current main (cattrs 26.2.0):
# main
FAIL ClassValidationError While structuring InitializeResult (1 sub-exception)
cattrs.errors.StructureHandlerNotFoundError: Unsupported type:
str | NotebookDocumentFilterNotebookType | NotebookDocumentFilterScheme | NotebookDocumentFilterPattern | None
# main + #466
OK NotebookDocumentSyncOptions(notebook_selector=(NotebookDocumentFilterWithCells(
cells=(NotebookCellLanguage(language='python'),), notebook=None),), save=False)
So nothing extra is needed here — this issue should close along with #466.
Activity
debonte commentedon Jul 22, 2025
Not sure what's wrong yet, but I was able to repro the issue with the code below.
The issue seems to have something to do with handling
NotebookDocumentFilterWithNotebookvsNotebookDocumentFilterWithCells. The input hascells, but the error is about parsingnotebook(theNotebookDocumentFiltertype).mjpieters commentedon Nov 26, 2025
The reproducer can be simplified to:
The issue is with the
notebookfield:for which there is no hook defined, because it is optional. There is only a hook for
Union[str, NotebookDocumentFilter]which doesn't account forNone.The work-around is to register such a hook:
fix: workaround microsoft/lsprotocol#430 for ty compatibility
Shubham-Padkonde commentedon Sep 20, 2026
This is the same root cause as #462, and #466 fixes it.
NotebookDocumentFilterWithCells.notebookis typedOptional[Union[str, NotebookDocumentFilterNotebookType, NotebookDocumentFilterScheme, NotebookDocumentFilterPattern]], but_hooks.pyregisters_notebook_filter_hookonly for the non-optional union, so the optional form has no structure hook — which is theNoneTypeyou spotted in the message.Checked against your payload on current
main(cattrs 26.2.0):So nothing extra is needed here — this issue should close along with #466.