https://pulumi.com logo
#python
Title
# python
g

great-sunset-355

06/25/2021, 11:55 AM
Hi was anyone able to get the code completion working in PyCharm? There seem to be something with _utilities.lazy_import so that PyCharm does not provide any completion at all. Then in VScode, you get completion working but it's not great either when I use Show Bover on the resource it does not show almost anything. For this example:
Copy code
"""A Python Pulumi program"""

import pulumi

from pulumi_aws import iam

iam.Role()
Show Hover action only shows
(class) Role
- while I expect the whole docstring to show up. But it looks like the cause of this is that how docstrings are written and possibly usage of overload decorator as well
Copy code
class MyClass:
    @overload
    def __init__(self, a:int)->None:
        """init INT"""
        ...
    def __init__(self, *args, **kwargs) -> None:
        pass # real implementation
If Classes had a class docstring like this it would at least shown that:
Copy code
class MyClass:
    """A class doc."""
    @overload
    def __init__(self, a:int)->None:
        """init INT"""
        ...
    def __init__(self, *args, **kwargs) -> None:
        pass # real implementation
I wonder if pulumi adheres to any of the styling guides or "just generates docstrings"
@red-match-15116 I noticed on github you worked on this a lot, would you be able to comment please? To confirm this is a problem so we open the issue. Thank you
r

red-match-15116

06/25/2021, 6:04 PM
Hey! So, the TL;DR is you’re right about some of this, and some of it is a little obscured. I captured the issues in detail over at https://github.com/pulumi/pulumi/issues/7367, you might be able to get some information there to get it to work for you but we do have some work to do.
I wonder if pulumi adheres to any of the styling guides or “just generates docstrings”
😆 nice FWIW, we use reStructured Text - but VSCode and PyCharm actually prioritize different formats. PyCharm likes reStructured, VSCode prefers Google-style docstrings 🤷🏽
g

great-sunset-355

06/27/2021, 6:48 AM
Yeah and I prefer Numpy style 😄 However, Goolge style classes suggest naming attributes in class docstring which can actually fix the problem at least partially 🙂 https://google.github.io/styleguide/pyguide.html#384-classes
@red-match-15116 I also found this issue: https://github.com/pulumi/pulumi/issues/5142 Then I did some research and found SO post from the author of
enum
python package and he created another package called
aenum
- that could solve the probelm in 5142 https://stackoverflow.com/questions/52062831/how-do-i-properly-document-python-enum-elements
nvm Pycharm can handle docstring under the value while VSCode don't
Downside of Auto enum is that the result shows as potential tuple in quick documentation but is not subscriptable
Speaking of doc what is making picture 1 is from
a
, picture 2 is from
b
r

red-match-15116

06/27/2021, 7:27 PM
@great-sunset-355 appreciate you looking into this. Please leave these comments in the issue so we can have a record when we go to fix, we’d like to keep github issues as the place to discuss bugs and possible fixes as we don’t all monitor this slack and it may not be me working on the issue 🙂
g

great-sunset-355

06/28/2021, 5:00 AM
yes I just wanted to make sure we want to track this in a single issue not a separate one
6 Views