Browse Source

💚 Revert to flit install and re-format

As it has shown to be more reliable, and closer to final user environments
pull/11/head
Sebastián Ramírez 6 years ago
parent
commit
7da9625505
  1. 4
      .travis.yml
  2. 3
      docs/tutorial/src/body/tutorial001.py
  3. 3
      docs/tutorial/src/body/tutorial002.py
  4. 3
      docs/tutorial/src/body/tutorial003.py
  5. 3
      docs/tutorial/src/body/tutorial004.py
  6. 3
      docs/tutorial/src/body_multiple_params/tutorial001.py
  7. 3
      docs/tutorial/src/body_multiple_params/tutorial002.py
  8. 3
      docs/tutorial/src/body_multiple_params/tutorial003.py
  9. 3
      docs/tutorial/src/body_multiple_params/tutorial004.py
  10. 3
      docs/tutorial/src/body_multiple_params/tutorial005.py
  11. 3
      docs/tutorial/src/body_nested_models/tutorial001.py
  12. 3
      docs/tutorial/src/body_nested_models/tutorial002.py
  13. 3
      docs/tutorial/src/body_nested_models/tutorial003.py
  14. 3
      docs/tutorial/src/body_nested_models/tutorial004.py
  15. 3
      docs/tutorial/src/body_nested_models/tutorial005.py
  16. 3
      docs/tutorial/src/body_nested_models/tutorial006.py
  17. 3
      docs/tutorial/src/body_nested_models/tutorial007.py
  18. 3
      docs/tutorial/src/body_nested_models/tutorial008.py
  19. 3
      docs/tutorial/src/body_schema/tutorial001.py
  20. 3
      docs/tutorial/src/body_schema/tutorial002.py
  21. 3
      docs/tutorial/src/custom_response/tutorial001.py
  22. 3
      docs/tutorial/src/custom_response/tutorial002.py
  23. 3
      docs/tutorial/src/custom_response/tutorial003.py
  24. 3
      docs/tutorial/src/custom_response/tutorial004.py
  25. 3
      docs/tutorial/src/dependencies/tutorial002.py
  26. 3
      docs/tutorial/src/dependencies/tutorial003.py
  27. 3
      docs/tutorial/src/dependencies/tutorial004.py
  28. 3
      docs/tutorial/src/extra_models/tutorial001.py
  29. 3
      docs/tutorial/src/extra_models/tutorial002.py
  30. 2
      docs/tutorial/src/nosql_databases/tutorial001.py
  31. 3
      docs/tutorial/src/path_operation_configuration/tutorial001.py
  32. 3
      docs/tutorial/src/path_operation_configuration/tutorial002.py
  33. 3
      docs/tutorial/src/path_operation_configuration/tutorial003.py
  34. 3
      docs/tutorial/src/path_operation_configuration/tutorial004.py
  35. 3
      docs/tutorial/src/path_operation_configuration/tutorial005.py
  36. 3
      docs/tutorial/src/response_model/tutorial001.py
  37. 3
      docs/tutorial/src/response_model/tutorial002.py
  38. 3
      docs/tutorial/src/response_model/tutorial003.py
  39. 3
      docs/tutorial/src/security/tutorial002.py
  40. 5
      docs/tutorial/src/security/tutorial003.py
  41. 5
      docs/tutorial/src/security/tutorial004.py
  42. 1
      docs/tutorial/src/sql_databases/tutorial001.py
  43. 7
      fastapi/applications.py
  44. 3
      fastapi/dependencies/models.py
  45. 9
      fastapi/dependencies/utils.py
  46. 13
      fastapi/openapi/utils.py
  47. 9
      fastapi/routing.py
  48. 3
      fastapi/security/api_key.py
  49. 3
      fastapi/security/http.py
  50. 5
      fastapi/security/oauth2.py
  51. 3
      fastapi/security/open_id_connect_url.py
  52. 5
      fastapi/utils.py
  53. 10
      scripts/test.sh
  54. 7
      tests/main_old.py

4
.travis.yml

@ -7,8 +7,8 @@ python:
- "3.7-dev"
install:
- pip install pipenv
- pipenv install --dev
- pip install flit
- flit install
script:
- bash scripts/test.sh

3
docs/tutorial/src/body/tutorial001.py

@ -1,6 +1,5 @@
from pydantic import BaseModel
from fastapi import FastAPI
from pydantic import BaseModel
class Item(BaseModel):

3
docs/tutorial/src/body/tutorial002.py

