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

Model detection fails for Ellipsis #124

Closed
sasanjac opened this issue Jul 30, 2024 · 4 comments · Fixed by #127
Closed

Model detection fails for Ellipsis #124

sasanjac opened this issue Jul 30, 2024 · 4 comments · Fixed by #127
Labels
bug Something isn't working

Comments

@sasanjac
Copy link

In core.py, only forms that don't have a __qualname__ attribute are not considered models:

def _add_if_model(self, model: type, recurse: bool) -> bool:
        """Private recursive method to add a model to the diagram."""
        try:
            key = str(FullyQualifiedName.from_object(model))
        except AttributeError as e:
            # May get typing special forms that don't have __qualname__ attribute
            # These are not going to be models
            if "__qualname__" in str(e):
                return False
            raise

However, e.g. when using ellipsis for type annotations, the error is as follows: AttributeError: 'ellipsis' object has no attribute '__module__'. Did you mean: '__reduce__'?

Maybe consider checking for more terms in the error message in order to catch non-modules?

@jayqi
Copy link
Member

jayqi commented Sep 14, 2024

Hi @sasanjac, sorry for the slow response here.

I was able to reproduce your error with a model like this:

    class EllipsisModel(pydantic.BaseModel):
        ellipsis_field: Tuple[int, ...]

Can you confirm if this covers the kinds of annotations you're using with ellipsis, or do you have other kinds of examples?

@jayqi
Copy link
Member

jayqi commented Sep 19, 2024

Hi @sasanjac @SebastianDD,

The fix for this has been released in v1.0.5. Please let me know whether or not this resolves your errors!

@SebastianDD
Copy link

Hi @sasanjac @SebastianDD,

The fix for this has been released in v1.0.5. Please let me know whether or not this resolves your errors!

Thanks for the notice. We will check this.

I have one addtional question, you may could answer: Asumming a pydantic class structure, is it possible to exclude classes? I know its possible to definde end-points via terminal_models, but in our case each class have an attribute of type "AttributeData", which we want to disable when drawing the diagram.
Thanks in advance.

@jayqi
Copy link
Member

jayqi commented Sep 23, 2024

I made a separate issue to address the question about exclusions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants