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
support NewType #115
Comments
Surely simpler to construct the class properly: class BossId(str):
pass That way you can easily add custom validation for If you really don't want to do that, why not use: BossId = type('BossId', str, {}) ? If for some reason this really doesn't work, I'd be happy to accept a pull request for your fix above. But we might also need extra logic so that |
Hmm, good point that NewType is designed to be cheap; while MyPy validates it, at runtime it's only a function call, and the instances it creates are the underlying type. So I think it would be ok if Pydantic treated |
humm, ok but I bet you someone in future will come back and whinge when they get confused about the type of Since your change above should have no effect on performance for other usage I'd be happy to accept a pull request for this change provided it has full coverage and documentation. |
Happy to accept a PR which supports this provided it's not to complicated.
|
* working on isintance checks * isinstance tests and remove message from errors * improve benchmarks * cleanup error methods * more tests for error cases * linting * fix error message * tweak error message * better exception strings * better exception strings
Pydantic does not seem to support NewType.
Given this code:
The code will hit an error as it's being parsed:
I currently am using Pydantic with this work around which involves monkey-patching:
The text was updated successfully, but these errors were encountered: