Settings

Theme

Show HN: Pre Python 3.15 PEP 661 compat-sentinel

pypi.org

6 points by owebeeone · 3 comments · 1 min read

Reader

Gets around broken pythonbackport-sentinel

2 threads
eesmith

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 pointing to the project!

owebeeoneOP

If you're like me, you don't want to wait for 3.15 to get it's features. Enjoy!

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection