From 34c91be7e4877f57e24a8eedfb9650502f5d3e8e Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 14 Nov 2021 02:45:49 +0000 Subject: [PATCH] Add `@final` to `NotImplementedType` and `ellipsis` (#6291) These aren't subclassable at runtime. (Missed these two in my previous PR due to the fact that they're exposed in the `types` module, rather than builtins, at runtime. Also they're both a little weird to say the least, so let's see what the CI thinks...) --- stdlib/builtins.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 324f5a5a0..6bc58d2a4 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -979,6 +979,7 @@ class property(object): def __set__(self, __obj: Any, __value: Any) -> None: ... def __delete__(self, __obj: Any) -> None: ... +@final class _NotImplementedType(Any): # type: ignore # A little weird, but typing the __call__ as NotImplemented makes the error message # for NotImplemented() much better @@ -1440,6 +1441,7 @@ def __import__( # Actually the type of Ellipsis is , but since it's # not exposed anywhere under that name, we make it private here. +@final class ellipsis: ... Ellipsis: ellipsis