Skip to content

Pydantic Models + Type Validation + uv Build#11

Open
thekaushikls wants to merge 17 commits into
paireks:masterfrom
thekaushikls:upstream
Open

Pydantic Models + Type Validation + uv Build#11
thekaushikls wants to merge 17 commits into
paireks:masterfrom
thekaushikls:upstream

Conversation

@thekaushikls
Copy link
Copy Markdown

Summary

  • Migrated all classes (Color, Vector, Rotation, Mesh, Element, File) to Pydantic BaseModel to leverage type validation
  • Replaced jsonpickle with Pydantic serialization (model_dump_json / model_validate)
  • Replaced setup.py / setup.cfg with pyproject.toml + hatchling
  • Moved package management from pip to uv
  • Added CI workflow for code quality (ruff)
  • Moved package to src/ layout
  • Split source into primitives.py and composites.py

Breaking changes

  • Requires Python 3.11+
  • Constructors raise pydantic.ValidationError on invalid input
  • Element.guid is now uuid.UUID
  • Element.info / File.info require Dict[str, str]

Issues addressed

Notes

I understand you prefer small, focused PRs. I'd be happy to break this into smaller pieces to make it easier to review. This PR is the full scope so you can see the direction; let me know how you'd like to proceed.

@paireks paireks self-requested a review May 9, 2026 09:00
@paireks
Copy link
Copy Markdown
Owner

paireks commented May 9, 2026

Hello @thekaushikls,

thank you for PR :)
I've spent some time investigating it, I haven't checked all aspects, but here are my conclusions:

This PR seems to me more like a rewrite to me looking at the number of changes, especially knowing this repository is quite small.
Current dotbimpy repository scope is the schema + Elements comparisons + plotly integration (although today I'm not sure if it's still makes sense) + some examples.
I don't know if moving from jsonpickle into Pydantic would make the library better/worse yet, because I'd have to compare both.
Ideally user could choose their favourite serialization library. I know these libraries already make this decision (e.g. here to use jsonpickle).
I think there are 2 options:

  1. Adding your package as a separate package on separate repo. I think it would be best, because then user can choose if he/she wants to depend on jsonpickle or Pydantic. I'll then refer to your repo and package in several places to help it be visible.
  2. If you prefer merging it, then I'd have to decide if this library switch makes sense. Or maybe if we should have 2 independent schemas separate in repo, one for jsonpickle another for Pydantic. But then I'd have to think how to manage both dependencies in a way it won't be overwhelming for the user.

Please let me know what you think :) Thank you once again for your input :)
Best regards,
Wojciech

@paireks paireks removed their request for review May 9, 2026 09:05
@thekaushikls
Copy link
Copy Markdown
Author

Hi Wojciech (@paireks) ,

Thank you for your comments. I agree it is a re-write, and I have tried my best to keep the current tests passing and changes very minor.

I don't know if moving from jsonpickle into Pydantic would make the library better/worse yet, because I'd have to compare both.

I haven't run any performance tests to compare which is "better", as the goal was to help with (de)serialization of dotbim elements/meshes with some quick validation. That said, it'd be a nice experiment to do some tests.

I think there are 2 options:

I like option 1 because it is a tad bit easier to maintain, and gives the end-user the flexibility to choose between the flavors. But I believe it's not completely black and white - we can decide on a later stage about merging if/when more people start using them.

Do let me know if you think otherwise.

Best,
Kaushik

@paireks
Copy link
Copy Markdown
Owner

paireks commented May 11, 2026

Hello @thekaushikls,

if you also prefer option 1 then great. Please let me know then which link to your repo and to the package should I reference, I will update documentation then with these links :)

Best regards,
Wojciech

@thekaushikls
Copy link
Copy Markdown
Author

Hi @paireks,

Here are the relevant links:

Thank you!

Best,
Kaushik

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

Successfully merging this pull request may close these issues.

2 participants