Skip to content

Commit 7e48817

Browse files
committed
Use declarative decorator on Base rather than redefining the class
This helps static analysis and makes all the PyCharm warnings disappear (like, method Foo.get_from_id undefined, ...)
1 parent 397e9eb commit 7e48817

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

cms/db/base.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
from __future__ import unicode_literals
2727
from future.builtins.disabled import * # noqa
2828
from future.builtins import * # noqa
29-
from six import iterkeys, iteritems
29+
from six import iterkeys
3030

3131
import ipaddress
3232
from datetime import datetime, timedelta
3333

34-
from sqlalchemy.ext.declarative import declarative_base
34+
from sqlalchemy.ext.declarative import as_declarative
3535
from sqlalchemy.orm.exc import ObjectDeletedError
3636
from sqlalchemy.orm.session import object_session
3737
from sqlalchemy.orm import \
@@ -78,6 +78,7 @@
7878
}
7979

8080

81+
@as_declarative(bind=engine, metadata=metadata, constructor=None)
8182
class Base(object):
8283
"""Base class for all classes managed by SQLAlchemy. Extending the
8384
base class given by SQLAlchemy.
@@ -336,5 +337,3 @@ def set_attrs(self, attrs, fill_with_defaults=False):
336337
"set_attrs() got an unexpected keyword argument '%s'" %
337338
attrs.popitem()[0])
338339

339-
340-
Base = declarative_base(engine, metadata=metadata, cls=Base, constructor=None)

0 commit comments

Comments
 (0)