Skip to content

Commit bc0d3a9

Browse files
committed
(#107) upgrade deps to latest
1 parent fe8ddf7 commit bc0d3a9

File tree

10 files changed

+743
-539
lines changed

10 files changed

+743
-539
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.pythonPath": "/Users/legolas/.local/share/virtualenvs/hobbit-core-LenoUno4/bin/python"
3+
}

Pipfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ name = "pypi"
66
[packages]
77
tox = "*"
88
ipython = "*"
9-
hobbit-core = {editable = true,extras = ["hobbit", "hobbit_core"],path = "."}
10-
cx-oracle = "*"
9+
hobbit-core = {version = "==1.4.4", extras = ["hobbit", "hobbit_core"]}
10+
cx-Oracle = "*"
1111

1212
[dev-packages]
1313
sphinx = "==2.0.1"
@@ -20,10 +20,10 @@ pytest-env = "*"
2020
flake8 = "*"
2121
twine = "*"
2222
mypy = "*"
23-
mypy-extensions = "==0.4.1"
23+
mypy-extensions = "*"
2424

2525
[requires]
26-
python_version = "3.7"
26+
python_version = "3.9"
2727

2828
[pipenv]
2929
allow_prereleases = true

Pipfile.lock

Lines changed: 696 additions & 502 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hobbit_core/db.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from typing import Any, Union, List, Dict
77

88
from flask import current_app
9-
from sqlalchemy import Integer, Column, ForeignKey, func, DateTime, Sequence
9+
from sqlalchemy import BigInteger, Column, ForeignKey, func, DateTime, Sequence
1010
from sqlalchemy.orm.session import Session
1111
from flask_sqlalchemy import DefaultMeta
1212

@@ -15,9 +15,9 @@
1515

1616
class _BaseModel:
1717

18-
__mapper_args__ = {
19-
'order_by': 'id',
20-
}
18+
# __mapper_args__ = {
19+
# 'order_by': 'id',
20+
# }
2121

2222
def __repr__(self) -> str:
2323
"""You can set label property.
@@ -35,7 +35,7 @@ class SurrogatePK(_BaseModel):
3535
"""A mixin that add ``id``、``created_at`` and ``updated_at`` columns
3636
to any declarative-mapped class.
3737
38-
**id**: A surrogate integer 'primary key' column.
38+
**id**: A surrogate biginteger 'primary key' column.
3939
4040
**created_at**: Auto save ``datetime.now()`` when row created.
4141
@@ -46,7 +46,7 @@ class SurrogatePK(_BaseModel):
4646

4747
__table_args__ = {'extend_existing': True} # type: ignore
4848

