openlawlibrary / pygls

A pythonic generic language server
https://pygls.readthedocs.io/en/latest/
Apache License 2.0
563 stars 102 forks source link

Is it possible to drop typeguard? #409

Closed karthiknadig closed 9 months ago

karthiknadig commented 10 months ago

This dependency often causes issues: https://github.com/microsoft/vscode-black-formatter/issues/265 https://github.com/microsoft/vscode-pylint/issues/446 https://github.com/microsoft/vscode-isort/issues/344

All caused by outdated version of typing extension in users environment.

lsprotocol includes the Type for the Options supported for each request. Would it be possible to use that to validate options without using typeguard?

tombh commented 10 months ago

I think this issue is related? #406 "Consider removing upper bounds on dependencies"

alcarney commented 10 months ago

I'm open to the idea.

As far as I know, the only place we use it is when we check to make sure the user passes the right type to the @server.feature decorator

During the initial migration to lsprotocol I tried replacing our is_instance function (which uses typeguard) with Python's regular isinstance() function - but couldn't make it work, or at least I didn't try very hard. I can't remember the details now, but it was either throwing errors when it shouldn't have, or was letting some errors slip through.

Assuming we can figure out a replacement for is_instance I'm all for it.

karthiknadig commented 10 months ago

@alcarney Are there tests I can verify the fix against?

alcarney commented 10 months ago

They're not comprehensive, but there are a few test cases like this one in test_feature_manager.py