-
-
Notifications
You must be signed in to change notification settings - Fork 898
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
Conversation
Held back on that as wanted to encourage a consistent import style, the concise imports are nice tho. 👍 |
"Mount", | ||
"WebSocketRoute", | ||
"WebSocket", | ||
) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only con of this is that it increases import time for cases where you only use a subset of the types/features which I feel like goes against Starlette's positioning as a toolking as opposed to a framework.
That's a good point. |
@tomchristie Is there a reason for not doing this?