diff options
| author | rr- | 2017-02-04 01:08:12 +0100 |
|---|---|---|
| committer | rr- | 2017-02-05 16:34:45 +0100 |
| commit | ad842ee8a54c57463b8e28b52970f173ea1d64ea (patch) | |
| tree | 1238e8270878801a2ddb10bc4db469115c026cab /server/szurubooru/func/versions.py | |
| parent | abf1fc2b2d135299fe7e8a700d4e7a18966d7bfe (diff) | |
server: refactor + add type hinting
- Added type hinting (for now, 3.5-compatible)
- Split `db` namespace into `db` module and `model` namespace
- Changed elastic search to be created lazily for each operation
- Changed to class based approach in entity serialization to allow
stronger typing
- Removed `required` argument from `context.get_*` family of functions;
now it's implied if `default` argument is omitted
- Changed `unalias_dict` implementation to use less magic inputs
Diffstat (limited to 'server/szurubooru/func/versions.py')
| -rw-r--r-- | server/szurubooru/func/versions.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/server/szurubooru/func/versions.py b/server/szurubooru/func/versions.py index ee84407..459b025 100644 --- a/server/szurubooru/func/versions.py +++ b/server/szurubooru/func/versions.py @@ -1,8 +1,11 @@ -from szurubooru import errors +from szurubooru import errors, rest, model -def verify_version(entity, context, field_name='version'): - actual_version = context.get_param_as_int(field_name, required=True) +def verify_version( + entity: model.Base, + context: rest.Context, + field_name: str='version') -> None: + actual_version = context.get_param_as_int(field_name) expected_version = entity.version if actual_version != expected_version: raise errors.IntegrityError( @@ -10,5 +13,5 @@ def verify_version(entity, context, field_name='version'): 'Please try again.') -def bump_version(entity): +def bump_version(entity: model.Base) -> None: entity.version = entity.version + 1 |