microsoft / python-language-server

Microsoft Language Server for Python
Apache License 2.0
912 stars 131 forks source link

GenericPath test failing after typeshed upgrade #1654

Open jakebailey opened 4 years ago

jakebailey commented 4 years ago

After upgrading typeshed to a newer version, the GenericPath test fails. It looks like the __truediv__ function on Path/PurePath/etc do not have their return values set correctly. The code added in #1463 doesn't even execute.

Split from #1371, since this is taking a good chunk of time investigating.

jakebailey commented 4 years ago

When building the overload, it tries to look up _P, but with the new typeshed, _P doesn't exist in the global scope. On master, it is in the global scope.

jakebailey commented 4 years ago

Change:

_P = TypeVar('_P', bound=PurePath)

To:

_P = TypeVar('_P', bound='PurePath')

And it works. I'm not sure that this should be legal, as PEP 484 says that forward references need to be wrapped in quotes, and we assume this behavior...

jakebailey commented 4 years ago

Filed https://github.com/python/typeshed/issues/3334. Worst case I can pin to something before that change, but typeshed hasn't yet fully updated to 3.8's new stuff yet as far as I can tell.

jakebailey commented 4 years ago

image

Handling the assignment of _P, it goes and tries to evaluate the TypeVar call, which then makes its way down to handling the evaluation of PurePath

jakebailey commented 4 years ago

Can be fixed by skipping the extra eval in GetValueFromName if the module being analyzed is a stub. Better fixed by using lazy references (future).