Correctly place teal imports

This commit is contained in:
Xavier Bustamante Talavera 2018-09-07 12:38:02 +02:00
parent ca7c89633b
commit 804a696390
30 changed files with 58 additions and 53 deletions

View file

@ -1,9 +1,9 @@
from sqlalchemy.exc import DataError
from teal.auth import TokenAuth
from teal.db import ResourceNotFound
from werkzeug.exceptions import Unauthorized
from ereuse_devicehub.resources.user.models import User
from teal.auth import TokenAuth
from teal.db import ResourceNotFound
class Auth(TokenAuth):

View file

@ -1,13 +1,13 @@
from inspect import isclass
from typing import Any, Dict, Iterable, Tuple, Type, Union
from ereuse_utils.test import JSON
from flask import Response
from teal.client import Client as TealClient
from teal.marshmallow import ValidationError
from werkzeug.exceptions import HTTPException
from ereuse_devicehub.resources import models, schemas
from ereuse_utils.test import JSON
from teal.client import Client as TealClient
from teal.marshmallow import ValidationError
class Client(TealClient):

View file

@ -2,13 +2,14 @@ from distutils.version import StrictVersion
from itertools import chain
from typing import Set
from ereuse_devicehub.resources import agent, device, event, inventory, lot, tag, user
from ereuse_devicehub.resources.enums import PriceSoftware, RatingSoftware
from teal.auth import TokenAuth
from teal.config import Config
from teal.enums import Currency
from teal.utils import import_resource
from ereuse_devicehub.resources import agent, device, event, inventory, lot, tag, user
from ereuse_devicehub.resources.enums import PriceSoftware, RatingSoftware
class DevicehubConfig(Config):
RESOURCE_DEFINITIONS = set(chain(import_resource(device),

View file

@ -1,13 +1,13 @@
from typing import Type
from flask_sqlalchemy import SQLAlchemy
from teal.config import Config as ConfigClass
from teal.teal import Teal
from ereuse_devicehub.auth import Auth
from ereuse_devicehub.client import Client
from ereuse_devicehub.db import db
from ereuse_devicehub.dummy.dummy import Dummy
from teal.config import Config as ConfigClass
from teal.teal import Teal
class Devicehub(Teal):

View file

@ -1,9 +1,9 @@
from marshmallow.fields import missing_
from ereuse_devicehub.db import db
from teal.db import SQLAlchemy
from teal.marshmallow import NestedOn as TealNestedOn
from ereuse_devicehub.db import db
class NestedOn(TealNestedOn):
__doc__ = TealNestedOn.__doc__

View file

@ -1,10 +1,10 @@
import click
from flask import current_app as app
from teal.db import SQLAlchemy
from teal.resource import Converters, Resource
from ereuse_devicehub.db import db
from ereuse_devicehub.resources.agent import models, schemas
from teal.db import SQLAlchemy
from teal.resource import Converters, Resource
class AgentDef(Resource):

View file

@ -8,13 +8,13 @@ from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.orm import backref, relationship
from sqlalchemy_utils import EmailType, PhoneNumberType
from ereuse_devicehub.resources.models import STR_SIZE, STR_SM_SIZE, Thing
from ereuse_devicehub.resources.user.models import User
from teal import enums
from teal.db import INHERIT_COND, POLYMORPHIC_ID, \
POLYMORPHIC_ON
from ereuse_devicehub.resources.models import STR_SIZE, STR_SM_SIZE, Thing
from ereuse_devicehub.resources.user.models import User
class JoinedTableMixin:
# noinspection PyMethodParameters

View file

@ -4,12 +4,12 @@ from typing import List, Set
from sqlalchemy import Column
from sqlalchemy.orm import relationship
from sqlalchemy_utils import PhoneNumber
from teal import enums
from ereuse_devicehub.resources.event.models import Event, Trade
from ereuse_devicehub.resources.models import Thing
from ereuse_devicehub.resources.tag.model import Tag
from ereuse_devicehub.resources.user import User
from teal import enums
class Agent(Thing):
@ -40,7 +40,7 @@ class Organization(Agent):
def __init__(self, name: str, **kwargs):
super().__init__(**kwargs)
self.members = ... # type: Set[Membership]
self.tags = ... # type: Set[Tag]
self.tags = ... # type: Set[Tag]
@classmethod
def get_default_org_id(cls) -> uuid.UUID:

View file

@ -1,11 +1,11 @@
from marshmallow import fields as ma_fields, validate as ma_validate
from marshmallow.fields import Email
from teal import enums
from teal.marshmallow import EnumField, Phone
from ereuse_devicehub.marshmallow import NestedOn
from ereuse_devicehub.resources.models import STR_SIZE, STR_SM_SIZE
from ereuse_devicehub.resources.schemas import Thing
from teal import enums
from teal.marshmallow import EnumField, Phone
class Agent(Thing):

View file

@ -1,6 +1,7 @@
from teal.resource import Converters, Resource
from ereuse_devicehub.resources.device import schemas
from ereuse_devicehub.resources.device.views import DeviceView
from teal.resource import Converters, Resource
class DeviceDef(Resource):

View file

@ -3,6 +3,7 @@ from itertools import chain
from operator import attrgetter
from typing import Dict, Set
from ereuse_utils.naming import Naming
from sqlalchemy import BigInteger, Boolean, Column, Enum as DBEnum, Float, ForeignKey, Integer, \
Sequence, SmallInteger, Unicode, inspect
from sqlalchemy.ext.declarative import declared_attr
@ -10,13 +11,12 @@ from sqlalchemy.orm import ColumnProperty, backref, relationship, validates
from sqlalchemy.util import OrderedSet
from sqlalchemy_utils import ColorType
from stdnum import imei, meid
from teal.db import CASCADE, POLYMORPHIC_ID, POLYMORPHIC_ON, ResourceNotFound, check_range
from teal.marshmallow import ValidationError
from ereuse_devicehub.resources.enums import ComputerChassis, DataStorageInterface, DisplayTech, \
RamFormat, RamInterface
from ereuse_devicehub.resources.models import STR_BIG_SIZE, STR_SIZE, STR_SM_SIZE, Thing
from ereuse_utils.naming import Naming
from teal.db import CASCADE, POLYMORPHIC_ID, POLYMORPHIC_ON, ResourceNotFound, check_range
from teal.marshmallow import ValidationError
class Device(Thing):

View file

@ -26,7 +26,7 @@ class Device(Thing):
height = ... # type: Column
depth = ... # type: Column
color = ... # type: Column
parents = ... # type: relationship
parents = ... # type: relationship
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
@ -47,7 +47,7 @@ class Device(Thing):
self.events_one = ... # type: Set[EventWithOneDevice]
self.images = ... # type: ImageList
self.tags = ... # type: Set[Tag]
self.parents = ... # type: Set[Lot]
self.parents = ... # type: Set[Lot]
class DisplayMixin:

View file

@ -3,6 +3,7 @@ from marshmallow.fields import Boolean, Float, Integer, Str
from marshmallow.validate import Length, OneOf, Range
from sqlalchemy.util import OrderedSet
from stdnum import imei, meid
from teal.marshmallow import EnumField, ValidationError
from ereuse_devicehub.marshmallow import NestedOn
from ereuse_devicehub.resources.device import models as m
@ -10,7 +11,6 @@ from ereuse_devicehub.resources.enums import ComputerChassis, DataStorageInterfa
RamFormat, RamInterface
from ereuse_devicehub.resources.models import STR_BIG_SIZE, STR_SIZE
from ereuse_devicehub.resources.schemas import Thing, UnitCodes
from teal.marshmallow import EnumField, ValidationError
class Device(Thing):

View file

@ -5,14 +5,14 @@ from typing import Iterable, Set
from sqlalchemy import inspect
from sqlalchemy.exc import IntegrityError
from sqlalchemy.util import OrderedSet
from teal.db import ResourceNotFound
from teal.marshmallow import ValidationError
from ereuse_devicehub.db import db
from ereuse_devicehub.resources.device.exceptions import NeedsId
from ereuse_devicehub.resources.device.models import Component, Computer, Device
from ereuse_devicehub.resources.event.models import Remove
from ereuse_devicehub.resources.tag.model import Tag
from teal.db import ResourceNotFound
from teal.marshmallow import ValidationError
class Sync:

View file

@ -1,6 +1,7 @@
from ereuse_devicehub.resources.device.models import Device
from teal.resource import View
from ereuse_devicehub.resources.device.models import Device
class DeviceView(View):

View file

@ -1,9 +1,10 @@
from typing import Callable, Iterable, Tuple
from teal.resource import Converters, Resource
from ereuse_devicehub.resources.device.sync import Sync
from ereuse_devicehub.resources.event import schemas
from ereuse_devicehub.resources.event.views import EventView, SnapshotView
from teal.resource import Converters, Resource
class EventDef(Resource):

View file

@ -9,6 +9,9 @@ from boltons.urlutils import URL
from sqlalchemy import Column
from sqlalchemy.orm import relationship
from sqlalchemy_utils import Currency
from teal import enums
from teal.db import Model
from teal.enums import Country
from ereuse_devicehub.resources.agent.models import Agent
from ereuse_devicehub.resources.device.models import Component, Computer, Device
@ -18,9 +21,6 @@ from ereuse_devicehub.resources.enums import AppearanceRange, Bios, Functionalit
from ereuse_devicehub.resources.image.models import Image
from ereuse_devicehub.resources.models import Thing
from ereuse_devicehub.resources.user.models import User
from teal import enums
from teal.db import Model
from teal.enums import Country
class Event(Thing):

View file

@ -6,6 +6,9 @@ from marshmallow.fields import Boolean, DateTime, Decimal, Float, Integer, List,
TimeDelta, URL, UUID
from marshmallow.validate import Length, Range
from sqlalchemy.util import OrderedSet
from teal.enums import Country, Currency, Subdivision
from teal.marshmallow import EnumField, IP, Version
from teal.resource import Schema
from ereuse_devicehub.marshmallow import NestedOn
from ereuse_devicehub.resources.agent.schemas import Agent
@ -17,9 +20,6 @@ from ereuse_devicehub.resources.event import models as m
from ereuse_devicehub.resources.models import STR_BIG_SIZE, STR_SIZE
from ereuse_devicehub.resources.schemas import Thing
from ereuse_devicehub.resources.user.schemas import User
from teal.enums import Country, Currency, Subdivision
from teal.marshmallow import EnumField, IP, Version
from teal.resource import Schema
class Event(Thing):

View file

@ -4,12 +4,12 @@ from sqlalchemy import BigInteger, Column, Enum as DBEnum, ForeignKey, Unicode
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import backref, relationship
from sqlalchemy.util import OrderedSet
from teal.db import CASCADE_OWN
from ereuse_devicehub.db import db
from ereuse_devicehub.resources.device.models import Device
from ereuse_devicehub.resources.enums import ImageMimeTypes, Orientation
from ereuse_devicehub.resources.models import STR_BIG_SIZE, Thing
from teal.db import CASCADE_OWN
class ImageList(Thing):

View file

@ -4,14 +4,14 @@ from marshmallow import Schema as MarshmallowSchema
from marshmallow.fields import Float, Integer, Nested, Str
from marshmallow.validate import Range
from sqlalchemy import Column
from teal.query import Between, FullTextSearch, ILike, Join, Or, Query, Sort, SortField
from teal.resource import Resource, View
from ereuse_devicehub.resources.device.models import Device
from ereuse_devicehub.resources.event.models import Rate
from ereuse_devicehub.resources.lot.models import Lot
from ereuse_devicehub.resources.schemas import Thing
from ereuse_devicehub.resources.tag import Tag
from teal.query import Between, FullTextSearch, ILike, Join, Or, Query, Sort, SortField
from teal.resource import Resource, View
class Inventory(Thing):

View file

@ -1,9 +1,10 @@
import pathlib
from teal.resource import Converters, Resource
from ereuse_devicehub.db import db
from ereuse_devicehub.resources.lot import schemas
from ereuse_devicehub.resources.lot.views import LotView
from teal.resource import Converters, Resource
class LotDef(Resource):

View file

@ -15,7 +15,7 @@ class Lot(Thing):
name = ... # type: Column
closed = ... # type: Column
devices = ... # type: relationship
paths = ... # type: relationship
paths = ... # type: relationship
def __init__(self, name: str, closed: bool = closed.default.arg) -> None:
super().__init__()

View file

@ -1,10 +1,10 @@
import uuid
from flask import current_app as app, request
from teal.resource import View
from ereuse_devicehub.db import db
from ereuse_devicehub.resources.lot.models import Lot
from teal.resource import View
class LotView(View):

View file

@ -2,9 +2,9 @@ from enum import Enum
from marshmallow import post_load
from marshmallow.fields import DateTime, List, String, URL
from teal.resource import Schema
from ereuse_devicehub.resources import models as m
from teal.resource import Schema
class UnitCodes(Enum):

View file

@ -1,13 +1,13 @@
from typing import Tuple
from click import argument, option
from teal.resource import Resource
from teal.teal import Teal
from ereuse_devicehub.db import db
from ereuse_devicehub.resources.tag import schema
from ereuse_devicehub.resources.tag.model import Tag
from ereuse_devicehub.resources.tag.view import TagView, get_device_from_tag
from teal.resource import Resource
from teal.teal import Teal
class TagDef(Resource):

View file

@ -1,12 +1,12 @@
from sqlalchemy import BigInteger, Column, ForeignKey, Unicode, UniqueConstraint
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import backref, relationship, validates
from teal.db import DB_CASCADE_SET_NULL, URL
from teal.marshmallow import ValidationError
from ereuse_devicehub.resources.agent.models import Organization
from ereuse_devicehub.resources.device.models import Device
from ereuse_devicehub.resources.models import Thing
from teal.db import DB_CASCADE_SET_NULL, URL
from teal.marshmallow import ValidationError
class Tag(Thing):

View file

@ -1,9 +1,9 @@
from marshmallow.fields import String
from teal.marshmallow import URL
from ereuse_devicehub.marshmallow import NestedOn
from ereuse_devicehub.resources.device.schemas import Device
from ereuse_devicehub.resources.schemas import Thing
from teal.marshmallow import URL
class Tag(Thing):

View file

@ -1,11 +1,11 @@
from flask import Response, current_app as app, request
from marshmallow.fields import List, String, URL
from teal.marshmallow import ValidationError
from teal.resource import Schema, View
from webargs.flaskparser import parser
from ereuse_devicehub.resources.device.models import Device
from ereuse_devicehub.resources.tag import Tag
from teal.marshmallow import ValidationError
from teal.resource import Schema, View
class TagView(View):

View file

@ -1,10 +1,10 @@
from click import argument, option
from teal.resource import Converters, Resource
from ereuse_devicehub.db import db
from ereuse_devicehub.resources.user import schemas
from ereuse_devicehub.resources.user.models import User
from ereuse_devicehub.resources.user.views import UserView, login
from teal.resource import Converters, Resource
class UserDef(Resource):

View file

@ -1,11 +1,11 @@
from uuid import UUID
from flask import g, request
from teal.resource import View
from ereuse_devicehub.resources.user.exceptions import WrongCredentials
from ereuse_devicehub.resources.user.models import User
from ereuse_devicehub.resources.user.schemas import User as UserS
from teal.resource import View
class UserView(View):