Skip to content

Commit b2777f4

Browse files
Mark stub-only types with runtime aliases as @type_check_only in stdlib (#14717)
1 parent fa4a662 commit b2777f4

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

stdlib/asyncio/events.pyi

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -602,18 +602,25 @@ class AbstractEventLoop:
602602
@abstractmethod
603603
async def shutdown_default_executor(self) -> None: ...
604604

605-
# This class does not exist at runtime, but stubtest complains if it's marked as
606-
# @type_check_only because it has an alias that does exist at runtime. See mypy#19568.
607-
# @type_check_only
608-
class _AbstractEventLoopPolicy:
609-
@abstractmethod
610-
def get_event_loop(self) -> AbstractEventLoop: ...
611-
@abstractmethod
612-
def set_event_loop(self, loop: AbstractEventLoop | None) -> None: ...
613-
@abstractmethod
614-
def new_event_loop(self) -> AbstractEventLoop: ...
615-
# Child processes handling (Unix only).
616-
if sys.version_info < (3, 14):
605+
if sys.version_info >= (3, 14):
606+
class _AbstractEventLoopPolicy:
607+
@abstractmethod
608+
def get_event_loop(self) -> AbstractEventLoop: ...
609+
@abstractmethod
610+
def set_event_loop(self, loop: AbstractEventLoop | None) -> None: ...
611+
@abstractmethod
612+
def new_event_loop(self) -> AbstractEventLoop: ...
613+
614+
else:
615+
@type_check_only
616+
class _AbstractEventLoopPolicy:
617+
@abstractmethod
618+
def get_event_loop(self) -> AbstractEventLoop: ...
619+
@abstractmethod
620+
def set_event_loop(self, loop: AbstractEventLoop | None) -> None: ...
621+
@abstractmethod
622+
def new_event_loop(self) -> AbstractEventLoop: ...
623+
# Child processes handling (Unix only).
617624
if sys.version_info >= (3, 12):
618625
@abstractmethod
619626
@deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
@@ -627,7 +634,6 @@ class _AbstractEventLoopPolicy:
627634
@abstractmethod
628635
def set_child_watcher(self, watcher: AbstractChildWatcher) -> None: ...
629636

630-
if sys.version_info < (3, 14):
631637
AbstractEventLoopPolicy = _AbstractEventLoopPolicy
632638

633639
if sys.version_info >= (3, 14):

stdlib/builtins.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,10 +1363,8 @@ class property:
13631363
def __set__(self, instance: Any, value: Any, /) -> None: ...
13641364
def __delete__(self, instance: Any, /) -> None: ...
13651365

1366-
# This class does not exist at runtime, but stubtest complains if it's marked as
1367-
# @type_check_only because it has an alias that does exist at runtime. See mypy#19568.
1368-
# @type_check_only
13691366
@final
1367+
@type_check_only
13701368
class _NotImplementedType(Any):
13711369
__call__: None
13721370

0 commit comments

Comments
 (0)