3 comments

[ 0.25 ms ] story [ 15.4 ms ] thread
If you're like me, you don't want to wait for 3.15 to get it's features. Enjoy!
Nice! I've a sentinel for my own project, but it's a simple

  class Default:
    def __repr__(self):
      return "<use default>")
  default = Default()
so I need to do:

  def f(a: Union[int, None, Default] = default):
    if a is default:
      ..
to get the typing right, from 3.10 onward.

Why I saw the info about the new sentinel, I wondered how they could manage using a '|default' with simply the sentinel. I see from your code's _union() that it's a bit tricky to make 3.10 even support Union[int, None, default].

Thanks for mentioning this!