diff options
author | Hervé Beraud <hberaud@redhat.com> | 2021-07-01 12:38:09 +0200 |
---|---|---|
committer | Hervé Beraud <hberaud@redhat.com> | 2021-07-01 19:09:14 +0200 |
commit | 41ad03533fe15ea9ad6188c65df129bfd8d077cd (patch) | |
tree | 75205640c2da4736fe95c6046abc036d1eed883e /pymemcache/client/base.py | |
parent | b289c87bb89b3ab477bd5d92c8951ab42c923923 (diff) | |
download | pymemcache-41ad03533fe15ea9ad6188c65df129bfd8d077cd.tar.gz |
Reduce method complexity to pass linter tests
The _store_cmd method became a bit to complexe and the linter complains
when we add new conditions or try/except clause.
These changes outsource some some processsing to reduce the complexity
of the method.
Diffstat (limited to 'pymemcache/client/base.py')
-rw-r--r-- | pymemcache/client/base.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/pymemcache/client/base.py b/pymemcache/client/base.py index ad9ed8c..abba063 100644 --- a/pymemcache/client/base.py +++ b/pymemcache/client/base.py @@ -43,6 +43,13 @@ SOCKET_KEEPALIVE_SUPPORTED_SYSTEM = { 'Linux', } +STORE_RESULTS_VALUE = { + b'STORED': True, + b'NOT_STORED': False, + b'NOT_FOUND': None, + b'EXISTS': False +} + # Some of the values returned by the "stats" command # need mapping into native Python types @@ -1089,14 +1096,7 @@ class Client(object): self._raise_errors(line, name) if line in VALID_STORE_RESULTS[name]: - if line == b'STORED': - results[key] = True - if line == b'NOT_STORED': - results[key] = False - if line == b'NOT_FOUND': - results[key] = None - if line == b'EXISTS': - results[key] = False + results[key] = STORE_RESULTS_VALUE[line] else: raise MemcacheUnknownError(line[:32]) return results |