pybind / pybind11

Seamless operability between C++11 and Python
https://pybind11.readthedocs.io/
Other
15.08k stars 2.05k forks source link

feat(types): adds support for Never and NoReturn from python Typing #5193

Closed InvincibleRMC closed 3 days ago

InvincibleRMC commented 3 days ago

Description

Adds support for Never and NoReturn.

Allows support for annotating functions that do not return. It is typically used in superclass that do not implement functions.

class Foo:

   def func() -> Never:
         raise Exception()

   def func2() -> NoReturn:
         raise Exception()

class Bar(Foo):

    def func() -> int:
          return 3
    def func2() -> int:
          return 3

Suggested changelog entry:

  Adds support for `typing.Never` and `typing.NoReturn`.