Browse Source

🎨 Remove un-used imports, add auto-flake

pull/11/head
Sebastián Ramírez 6 years ago
parent
commit
d9fbead646
  1. 10
      fastapi/dependencies/models.py
  2. 1
      fastapi/openapi/models.py
  3. 4
      fastapi/openapi/utils.py
  4. 5
      scripts/lint.sh
  5. 5
      tests/main.py
  6. 1
      tests/test_security.py

10
fastapi/dependencies/models.py

@ -1,13 +1,7 @@
from typing import Any, Callable, Dict, List, Sequence, Tuple from typing import Callable, List, Sequence
from fastapi.security.base import SecurityBase from fastapi.security.base import SecurityBase
from pydantic import BaseConfig, Schema from pydantic.fields import Field
from pydantic.error_wrappers import ErrorWrapper
from pydantic.errors import MissingError
from pydantic.fields import Field, Required
from pydantic.schema import get_annotation_from_schema
from starlette.concurrency import run_in_threadpool
from starlette.requests import Request
param_supported_types = (str, int, float, bool) param_supported_types = (str, int, float, bool)

1
fastapi/openapi/models.py

@ -6,7 +6,6 @@ from pydantic import BaseModel, Schema as PSchema
from pydantic.types import UrlStr from pydantic.types import UrlStr
try: try:
import email_validator
from pydantic.types import EmailStr # type: ignore from pydantic.types import EmailStr # type: ignore
except ImportError: except ImportError:
logging.warning( logging.warning(

4
fastapi/openapi/utils.py

@ -11,8 +11,8 @@ from fastapi.utils import get_flat_models_from_routes, get_model_definitions
from pydantic.fields import Field from pydantic.fields import Field
from pydantic.schema import Schema, field_schema, get_model_name_map from pydantic.schema import Schema, field_schema, get_model_name_map
from pydantic.utils import lenient_issubclass from pydantic.utils import lenient_issubclass
from starlette.responses import HTMLResponse, JSONResponse from starlette.responses import JSONResponse
from starlette.routing import BaseRoute, Route from starlette.routing import BaseRoute
from starlette.status import HTTP_422_UNPROCESSABLE_ENTITY from starlette.status import HTTP_422_UNPROCESSABLE_ENTITY
validation_error_definition = { validation_error_definition = {

5
scripts/lint.sh

@ -1,5 +1,6 @@
#!/bin/sh -e #!/bin/sh -e
set -x set -x
black fastapi tests autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place docs/tutorial/src/ fastapi tests --exclude=__init__.py
isort --multi-line=3 --trailing-comma --force-grid-wrap=0 --combine-as --line-width 88 --recursive --apply fastapi tests black fastapi tests docs/tutorial/src
isort --multi-line=3 --trailing-comma --force-grid-wrap=0 --combine-as --line-width 88 --recursive --apply fastapi tests docs/tutorial/src

5
tests/main.py

@ -1,6 +1,3 @@
from typing import Optional
import fastapi
from fastapi import ( from fastapi import (
Body, Body,
Cookie, Cookie,
@ -20,10 +17,8 @@ from fastapi.security import (
OAuth2PasswordRequestForm, OAuth2PasswordRequestForm,
) )
from pydantic import BaseModel from pydantic import BaseModel
from starlette.exceptions import HTTPException
from starlette.responses import HTMLResponse, JSONResponse, PlainTextResponse from starlette.responses import HTMLResponse, JSONResponse, PlainTextResponse
from starlette.status import HTTP_202_ACCEPTED from starlette.status import HTTP_202_ACCEPTED
from starlette.testclient import TestClient
from .endpoints.a import router as router_a from .endpoints.a import router as router_a
from .endpoints.b import router as router_b from .endpoints.b import router as router_b

1
tests/test_security.py

@ -1,4 +1,3 @@
import pytest
from starlette.testclient import TestClient from starlette.testclient import TestClient
from .main import app from .main import app

Loading…
Cancel
Save