Skip to content

Commit 7f9a8bd

Browse files
committed
Add None-assert operator to deferred ideas
1 parent 0424689 commit 7f9a8bd

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎peps/pep-0823.rst‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,19 @@ hierarchies.
587587

588588
A workaround would be to write ``a.foo?.__call__(arguments)``.
589589

590+
``None``-assert operator
591+
------------------------
592+
593+
Some languages with "``null``-aware" operators also have a "``not-null``
594+
assertion" operator ``!``, e.g. TypeScript [#ts_non_null]_ and Dart [#dart]_.
595+
It was proposed to add a "``None``-assert" operator ``!``. This would
596+
be especially useful in typed Python code where type checkers are not
597+
able to statically deduce that a variable, with an ``optional`` (can be
598+
``None``) value, cannot be ``None`` in some contexts.
599+
600+
This PEP focuses on the ``None``-aware access operators and therefore
601+
this proposal is out of scope.
602+
590603
Add ``list.get(key)``
591604
---------------------
592605

@@ -1190,6 +1203,8 @@ Footnotes
11901203
(https://discuss.python.org/t/introducing-a-safe-navigation-operator-in-python/35480)
11911204
.. [#ts] TypeScript: Optional Chaining
11921205
(https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#optional-chaining)
1206+
.. [#ts_non_null] TypeScript: Non-null Assertion Operator
1207+
(https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#non-null-assertion-operator-postfix-)
11931208
.. [#js] JavaScript: Optional chaining (?.)
11941209
(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining)
11951210
.. [#js_short_circuiting] JavaScript: Optional chaining (?.) - Short-circuiting

0 commit comments

Comments
 (0)