@ -1,6 +1,5 @@
from pydantic import BaseModel
from fastapi import FastAPI
from pydantic import BaseModel
class Item(BaseModel):

3
docs/tutorial/src/body/tutorial003.py

@ -1,6 +1,5 @@
from pydantic import BaseModel
from fastapi import FastAPI
from pydantic import BaseModel
class Item(BaseModel):

3
docs/tutorial/src/body/tutorial004.py

@ -1,6 +1,5 @@
from pydantic import BaseModel
from fastapi import FastAPI
from pydantic import BaseModel
class Item(BaseModel):

3
docs/tutorial/src/body_multiple_params/tutorial001.py

@ -1,6 +1,5 @@
from pydantic import BaseModel
from fastapi import FastAPI, Path
from pydantic import BaseModel
app = FastAPI()

3
docs/tutorial/src/body_multiple_params/tutorial002.py

@ -1,6 +1,5 @@
from pydantic import BaseModel
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()

3
docs/tutorial/src/body_multiple_params/tutorial003.py

@ -1,6 +1,5 @@
from pydantic import BaseModel
from fastapi import Body, FastAPI
from pydantic import BaseModel
app = FastAPI()

3
docs/tutorial/src/body_multiple_params/tutorial004.py

@ -1,6 +1,5 @@
from pydantic import BaseModel
from fastapi import Body, FastAPI
from pydantic import BaseModel
app = FastAPI()

3
docs/tutorial/src/body_multiple_params/tutorial005.py

@ -1,6 +1,5 @@
from pydantic import BaseModel
from fastapi import Body, FastAPI
from pydantic import BaseModel
app = FastAPI()

3
docs/tutorial/src/body_nested_models/tutorial001.py

@ -1,6 +1,5 @@
from pydantic import BaseModel
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()

3
docs/tutorial/src/body_nested_models/tutorial002.py

@ -1,8 +1,7 @@
from typing import List
from pydantic import BaseModel
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()

3
docs/tutorial/src/body_nested_models/tutorial003.py

@ -1,8 +1,7 @@
from typing import Set
from pydantic import BaseModel
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()

3
docs/tutorial/src/body_nested_models/tutorial004.py

@ -1,8 +1,7 @@
from typing import Set
from pydantic import BaseModel
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()

3
docs/tutorial/src/body_nested_models/tutorial005.py

@ -1,10 +1,9 @@
from typing import Set
from fastapi import FastAPI
from pydantic import BaseModel
from pydantic.types import UrlStr
from fastapi import FastAPI
app = FastAPI()

3
docs/tutorial/src/body_nested_models/tutorial006.py

@ -1,10 +1,9 @@
from typing import List, Set
from fastapi import FastAPI
from pydantic import BaseModel
from pydantic.types import UrlStr
from fastapi import FastAPI
app = FastAPI()

3
docs/tutorial/src/body_nested_models/tutorial007.py

@ -1,10 +1,9 @@
from typing import List, Set
from fastapi import FastAPI
from pydantic import BaseModel
from pydantic.types import UrlStr
from fastapi import FastAPI
app = FastAPI()

3
docs/tutorial/src/body_nested_models/tutorial008.py

@ -1,10 +1,9 @@
from typing import List
from fastapi import FastAPI
from pydantic import BaseModel
from pydantic.types import UrlStr
from fastapi import FastAPI
app = FastAPI()

3
docs/tutorial/src/body_schema/tutorial001.py

@ -1,6 +1,5 @@
from pydantic import BaseModel, Schema
from fastapi import Body, FastAPI
from pydantic import BaseModel, Schema
app = FastAPI()

3
docs/tutorial/src/body_schema/tutorial002.py

@ -1,6 +1,5 @@
from pydantic import BaseModel
from fastapi import Body, FastAPI
from pydantic import BaseModel
app = FastAPI()

3
docs/tutorial/src/custom_response/tutorial001.py

@ -1,6 +1,5 @@
from starlette.responses import UJSONResponse
from fastapi import FastAPI
from starlette.responses import UJSONResponse
app = FastAPI()

3
docs/tutorial/src/custom_response/tutorial002.py

@ -1,6 +1,5 @@
from starlette.responses import HTMLResponse
from fastapi import FastAPI
from starlette.responses import HTMLResponse
app = FastAPI()

3
docs/tutorial/src/custom_response/tutorial003.py

@ -1,6 +1,5 @@
from starlette.responses import HTMLResponse
from fastapi import FastAPI
from starlette.responses import HTMLResponse
app = FastAPI()

