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

3.4.0 borks inheritance diagrams of classes with namedtuple class variables #505

Open
eigenbrot opened this issue Dec 2, 2024 · 1 comment
Labels

Comments

@eigenbrot
Copy link

We have a class that uses a namedtuple as a class variable:

class GreatClass(BaseClass):
  
  CoolVar = namedtuple("CoolVar", ["x", "y"])

  ...

Prior to version 3.4.0 this class rendered fine with a correct inheritance diagram. Since the change from #485 in v3.4.0 building the docs produces the following warning:

/repo/docs/autoapi/module/index.rst:XX: WARNING: module.GreatClass.CoolVar specified for inheritance diagram is not a class or module [docutils]

which is true. I think the issue is that since #485 namedtuples are reported as classes.

FWIW, the rendered docs still look correct, but the warning is breaking our build pipelines. Any advice would be greatly appreciated.

@eigenbrot
Copy link
Author

Another issue that arises from defaulting to reporting namedtuples as class occurs when a namedtuple shares a name with a class in the same module (admittedly bad practice, but not disallowed by python). E.g.,

CoolThingTuple = namedtuple("CoolThing", ["foo", "bar"])

class CoolThing:
  ...

in this case building the docs produces the following warning:

/repo/docs/autoapi/module/index.rst:XX: WARNING: duplicate object description of module.CoolThing, other instance in autoapi/module/index, use :no-index: for one of them

Perhaps an configuration option to not report namedtuples as classes is the right direction to move here?

@AWhetter AWhetter added the Bug label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants