Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type info of decorated class is not helpful with specific attribute class #728

Closed
kang-sw opened this issue Dec 14, 2020 · 6 comments
Closed
Labels
enhancement New feature or request fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@kang-sw
Copy link

kang-sw commented Dec 14, 2020

When gin.configurable decorates any class, pylance's suggestions shows pretty useless information. It works well when the class is decorated with attr.attrs, or any other attribute method.

image

image

image

image

This makes it hard to work with tf-agents that most of classes are decorated with gin attribute....

Is there any workaround to resolve this?

@jakebailey
Copy link
Member

This is likely due to the gin.configurable decorator not being well-typed, and the analysis assuming it wipes away all of the info. This happens pretty commonly when a decorator uses functools.wraps, whose type isn't super helpful.

Where can we find the code for gin? I've looked on PyPI, but the results didn't seem like they matched what this library appears to be doing.

@jakebailey jakebailey added the waiting for user response Requires more information from user label Dec 14, 2020
@github-actions github-actions bot removed the triage label Dec 14, 2020
@kang-sw
Copy link
Author

kang-sw commented Dec 15, 2020

I found this when I was using tf-agent library to practice some reinforcement algorithms.

I think you can get gin package by command pip install gin, in Windows.

image

and here's url of the repository gin

@jakebailey
Copy link
Member

Yeah, they haven't annotated it at all: https://github.com/google/gin-config/blob/0841fef568722a21e4f3745a0697da608ba4376e/gin/config.py#L1163

Though I'm a bit confused, as I believe we had a heuristic where we would assume that the decorator did nothing to the signature if the decorator was untyped. @erictraut Am I misremembering that?

@erictraut
Copy link
Contributor

That's definitely the way it used to work. I'm wondering if maybe I broke that heuristic when I added support for PEP 614. I don't think we have a specific unit test for this heuristic, and we probably should.

@erictraut
Copy link
Contributor

This will be addressed in the next release. See microsoft/pyright#1292 for details.

@erictraut erictraut added enhancement New feature or request fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed waiting for user response Requires more information from user labels Dec 21, 2020
@jakebailey
Copy link
Member

This issue has been fixed in version 2021.1.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202110-6-january-2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

3 participants