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

Using dataclass_transforms to support attrs, pydantic, etc. #26

Open
mcgfeller opened this issue Mar 22, 2022 · 6 comments
Open

Using dataclass_transforms to support attrs, pydantic, etc. #26

mcgfeller opened this issue Mar 22, 2022 · 6 comments
Labels
documentation Improvements or additions to documentation

Comments

@mcgfeller
Copy link

mcgfeller commented Mar 22, 2022

Hi - interesting project. UML is currently underestimate, IMO it gives great overviews.

I just wanted to point out to dataclass transforms - I believe it would allow to treat Pydantic, attrs, or Django models like dataclasses with little additional coding.

@lucsorel
Copy link
Owner

thank you @mcgfeller for pointing out this PEP. So just to make sure I understood the purpose of your message correctly: are you encouraging me to follow the status of this PEP so that I can implement UML documentation from any solution that follows the dataclass-transforms convention?

Or had you other ideas in mind?

@lucsorel
Copy link
Owner

and do you have any ideas about how this specification evolve? The changelog stopped a year ago.

@mcgfeller
Copy link
Author

Dear @lucsorel - exactly: If you ever wanted to support Pydantic or attrs as an alternative to dataclasses as the source for the UML documentation, following these specs may be the easiest way. Very few changes might be required; in fact, I already get quite nice results from using py2puml on Pydantic models.

The specs were already adopted in Pydantic release v1.9.0 (2021-12-31) and attrs 21.1.0 (2021-05-06). It is supported by Pyright; hence Pylance and VS Code provide type checking and code completion for these alternatives to dataclasses.

I just realized it is also officially PEP 681.

@lucsorel lucsorel added the documentation Improvements or additions to documentation label Apr 15, 2022
@Baukebrenninkmeijer
Copy link

Hi both, great to see that there is already a topic for this. To add some more info as well as a related but different request for ORM support:

  1. Pydantic seems to work for me just fine - not sure if that required specific work or came baked in with some other approach similarly to dataclasses.
  2. SQLAlchemy does not seem to be working currently. All the class definitions have no attributes unfortunately. I might have a look at how to implement that if I find the time, since I presume that SQLAlchemy would also be a desired addition in functionality.

Has there been any previous work or thoughts on adding SQLAlchemy support? @lucsorel

@lucsorel
Copy link
Owner

hi @Baukebrenninkmeijer

Has there been any previous work or thoughts on adding SQLAlchemy support?

There has been no previous work or thoughts about supporting SQLAlchemy classes, only because I have not used this framework and nobody asked for them 😃 So the topic is open: my initial goal with py2puml was to document the business domain of an application, so it would make sense to support a business domain being persisted with SQLAlchemy.

A first step towards supporting SQLAlchemy would be to create a fake business domain model to support, with the different kinds of relationships between the classes (1-1 composition, 1-n association, inheritance maybe, etc.). I have no idea about how a SQLAlchemy domain model is designed, so doing that for me with code snippets would help.

Maybe in a separate issue dedicated to SQLAlchemy? What do you think?

@Baukebrenninkmeijer
Copy link

@lucsorel Great to hear. Much value to be added then :). A separate issue might indeed be best suited, I'll create one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants