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

Add public variables #5

Merged
merged 8 commits into from
Mar 23, 2024
Merged

Add public variables #5

merged 8 commits into from
Mar 23, 2024

Conversation

bluebird75
Copy link
Contributor

Attempt to add public variables

attr_of_instance = getattr(instance, class_attr_name)
if attr_of_instance == None:
continue
typename = attr_of_instance.__class__.__name__
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do something like this to extend the types with modules:

typename = attr_of_instance.__class__.__name__
modulename = attr_of_instance.__class__.__module__
if modulename != "builtins":
    typename = f'{modulename}.{typename}'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I did not know about that one. It will solve several cases, but not nested class. So, all enums can not be typed for example, because they always lie within another class.

Still, it's better than nothing, I'll have an attempt at it.

Copy link
Contributor

@boldar99 boldar99 Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe using __class__.__qualname__ could solve this problem?

@kaofelix
Copy link

kaofelix commented Mar 5, 2024

Hi folks, I'm interested in this changes. I have done some of it manually in a stubs folder in my own project, but I would love to see this merged. I don't know much about libcst and the code in the repo in general, so would probably take me a while to figure out what's missing, but with a few pointers I'm happy to help testing or even try finishing it

@boldar99
Copy link
Contributor

boldar99 commented Mar 7, 2024

Hey @kaofelix, I have submitted PR #6 which, I believe, solves the remaining issues.

Maybe @bluebird75 or @altendky could take a look and both PRs could be merged!

@bluebird75
Copy link
Contributor Author

Thanks @boldar99 . This looks much better

@bluebird75 bluebird75 merged commit f451517 into main Mar 23, 2024
2 checks passed
@bluebird75 bluebird75 deleted the add_public_variables branch March 23, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants