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

Fix Missing Imports #2009

Merged
merged 15 commits into from
Jul 1, 2024

Conversation

luca-knaack-webcom
Copy link
Contributor

The processed_models array stores Processed objects, which include models and their imports after being handled by the parser/base.py:parse function. However, since models are objects (passed by reference), the Processed objects and their models can be modified after creation. This can sometimes result in model changes without corresponding updates to the model imports, leading to broken Pydantic models (example is given in #2001).

This PR addresses this issue by introducing a post-processing step in the base parser's parsing method, ensuring that all necessary imports are correctly included.

Fixes #2001

Copy link

codecov bot commented Jun 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (9ac0425) to head (9e7eafb).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #2009   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           38        38           
  Lines         4188      4197    +9     
  Branches       961       967    +6     
=========================================
+ Hits          4188      4197    +9     
Flag Coverage Δ
unittests 99.66% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

codspeed-hq bot commented Jun 26, 2024

CodSpeed Performance Report

Merging #2009 will not alter performance

Comparing luca-knaack-webcom:feat/2001-missing-imports (9e7eafb) with main (9ac0425)

Summary

✅ 29 untouched benchmarks

@koxudaxi
Copy link
Owner

koxudaxi commented Jun 28, 2024

@luca-knaack-webcom
Thank you for creating the PR again.
Could you please fix the test coverage?

https://github.com/koxudaxi/datamodel-code-generator/pull/2009/files

@luca-knaack-webcom
Copy link
Contributor Author

@koxudaxi
Just performed a final code-cleanup. Everything is now covered by tests. While there is one pragma: no cover, this is still covered by those lines being covered 😅

@koxudaxi koxudaxi merged commit 031666f into koxudaxi:main Jul 1, 2024
92 checks passed
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.

Missing Imports When Model Is Changed as a Discriminator
2 participants