Skip to content

Question - how to write a stub file with missing imports? #14867

@lev-blit

Description

@lev-blit

I'm working on adding engineio to typeshed, and in its source code there is a file which imports from eventlet without a guard - https://github.com/miguelgrinberg/python-engineio/blob/main/src/engineio/async_drivers/eventlet.py#L1-L3.
the guard is in another part of the code - https://github.com/miguelgrinberg/python-engineio/blob/main/src/engineio/base_server.py#L82-L92

eventlet isn't even an optional dependency of engineio, but if it's installed and configured properly then the user's code can use engineio's eventlet driver

how should I approach this in the stub file of engineio/async_drivers/eventlet.pyi? I can't import from eventlet since it's not a dependency, but I also can't define the class WebSocketWSGI which inherits from the import eventlet.websocket.WebSocketWSGI

one possibility I've though of is to write a protocol which behaves like eventlet.websocket.WebSocketWSGI but that doesn't seem like the best approach...

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