phantom-types icon indicating copy to clipboard operation
phantom-types copied to clipboard

Add `TypeGuard` to `is_formatted_phone_number`

Open flaeppe opened this issue 1 year ago • 2 comments

I added an assert_type row since it seems that you are checking types with pytest-mypy-plugins but I figured using assert_type is probably preferable

flaeppe avatar Jul 04 '24 20:07 flaeppe

Hmm, looks like something unrelated broke sized types badly, will look at it as soon as I have some time.

antonagestam avatar Jul 04 '24 21:07 antonagestam

but I figured using assert_type is probably preferable

Yup, it didn't exist back then, much better 👍

This is probably a good idea, although the circular dependency between the type definition and its predicate bothers me just slightly. The TypeGuard function will also be an optimization over going through the isinstance interface though, so definitely seems like net positive.

antonagestam avatar Jul 04 '24 21:07 antonagestam

Found minimal reproduction of the test failures, it's not related so I am merging this as is. Thanks for the contribution! 🙏

https://github.com/antonagestam/phantom-types/issues/299

antonagestam avatar Sep 15 '24 15:09 antonagestam