The following example fails on main because the annotation is a string rather than a concrete type due to the use of from __future__ import annotations. typing.get_type_hints can be used to resolve the annotations for the signature to support detection in this case.
from __future__ import annotations
from pygls import server
async def example(
foo: server.LanguageServer,
params: None,
) -> None:
pass
from pygls.feature_manager import has_ls_param_or_annotation
assert has_ls_param_or_annotation(example, server.LanguageServer)
This can also be reproduced by wrapping the annotation type in a string manually (as I do in the test in this pull request).
Code review checklist (for code reviewer to complete)
[x] Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR)
[x] Title summarizes what is changing
[x] Commit messages are meaningful (see this for details)
[x] Tests have been included and/or updated, as appropriate
~[ ] Docstrings have been included and/or updated, as appropriate~
~[ ] Standalone docs have been updated accordingly~
Description
The following example fails on
main
because the annotation is a string rather than a concrete type due to the use offrom __future__ import annotations
.typing.get_type_hints
can be used to resolve the annotations for the signature to support detection in this case.This can also be reproduced by wrapping the annotation type in a string manually (as I do in the test in this pull request).
Code review checklist (for code reviewer to complete)