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

Class variable intialized with object: value rendered as None #30

Open
powderflask opened this issue Sep 14, 2023 · 1 comment
Open

Comments

@powderflask
Copy link

Great work! I'm converting a project from autodoc, and loving the improvements...
Came across this, its a bit of a show-stopper:

Code like this:

class Foo:
    """I'm a Foo"""
    pass

class Bar:
    """I'm composed of Foo"""

    s = "just fine"

    my_foo = Foo()
    """ What the foo?"""

    i = 42  # no problem

renders to:

.. py:class:: Bar
   :canonical: scratch.Bar

   .. autodoc2-docstring:: scratch.Bar

   .. py:attribute:: s
      :canonical: scratch.Bar.s
      :value: 'just fine'

      .. autodoc2-docstring:: scratch.Bar.s

   .. py:attribute:: my_foo
      :canonical: scratch.Bar.my_foo
      :value: None

      .. autodoc2-docstring:: scratch.Bar.my_foo

   .. py:attribute:: i
      :canonical: scratch.Bar.i
      :value: 42

Was expecting value of my_foo to be Foo().

I think this is a known issue in astroid_utils

def get_const_values(node: nodes.NodeNG) -> t.Any:
    """Get the value of a constant node."""
    # TODO its not ideal that this goes to None if not understood

Any work around for this?
thanks.

@chrisjsewell
Copy link
Member

Heya, Maybe not the complete solution, but this is improved in #40

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

No branches or pull requests

2 participants