49-
id = Column(Integer, primary_key=True)
49+
id = Column(BigInteger, primary_key=True)
5050
created_at = Column(
5151
DateTime, index=True, nullable=False, server_default=func.now())
5252
updated_at = Column(
@@ -67,7 +67,7 @@ def __new__(cls, name, bases, attrs):
6767

6868
primary_key_name = attrs.get('primary_key_name') or 'id'
6969

70-
attrs[primary_key_name] = Column(Integer, primary_key=True)
70+
attrs[primary_key_name] = Column(BigInteger, primary_key=True)
7171
attrs['created_at'] = Column(
7272
DateTime, index=True, nullable=False, server_default=func.now())
7373
attrs['updated_at'] = Column(
@@ -80,7 +80,7 @@ def __new__(cls, name, bases, attrs):
8080
if current_app.config['HOBBIT_UPPER_SEQUENCE_NAME']:
8181
sequence_name = sequence_name.upper()
8282
attrs[primary_key_name] = Column(
83-
Integer,
83+
BigInteger,
8484
Sequence(sequence_name),
8585
primary_key=True)
8686

@@ -95,7 +95,7 @@ class BaseModel(_BaseModel, db.Model, metaclass=BaseModelMeta): # type: ignore
9595
"""Abstract base model class contains
9696
``id``、``created_at`` and ``updated_at`` columns.
9797
98-
**id**: A surrogate integer 'primary key' column.
98+
**id**: A surrogate biginteger 'primary key' column.
9999
100100
**created_at**: Auto save ``datetime.now()`` when row created.
101101
@@ -358,6 +358,7 @@ def create(username, password):
358358
def wrapper(func):
359359
@wraps(func)
360360
def inner(*args, **kwargs):
361+
print(session.autocommit, "session.autocommit")
361362
if session.autocommit is True and nested is False:
362363
session.begin() # start a transaction
363364

hobbit_core/schemas.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from marshmallow import (
22
Schema as Schema_, fields, pre_load, post_load, post_dump,
33
)
4-
from marshmallow_sqlalchemy.schema import ModelSchemaMeta
5-
from flask_marshmallow.sqla import ModelSchema as ModelSchema_
4+
from marshmallow_sqlalchemy.schema import SQLAlchemyAutoSchemaMeta
5+
from flask_marshmallow.sqla import SQLAlchemyAutoSchema as SQLAlchemyAutoSchema_
66
from marshmallow_enum import EnumField
77

88

9-
class ORMSchema(ModelSchema_):
9+
class ORMSchema(SQLAlchemyAutoSchema_):
1010
"""Base schema for ModelSchema. See `webargs/issues/126
1111
<https://github.com/sloria/webargs/issues/126>`_.
1212
@@ -92,7 +92,7 @@ class Meta:
9292
strict = True
9393

9494

95-
class EnumSetMeta(ModelSchemaMeta):
95+
class EnumSetMeta(SQLAlchemyAutoSchemaMeta):
9696
"""EnumSetMeta is a metaclass that can be used to auto generate load and
9797
dump func for EnumField.
9898
"""
@@ -118,7 +118,7 @@ def wrapper(self, data):
118118
return wrapper
119119

120120
def __new__(cls, name, bases, attrs):
121-
schema = ModelSchemaMeta.__new__(cls, name, tuple(bases), attrs)
121+
schema = SQLAlchemyAutoSchemaMeta.__new__(cls, name, tuple(bases), attrs)
122122
verbose = getattr(schema.Meta, 'verbose', True)
123123

124124
setattr(schema.Meta, 'dateformat', '%Y-%m-%d %H:%M:%S')

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel"]
3+
build-backend = "setuptools.build_meta:__legacy__"

setup.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ def gen_data(data_root='static'):
5050
install_requires=[],
5151
extras_require={
5252
'hobbit_core': [
53-
'Flask>=1.0.2',
54-
'flask-marshmallow>=0.9.0',
55-
'Flask-Migrate>=2.2.1',
56-
'flask-shell-ipython>=0.3.1',
57-
'Flask-SQLAlchemy>=2.3.2',
58-
'marshmallow-enum>=1.4.1',
59-
'marshmallow-sqlalchemy>=0.14.1',
60-
'webargs>=5.1.3, <6',
61-
'mypy-extensions==0.4.1',
62-
'pyyaml>=4.2b1',
63-
'marshmallow==v3.0.0rc6',
53+
'Flask>=2.0.1, <3',
54+
'flask-marshmallow>=0.14.0, <1',
55+
'Flask-Migrate>=3.0.1, <4',
56+
'flask-shell-ipython>=0.4.1',
57+
'Flask-SQLAlchemy>=2.5.1, <3',
58+
'marshmallow-enum>=1.5.1, <2',
59+
'marshmallow-sqlalchemy>=0.26.1, <3',
60+
'webargs>=8.0.0, <9',
61+
'mypy-extensions>=0.4.3',
62+
'pyyaml>=5.4.1, <6',
63+
'marshmallow>=3.0.0, <4',
6464
],
6565
'hobbit': [
6666
'Click>=6.7',

tests/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ def teardown_class(cls):
2222

2323
def teardown_method(self, method):
2424
with app.app_context():
25-
for m in [m for m in db.Model._decl_class_registry.values()
25+
print(">>>>>>", [m for m in db.Model.registry._class_registry.values()])
26+
for m in [m for m in db.Model.registry._class_registry.values()
2627
if isinstance(m, model.DefaultMeta) and
2728
getattr(m, '__bind_key__', None) != 'oracle']:
29+
print(m)
2830
db.session.query(m).delete()
2931
db.session.commit()
3032

tests/conftest.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from unittest import mock
33

4-
from webargs.core import Parser, get_value
4+
from webargs.core import Parser
55

66
from .test_app.run import app as tapp
77
from .test_app.exts import db as tdb
@@ -62,14 +62,14 @@ def session(request):
6262
class MockRequestParser(Parser):
6363
"""A minimal parser implementation that parses mock requests."""
6464

65-
def parse_querystring(self, req, name, field):
66-
return get_value(req.query, name, field)
65+
def parse_querystring(self, req, schema):
66+
return self.load_json(req, schema)
6767

68-
def parse_json(self, req, name, field):
69-
return get_value(req.json, name, field)
68+
def parse_json(self, req, schema):
69+
return self.load_json(req, schema)
7070

71-
def parse_cookies(self, req, name, field):
72-
return get_value(req.cookies, name, field)
71+
def parse_cookies(self, req, schema):
72+
return self.load_json(req, schema)
7373

7474

7575
@pytest.yield_fixture(scope="function")

tests/test_db.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def create_user():
160160
session.commit()
161161

162162
msg = 'This transaction is closed'
163+
create_user()
163164
with pytest.raises(ResourceClosedError, match=msg):
164165
create_user()
165166
assert assert_session.query(User).all() == []

0 commit comments

Comments
 (0)