3
docs/tutorial/src/custom_response/tutorial004.py

@ -1,6 +1,5 @@
from starlette.responses import HTMLResponse
from fastapi import FastAPI
from starlette.responses import HTMLResponse
app = FastAPI()

3
docs/tutorial/src/dependencies/tutorial002.py

@ -1,6 +1,5 @@
from pydantic import BaseModel
from fastapi import Depends, FastAPI
from pydantic import BaseModel
app = FastAPI()

3
docs/tutorial/src/dependencies/tutorial003.py

@ -1,8 +1,7 @@
from typing import List
from pydantic import BaseModel
from fastapi import Cookie, Depends, FastAPI
from pydantic import BaseModel
app = FastAPI()

3
docs/tutorial/src/dependencies/tutorial004.py

@ -1,9 +1,8 @@
from random import choice
from typing import List
from pydantic import BaseModel
from fastapi import Cookie, Depends, FastAPI
from pydantic import BaseModel
app = FastAPI()

3
docs/tutorial/src/extra_models/tutorial001.py

@ -1,8 +1,7 @@
from fastapi import FastAPI
from pydantic import BaseModel
from pydantic.types import EmailStr
from fastapi import FastAPI
app = FastAPI()

3
docs/tutorial/src/extra_models/tutorial002.py

@ -1,8 +1,7 @@
from fastapi import FastAPI
from pydantic import BaseModel
from pydantic.types import EmailStr
from fastapi import FastAPI
app = FastAPI()

2
docs/tutorial/src/nosql_databases/tutorial001.py

@ -1,11 +1,11 @@
from typing import Optional
from fastapi import FastAPI
from pydantic import BaseModel
from couchbase import LOCKMODE_WAIT
from couchbase.bucket import Bucket
from couchbase.cluster import Cluster, PasswordAuthenticator
from fastapi import FastAPI
USERPROFILE_DOC_TYPE = "userprofile"

3
docs/tutorial/src/path_operation_configuration/tutorial001.py

@ -1,10 +1,9 @@
from typing import Set
from fastapi import FastAPI
from pydantic import BaseModel
from starlette.status import HTTP_201_CREATED
from fastapi import FastAPI
app = FastAPI()

3
docs/tutorial/src/path_operation_configuration/tutorial002.py

@ -1,8 +1,7 @@
from typing import Set
from pydantic import BaseModel
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()

3
docs/tutorial/src/path_operation_configuration/tutorial003.py

@ -1,8 +1,7 @@
from typing import Set
from pydantic import BaseModel
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()

3
docs/tutorial/src/path_operation_configuration/tutorial004.py

@ -1,8 +1,7 @@
from typing import Set
from pydantic import BaseModel
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()

3
docs/tutorial/src/path_operation_configuration/tutorial005.py

@ -1,8 +1,7 @@
from typing import Set
from pydantic import BaseModel
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()

3
docs/tutorial/src/response_model/tutorial001.py

@ -1,8 +1,7 @@
from typing import Set
from pydantic import BaseModel
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()

3
docs/tutorial/src/response_model/tutorial002.py

@ -1,8 +1,7 @@
from fastapi import FastAPI
from pydantic import BaseModel
from pydantic.types import EmailStr
from fastapi import FastAPI
app = FastAPI()

3
docs/tutorial/src/response_model/tutorial003.py

@ -1,8 +1,7 @@
from fastapi import FastAPI
from pydantic import BaseModel
from pydantic.types import EmailStr
from fastapi import FastAPI
app = FastAPI()

3
docs/tutorial/src/security/tutorial002.py

@ -1,9 +1,8 @@
from typing import Optional
from pydantic import BaseModel
from fastapi import Depends, FastAPI, Security
from fastapi.security import OAuth2PasswordBearer
from pydantic import BaseModel
app = FastAPI()

5
docs/tutorial/src/security/tutorial003.py

