some cleanup
This commit is contained in:
1
.flake8
1
.flake8
@ -2,4 +2,5 @@
|
|||||||
ignore = ANN101, ANN102, W503, S101
|
ignore = ANN101, ANN102, W503, S101
|
||||||
max-complexity = 8
|
max-complexity = 8
|
||||||
max-line-length = 88
|
max-line-length = 88
|
||||||
|
import-order-style = pycharm
|
||||||
exclude = p38venv,.pytest_cache
|
exclude = p38venv,.pytest_cache
|
||||||
|
|||||||
@ -33,4 +33,5 @@ __all__ = [
|
|||||||
"ModelNotSet",
|
"ModelNotSet",
|
||||||
"MultipleMatches",
|
"MultipleMatches",
|
||||||
"NoMatch",
|
"NoMatch",
|
||||||
|
"ForeignKey",
|
||||||
]
|
]
|
||||||
|
|||||||
@ -1,18 +1,18 @@
|
|||||||
|
from orm.fields.base import BaseField
|
||||||
|
from orm.fields.foreign_key import ForeignKey
|
||||||
from orm.fields.model_fields import (
|
from orm.fields.model_fields import (
|
||||||
BigInteger,
|
BigInteger,
|
||||||
Boolean,
|
Boolean,
|
||||||
Date,
|
Date,
|
||||||
DateTime,
|
DateTime,
|
||||||
Decimal,
|
Decimal,
|
||||||
String,
|
|
||||||
Integer,
|
|
||||||
Text,
|
|
||||||
Float,
|
Float,
|
||||||
Time,
|
Integer,
|
||||||
JSON,
|
JSON,
|
||||||
|
String,
|
||||||
|
Text,
|
||||||
|
Time,
|
||||||
)
|
)
|
||||||
from orm.fields.foreign_key import ForeignKey
|
|
||||||
from orm.fields.base import BaseField
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"Decimal",
|
"Decimal",
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
from typing import Type, Any, Dict, Optional, List
|
from typing import Any, Dict, List, Optional, TYPE_CHECKING, Type
|
||||||
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
from orm import ModelDefinitionError
|
from orm import ModelDefinitionError # noqa I101
|
||||||
|
|
||||||
|
if TYPE_CHECKING: # pragma no cover
|
||||||
|
from orm.models import Model
|
||||||
|
|
||||||
|
|
||||||
class RequiredParams:
|
class RequiredParams:
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
from typing import Type, List, Any, Union, TYPE_CHECKING, Optional
|
from typing import Any, List, Optional, TYPE_CHECKING, Type, Union
|
||||||
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
import orm
|
import orm # noqa I101
|
||||||
from orm.exceptions import RelationshipInstanceError
|
from orm.exceptions import RelationshipInstanceError
|
||||||
from orm.fields.base import BaseField
|
from orm.fields.base import BaseField
|
||||||
|
|
||||||
@ -80,9 +80,7 @@ class ForeignKey(BaseField):
|
|||||||
model = create_dummy_instance(fk=self.to, pk=value)
|
model = create_dummy_instance(fk=self.to, pk=value)
|
||||||
|
|
||||||
model._orm_relationship_manager.add_relation(
|
model._orm_relationship_manager.add_relation(
|
||||||
model,
|
model, child, virtual=self.virtual,
|
||||||
child,
|
|
||||||
virtual=self.virtual,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return model
|
return model
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import decimal
|
|||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from pydantic import Json
|
from pydantic import Json
|
||||||
|
|
||||||
from orm.fields.base import BaseField, RequiredParams
|
from orm.fields.base import BaseField, RequiredParams # noqa I101
|
||||||
|
|
||||||
|
|
||||||
@RequiredParams("length")
|
@RequiredParams("length")
|
||||||
|
|||||||
@ -6,18 +6,16 @@ from typing import Any, List, Optional, TYPE_CHECKING, Tuple, Type, TypeVar
|
|||||||
from typing import Callable, Dict, Set
|
from typing import Callable, Dict, Set
|
||||||
|
|
||||||
import databases
|
import databases
|
||||||
|
|
||||||
import orm.queryset as qry
|
|
||||||
from orm.exceptions import ModelDefinitionError
|
|
||||||
from orm import ForeignKey
|
|
||||||
from orm.fields.base import BaseField
|
|
||||||
from orm.relations import RelationshipManager
|
|
||||||
|
|
||||||
import pydantic
|
import pydantic
|
||||||
|
import sqlalchemy
|
||||||
from pydantic import BaseConfig, BaseModel, create_model
|
from pydantic import BaseConfig, BaseModel, create_model
|
||||||
from pydantic.fields import ModelField
|
from pydantic.fields import ModelField
|
||||||
|
|
||||||
import sqlalchemy
|
import orm.queryset as qry # noqa I100
|
||||||
|
from orm import ForeignKey
|
||||||
|
from orm.exceptions import ModelDefinitionError
|
||||||
|
from orm.fields.base import BaseField
|
||||||
|
from orm.relations import RelationshipManager
|
||||||
|
|
||||||
relationship_manager = RelationshipManager()
|
relationship_manager = RelationshipManager()
|
||||||
|
|
||||||
|
|||||||
@ -11,16 +11,15 @@ from typing import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
import databases
|
import databases
|
||||||
|
import sqlalchemy
|
||||||
|
from sqlalchemy import text
|
||||||
|
|
||||||
import orm
|
import orm # noqa I100
|
||||||
import orm.fields.foreign_key
|
import orm.fields.foreign_key
|
||||||
from orm import ForeignKey
|
from orm import ForeignKey
|
||||||
from orm.exceptions import MultipleMatches, NoMatch, QueryDefinitionError
|
from orm.exceptions import MultipleMatches, NoMatch, QueryDefinitionError
|
||||||
from orm.fields.base import BaseField
|
from orm.fields.base import BaseField
|
||||||
|
|
||||||
import sqlalchemy
|
|
||||||
from sqlalchemy import text
|
|
||||||
|
|
||||||
if TYPE_CHECKING: # pragma no cover
|
if TYPE_CHECKING: # pragma no cover
|
||||||
from orm.models import Model
|
from orm.models import Model
|
||||||
|
|
||||||
|
|||||||
@ -56,10 +56,7 @@ class RelationshipManager:
|
|||||||
del self._relations[rel_type][model._orm_id]
|
del self._relations[rel_type][model._orm_id]
|
||||||
|
|
||||||
def add_relation(
|
def add_relation(
|
||||||
self,
|
self, parent: "FakePydantic", child: "FakePydantic", virtual: bool = False,
|
||||||
parent: "FakePydantic",
|
|
||||||
child: "FakePydantic",
|
|
||||||
virtual: bool = False,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
parent_id = parent._orm_id
|
parent_id = parent._orm_id
|
||||||
child_id = child._orm_id
|
child_id = child._orm_id
|
||||||
|
|||||||
Reference in New Issue
Block a user