Skip to content

DefaultEventLoopPolicy is not valid as a type / base class #7452

Closed
@henryiii

Description

@henryiii

The following code fails mypy tmp.py:

import asyncio

class MyEventLoopPolicy(asyncio.DefaultEventLoopPolicy):
    pass

with:

tmp.py:3: error: Variable "asyncio.DefaultEventLoopPolicy" is not valid as a type
tmp.py:3: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
tmp.py:3: error: Invalid base class "asyncio.DefaultEventLoopPolicy"
Found 2 errors in 1 file (checked 1 source file)

This MWE is copied from the Python docs here: https://docs.python.org/3/library/asyncio-policy.html#custom-policies.

Maybe this is because of the assignment here:

class _UnixDefaultEventLoopPolicy(BaseDefaultEventLoopPolicy):
def get_child_watcher(self) -> AbstractChildWatcher: ...
def set_child_watcher(self, watcher: AbstractChildWatcher | None) -> None: ...
SelectorEventLoop = _UnixSelectorEventLoop
DefaultEventLoopPolicy = _UnixDefaultEventLoopPolicy
?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions