opensearch-project / opensearch-py

Python Client for OpenSearch
https://opensearch.org/docs/latest/clients/python/
Apache License 2.0
359 stars 178 forks source link

Allow the use of percent string in Bool.__and__ method #780

Closed Godefroy-Amaury closed 3 months ago

Godefroy-Amaury commented 4 months ago

Description

Allow the use of 50, "50" or "50%" as valid value for qx._min_should_match/min_should_match in the Bool.__and__ method.

Previously, if for any reason the qx._min_should_match was a string, a TypeError error was raise by the if len(qx.should) <= min_should_match:.

Still raise a ValueError if the given value is an invalid integer representation.

Issues Resolved

Closes #779

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check here.

dblock commented 4 months ago

Thanks! Add a test and a CHANGELOG entry, please?

It would be amazing if you could please look at https://github.com/opensearch-project/opensearch-api-specification as well and add tests there for this and other use-cases so we don't lose this functionality as we move towards more of this code being generated.

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 70.69%. Comparing base (ba715b9) to head (b786504). Report is 42 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #780 +/- ## ========================================== - Coverage 71.95% 70.69% -1.26% ========================================== Files 91 105 +14 Lines 8001 8621 +620 ========================================== + Hits 5757 6095 +338 - Misses 2244 2526 +282 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

dblock commented 3 months ago

Thanks for fixing this!