Skip to content

Conversation

davidhewitt
Copy link
Contributor

Change Summary

At the moment when checking for non-negative integers, we can get false-postives from types that aren't integer.

e.g. the original logic was equivalent to

>>> bool("__all__".__lt__(0)) <stdin>:1: DeprecationWarning: NotImplemented should not be used in a boolean context True

... because comparisons between strings and integers are not implemented, and the dunder method does not raise type errors on NotImplemented.

Related issue number

Fixes pydantic/pydantic#9328

Checklist

  • Unit tests for the changes exist
  • Documentation reflects the changes where applicable
  • Pydantic tests pass with this pydantic-core (except for expected changes)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers
Copy link
Contributor

@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@sydney-runkle sydney-runkle enabled auto-merge (squash) May 22, 2024 13:35
Copy link

codspeed-hq bot commented May 22, 2024

CodSpeed Performance Report

Merging #1298 will not alter performance

Comparing dh/negative-comparison (293f4c3) with main (2415f42)

Summary

✅ 155 untouched benchmarks

@sydney-runkle sydney-runkle merged commit 88a8a30 into main May 22, 2024
@sydney-runkle sydney-runkle deleted the dh/negative-comparison branch May 22, 2024 13:40
@MatthieuSarter
Copy link

Thanks for the fix 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants