Skip to content

Commit 7a77680

Browse files
committed
Allow subclassing while still protecting the registry
1 parent 030e5e1 commit 7a77680

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

graphene_sqlalchemy/registry.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ def __init__(self):
66
self._registry_composites = {}
77

88
def register(self, cls):
9-
from .types import SQLAlchemyObjectType
10-
assert issubclass(
11-
cls, SQLAlchemyObjectType), 'Only SQLAlchemyObjectType can be registered, received "{}"'.format(
12-
cls.__name__)
9+
from .types import SQLAlchemyObjectType, SQLAlchemyObjectTypeMeta
10+
assert issubclass(type(cls), SQLAlchemyObjectTypeMeta), (
11+
'Only classes of type SQLAlchemyObjectTypeMeta can be registered, ',
12+
'received "{}"'
13+
).format(cls.__name__)
1314
assert cls._meta.registry == self, 'Registry for a Model have to match.'
1415
# assert self.get_type_for_model(cls._meta.model) in [None, cls], (
1516
# 'SQLAlchemy model "{}" already associated with '

setup.cfg

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,20 @@ omit = */tests/*
77

88
[isort]
99
known_first_party=graphene,graphene_sqlalchemy
10+
11+
[tool:pytest]
12+
testpaths = graphene_sqlalchemy/
13+
addopts =
14+
-s
15+
; --cov graphene-sqlalchemy
16+
norecursedirs =
17+
__pycache__
18+
*.egg-info
19+
.cache
20+
.git
21+
.tox
22+
appdir
23+
docs
24+
filterwarnings =
25+
error
26+
ignore::DeprecationWarning

0 commit comments

Comments
 (0)