Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
use type() in int validator #264
This fixes an issue I would not expect where if you pass
Related issue number
I didn't see any.
pydantic cares about performance, if there's any risk performance changed on this PR,
@@ Coverage Diff @@ ## master #264 +/- ## =========================================== - Coverage 100% 81.14% -18.86% =========================================== Files 11 11 Lines 1480 1824 +344 Branches 274 274 =========================================== Hits 1480 1480 - Misses 0 344 +344
Looks good, my only question is what happens with the following:
class MyInt(int): pass class FooModel(BaseModel): v: MyInt
I would expect it to be validated as an int. More dangerous: people could already have code like this.
Maybe safter to have:
def int_validator(v) -> int: if not isinstance(v, bool) and isinstance(v, int): return v