Hacker News new | ask | show | jobs
by sanderjd 16 days ago
This does seem like an abstraction leak though.
1 comments

The abstraction gets leaky once you expect the distinct NewTypes to adhere to the original inheritance property. I think that's a wrong assumption from the get-go.

OP could just do:

    def foo(val: _A) -> None:
        pass
...and it'll accept both NewTypes just fine. I guess it depends on whether foo is designed to be public or private.
This works but it does not let other modules define such methods.