emmett-framework / granian

A Rust HTTP server for Python applications
BSD 3-Clause "New" or "Revised" License
2.86k stars 83 forks source link

Explicitly re-rexport Granian in `__init__.py` #215

Closed RafaelWO closed 8 months ago

RafaelWO commented 8 months ago

Background

To debug Python ASGI apps it is common to add some code to your main.py file which could look as follows:

if __name__ == "__main__":
    import granian

    granian.Granian("app.main:app", port=8000, interface="asgi", reload=True).serve()

While this works perfectly, one now gets an error when running mypy:

error: Module "granian" does not explicitly export attribute "Granian"  [attr-defined]

See also the mypy docs on this error.

PR Description

This PR attempts to fix this error by explicitly re-export the class Granian within the __init__.py file. (AFAIS FastAPI does it the same way.)


P.S. Thanks for the great work on this project! :rocket:

gi0baro commented 8 months ago

@RafaelWO thank you for your contribution ❤️