Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add most used objects to __init__.py #2668

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions starlette/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
__version__ = "0.38.2"

from .applications import Starlette
from .middleware import Middleware
from .responses import (
HTMLResponse,
JSONResponse,
PlainTextResponse,
RedirectResponse,
Response,
StreamingResponse,
)
from .routing import Mount, Route, Router, WebSocketRoute
from .websockets import WebSocket

__all__ = (
"__version__",
"Starlette",
"Middleware",
"Response",
"HTMLResponse",
"JSONResponse",
"PlainTextResponse",
"RedirectResponse",
"StreamingResponse",
"Route",
"Router",
"Mount",
"WebSocketRoute",
"WebSocket",
)
Copy link
Member

@tomchristie tomchristie Aug 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing the complete set of documented imports here's what I've got...

from starlette.applications import Starlette
from starlette.authentication import requires, AuthCredentials, AuthenticationBackend, AuthenticationError, SimpleUser
from starlette.background import BackgroundTask
from starlette.config import environ, Config
from starlette.datastructures import Headers, MutableHeaders, Secret, URL
from starlette.endpoints import HTTPEndpoint
from starlette.exceptions import HTTPException, WebSocketException
from starlette.middleware import Middleware
from starlette.responses import Response, FileResponse, HTMLResponse, JSONResponse, PlainTextResponse, RedirectResponse, StreamingResponse
from starlette.requests import Request
from starlette.routing import Route, Mount, WebSocketRoute
from starlette.schemas import SchemaGenerator
from starlette.staticfiles import StaticFiles
from starlette.templating import Jinja2Templates
from starlette.testclient import TestClient
from starlette.websockets import WebSocket

from starlette.middleware.base import BaseHTTPMiddleware
from starlette.middleware.cors import CORSMiddleware
from starlette.middleware.gzip import GZipMiddleware
from starlette.middleware.httpsredirect import HTTPSRedirectMiddleware
from starlette.middleware.sessions import SessionMiddleware
from starlette.middleware.trustedhost import TrustedHostMiddleware

Does it make sense to include the whole set of imports here, or just the subset above?