Skip to content

Conversation

@benglewis
Copy link

@benglewis benglewis commented Jan 29, 2025

Update the validate_smart function to better identify discriminated unions by using the class with the greatest number of matching fields, in addition to the greatest percentage of matching fields.

  • Modify the validate_smart function in src/validators/union.rs to include the number of matching fields in the comparison logic.
  • Add test cases in tests/validators/test_union.py to verify the updated validate_smart function correctly identifies the class with the greatest number of matching fields.
    • Test cases cover various scenarios, including cases with equal percentages but different numbers of matching fields.
    • Include test cases with classes that inherit from one another.

For more details, open the Copilot Workspace session.

Update the `validate_smart` function to better identify discriminated unions by using the class with the greatest number of matching fields, in addition to the greatest percentage of matching fields.

* Modify the `validate_smart` function in `src/validators/union.rs` to include the number of matching fields in the comparison logic.
* Add test cases in `tests/validators/test_union.py` to verify the updated `validate_smart` function correctly identifies the class with the greatest number of matching fields.
  * Test cases cover various scenarios, including cases with equal percentages but different numbers of matching fields.
  * Include test cases with classes that inherit from one another.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/pydantic/pydantic-core?shareId=XXXX-XXXX-XXXX-XXXX).
…umber of matching fields

* Modify logic to compare the number of matching fields for each class
* Fix mismatched types error by dereferencing the borrow
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 29, 2025

CodSpeed Performance Report

Merging #1612 will not alter performance

Comparing benglewis:update-validate-smart (389b6e8) with main (0ede4d1)

Summary

✅ 157 untouched benchmarks

@benglewis benglewis closed this Jan 30, 2025
@benglewis
Copy link
Author

This doesn't seem to work. I am trying again

@benglewis benglewis deleted the update-validate-smart branch January 30, 2025 07:31
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.

1 participant