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