@ -1,10 +1,9 @@
from typing import Optional
from pydantic import BaseModel
from starlette.exceptions import HTTPException
from fastapi import Depends, FastAPI, Security
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from pydantic import BaseModel
from starlette.exceptions import HTTPException
fake_users_db = {
"johndoe": {

5
docs/tutorial/src/security/tutorial004.py

@ -2,15 +2,14 @@ from datetime import datetime, timedelta
from typing import Optional
import jwt
from fastapi import Depends, FastAPI, Security
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from jwt import PyJWTError
from passlib.context import CryptContext
from pydantic import BaseModel
from starlette.exceptions import HTTPException
from starlette.status import HTTP_403_FORBIDDEN
from fastapi import Depends, FastAPI, Security
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
# to get a string like this run:
# openssl rand -hex 32
SECRET_KEY = "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7"

1
docs/tutorial/src/sql_databases/tutorial001.py

@ -1,4 +1,5 @@
from fastapi import FastAPI
from sqlalchemy import Boolean, Column, Integer, String, create_engine
from sqlalchemy.ext.declarative import declarative_base, declared_attr
from sqlalchemy.orm import scoped_session, sessionmaker

7
fastapi/applications.py

@ -1,5 +1,8 @@
from typing import Any, Callable, Dict, List, Optional, Type
from fastapi import routing
from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html
from fastapi.openapi.utils import get_openapi
from pydantic import BaseModel
from starlette.applications import Starlette
from starlette.exceptions import ExceptionMiddleware, HTTPException
@ -8,10 +11,6 @@ from starlette.middleware.lifespan import LifespanMiddleware
from starlette.requests import Request
from starlette.responses import JSONResponse, Response
from fastapi import routing
from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html
from fastapi.openapi.utils import get_openapi
async def http_exception(request: Request, exc: HTTPException) -> JSONResponse:
return JSONResponse({"detail": exc.detail}, status_code=exc.status_code)

3
fastapi/dependencies/models.py

@ -1,8 +1,7 @@
from typing import Callable, List, Sequence
from pydantic.fields import Field
from fastapi.security.base import SecurityBase
from pydantic.fields import Field
param_supported_types = (str, int, float, bool)

9
fastapi/dependencies/utils.py

@ -3,6 +3,10 @@ import inspect
from copy import deepcopy
from typing import Any, Callable, Dict, List, Mapping, Sequence, Tuple, Type
from fastapi import params
from fastapi.dependencies.models import Dependant, SecurityRequirement
from fastapi.security.base import SecurityBase
from fastapi.utils import get_path_param_names
from pydantic import BaseConfig, Schema, create_model
from pydantic.error_wrappers import ErrorWrapper
from pydantic.errors import MissingError
@ -12,11 +16,6 @@ from pydantic.utils import lenient_issubclass
from starlette.concurrency import run_in_threadpool
from starlette.requests import Request
from fastapi import params
from fastapi.dependencies.models import Dependant, SecurityRequirement
from fastapi.security.base import SecurityBase
from fastapi.utils import get_path_param_names
param_supported_types = (str, int, float, bool)

13
fastapi/openapi/utils.py

@ -1,12 +1,5 @@
from typing import Any, Dict, List, Optional, Sequence, Tuple, Type
from pydantic.fields import Field
from pydantic.schema import Schema, field_schema, get_model_name_map
from pydantic.utils import lenient_issubclass
from starlette.responses import JSONResponse
from starlette.routing import BaseRoute
from starlette.status import HTTP_422_UNPROCESSABLE_ENTITY
from fastapi import routing
from fastapi.dependencies.models import Dependant
from fastapi.dependencies.utils import get_flat_dependant
@ -15,6 +8,12 @@ from fastapi.openapi.constants import METHODS_WITH_BODY, REF_PREFIX
from fastapi.openapi.models import OpenAPI
from fastapi.params import Body, Param
from fastapi.utils import get_flat_models_from_routes, get_model_definitions
from pydantic.fields import Field
from pydantic.schema import Schema, field_schema, get_model_name_map
from pydantic.utils import lenient_issubclass
from starlette.responses import JSONResponse
from starlette.routing import BaseRoute
from starlette.status import HTTP_422_UNPROCESSABLE_ENTITY
validation_error_definition = {
"title": "ValidationError",

9
fastapi/routing.py

@ -3,6 +3,10 @@ import inspect
import logging
from typing import Any, Callable, List, Optional, Type
from fastapi import params
from fastapi.dependencies.models import Dependant
from fastapi.dependencies.utils import get_body_field, get_dependant, solve_dependencies
from fastapi.encoders import jsonable_encoder
from pydantic import BaseConfig, BaseModel, Schema
from pydantic.error_wrappers import ErrorWrapper, ValidationError
from pydantic.fields import Field
@ -16,11 +20,6 @@ from starlette.responses import JSONResponse, Response
from starlette.routing import get_name, request_response
from starlette.status import HTTP_422_UNPROCESSABLE_ENTITY
from fastapi import params
from fastapi.dependencies.models import Dependant
from fastapi.dependencies.utils import get_body_field, get_dependant, solve_dependencies
from fastapi.encoders import jsonable_encoder
def serialize_response(*, field: Field = None, response: Response) -> Any:
if field:

3
fastapi/security/api_key.py

@ -1,7 +1,6 @@
from starlette.requests import Request
from fastapi.openapi.models import APIKey, APIKeyIn
from fastapi.security.base import SecurityBase
from starlette.requests import Request
class APIKeyBase(SecurityBase):

3
fastapi/security/http.py

@ -1,10 +1,9 @@
from starlette.requests import Request
from fastapi.openapi.models import (
HTTPBase as HTTPBaseModel,
HTTPBearer as HTTPBearerModel,
)
from fastapi.security.base import SecurityBase
from starlette.requests import Request
class HTTPBase(SecurityBase):

5
fastapi/security/oauth2.py

@ -1,13 +1,12 @@
from typing import List, Optional
from fastapi.openapi.models import OAuth2 as OAuth2Model, OAuthFlows as OAuthFlowsModel
from fastapi.security.base import SecurityBase
from pydantic import BaseModel, Schema
from starlette.exceptions import HTTPException
from starlette.requests import Request
from starlette.status import HTTP_403_FORBIDDEN
from fastapi.openapi.models import OAuth2 as OAuth2Model, OAuthFlows as OAuthFlowsModel
from fastapi.security.base import SecurityBase
class OAuth2PasswordRequestData(BaseModel):
grant_type: str = "password"

3
fastapi/security/open_id_connect_url.py

@ -1,7 +1,6 @@
from starlette.requests import Request
from fastapi.openapi.models import OpenIdConnect as OpenIdConnectModel
from fastapi.security.base import SecurityBase
from starlette.requests import Request
class OpenIdConnect(SecurityBase):

5
fastapi/utils.py

@ -1,14 +1,13 @@
import re
from typing import Any, Dict, List, Sequence, Set, Type
from fastapi import routing
from fastapi.openapi.constants import REF_PREFIX
from pydantic import BaseModel
from pydantic.fields import Field
from pydantic.schema import get_flat_models_from_fields, model_process_schema
from starlette.routing import BaseRoute
from fastapi import routing
from fastapi.openapi.constants import REF_PREFIX
def get_flat_models_from_routes(
routes: Sequence[Type[BaseRoute]]

10
scripts/test.sh

@ -6,13 +6,13 @@ set -x
export VERSION_SCRIPT="import sys; print('%s.%s' % sys.version_info[0:2])"
export PYTHON_VERSION=`python -c "$VERSION_SCRIPT"`
export PYTHONPATH=.:./docs/tutorial/src
export PYTHONPATH=./docs/tutorial/src
# PYTHONPATH=. pytest --cov=fastapi --cov=tests --cov-fail-under=100 --cov-report=term-missing ${@} --cov-report=html
pipenv run -- pytest --cov=fastapi --cov=tests --cov=docs/tutorial/src --cov-report=term-missing ${@} --cov-report=html
pipenv run -- mypy fastapi --disallow-untyped-defs
pytest --cov=fastapi --cov=tests --cov=docs/tutorial/src --cov-report=term-missing ${@} --cov-report=html
mypy fastapi --disallow-untyped-defs
if [ "${PYTHON_VERSION}" = '3.7' ]; then
echo "Skipping 'black' on 3.7. See issue https://github.com/ambv/black/issues/494"
else
pipenv run -- black fastapi tests --check
black fastapi tests --check
fi
pipenv run -- isort --multi-line=3 --trailing-comma --force-grid-wrap=0 --combine-as --line-width 88 --recursive --check-only fastapi tests
isort --multi-line=3 --trailing-comma --force-grid-wrap=0 --combine-as --line-width 88 --recursive --check-only fastapi tests

7
tests/main_old.py

@ -1,7 +1,3 @@
from pydantic import BaseModel
from starlette.responses import HTMLResponse, JSONResponse, PlainTextResponse
from starlette.status import HTTP_202_ACCEPTED
from fastapi import (
Body,
Cookie,
@ -20,6 +16,9 @@ from fastapi.security import (
OAuth2PasswordBearer,
OAuth2PasswordRequestForm,
)
from pydantic import BaseModel
from starlette.responses import HTMLResponse, JSONResponse, PlainTextResponse
from starlette.status import HTTP_202_ACCEPTED
from .endpoints.a import router as router_a
from .endpoints.b import router as router_b

Loading…
Cancel
Save