mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-21 19:32:13 +08:00
Remove, move or # noqa more TypeAlias declarations (#8450)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import sys
|
||||
from multiprocessing import context, reduction as reducer, synchronize
|
||||
from multiprocessing import context, reduction as reducer
|
||||
from multiprocessing.context import (
|
||||
AuthenticationError as AuthenticationError,
|
||||
BufferTooShort as BufferTooShort,
|
||||
@@ -10,12 +10,14 @@ from multiprocessing.context import (
|
||||
from multiprocessing.process import active_children as active_children, current_process as current_process
|
||||
|
||||
# These are technically functions that return instances of these Queue classes.
|
||||
# Using them as annotations is deprecated. Either use imports from
|
||||
# multiprocessing.queues or the aliases defined below. See #4266 for discussion.
|
||||
# The stub here doesn't reflect reality exactly --
|
||||
# while e.g. `multiprocessing.queues.Queue` is a class,
|
||||
# `multiprocessing.Queue` is actually a function at runtime.
|
||||
# Avoid using `multiprocessing.Queue` as a type annotation;
|
||||
# use imports from multiprocessing.queues instead.
|
||||
# See #4266 and #8450 for discussion.
|
||||
from multiprocessing.queues import JoinableQueue as JoinableQueue, Queue as Queue, SimpleQueue as SimpleQueue
|
||||
from multiprocessing.spawn import freeze_support as freeze_support
|
||||
from typing import TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from multiprocessing.process import parent_process as parent_process
|
||||
@@ -62,27 +64,6 @@ __all__ = [
|
||||
if sys.version_info >= (3, 8):
|
||||
__all__ += ["parent_process"]
|
||||
|
||||
# The following type aliases can be used to annotate the return values of
|
||||
# the corresponding functions. They are not defined at runtime.
|
||||
#
|
||||
# from multiprocessing import Lock
|
||||
# from typing import TYPE_CHECKING
|
||||
# if TYPE_CHECKING:
|
||||
# from multiprocessing import _LockType
|
||||
# lock: _LockType = Lock()
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_QueueType: TypeAlias = Queue[_T]
|
||||
_SimpleQueueType: TypeAlias = SimpleQueue[_T]
|
||||
_JoinableQueueType: TypeAlias = JoinableQueue[_T]
|
||||
_BarrierType: TypeAlias = synchronize.Barrier
|
||||
_BoundedSemaphoreType: TypeAlias = synchronize.BoundedSemaphore
|
||||
_ConditionType: TypeAlias = synchronize.Condition
|
||||
_EventType: TypeAlias = synchronize.Event
|
||||
_LockType: TypeAlias = synchronize.Lock
|
||||
_RLockType: TypeAlias = synchronize.RLock
|
||||
_SemaphoreType: TypeAlias = synchronize.Semaphore
|
||||
|
||||
# These functions (really bound methods)
|
||||
# are all autogenerated at runtime here: https://github.com/python/cpython/blob/600c65c094b0b48704d8ec2416930648052ba715/Lib/multiprocessing/__init__.py#L23
|
||||
RawValue = context._default_context.RawValue
|
||||
|
||||
Reference in New Issue
Block a user