Skip to content

Commit

Permalink
chore: fix code-qa
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-schoonjans committed Jan 15, 2024
1 parent 13d6163 commit 5b33b6f
Show file tree
Hide file tree
Showing 10 changed files with 207 additions and 162 deletions.
1 change: 1 addition & 0 deletions requirements/requirements.3.11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ idna==3.6
pyasn1==0.5.1
python-dateutil==2.8.2
python-jose==3.3.0
python-magic==0.4.27
rsa==4.9
six==1.16.0
sniffio==1.3.0
Expand Down
9 changes: 7 additions & 2 deletions requirements/requirements.all.3.11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ astroid==3.0.2
autopep8==2.0.4
certifi==2023.11.17
charset-normalizer==3.3.2
coverage==7.4.0
dill==0.3.7
docformatter==1.7.5
ecdsa==0.18.0
Expand All @@ -27,6 +28,9 @@ pydantic_core==2.14.6
pydocstyle==6.3.0
pylint==3.0.3
pytest==7.4.4
pytest-asyncio==0.23.3
pytest-cov==4.1.0
pytest-httpx==0.28.0
pytest-mock==3.12.0
python-dateutil==2.8.2
python-jose==3.3.0
Expand All @@ -35,12 +39,13 @@ rsa==4.9
six==1.16.0
sniffio==1.3.0
snowballstemmer==2.2.0
syrupy==4.6.0
tomlkit==0.12.3
types-appdirs==1.4.3.5
types-pyasn1==0.5.0.20240106
types-python-dateutil==2.8.19.20240106
types-python-jose==3.3.4.20240106
typing_extensions==4.9.0
untokenize==0.1.1
waylay_registry_api @ git+https://github.com/waylayio/waylay-py-services@7ab6b2cb2d5587d32bdddfa918b0bfb88beffd9c#subdirectory=services/registry/waylay_registry_api
waylay_registry_types @ git+https://github.com/waylayio/waylay-py-services@7ab6b2cb2d5587d32bdddfa918b0bfb88beffd9c#subdirectory=services/registry/waylay_registry_types
waylay_registry_api @ git+https://github.com/waylayio/waylay-py-services@21b3e048e9ff9bcb1718b48fbf500627c9a7a01e#subdirectory=services/registry/waylay_registry_api
waylay_registry_types @ git+https://github.com/waylayio/waylay-py-services@21b3e048e9ff9bcb1718b48fbf500627c9a7a01e#subdirectory=services/registry/waylay_registry_types
10 changes: 7 additions & 3 deletions requirements/requirements.dev.3.11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ annotated-types==0.6.0
astroid==3.0.2
autopep8==2.0.4
charset-normalizer==3.3.2
coverage==7.4.0
dill==0.3.7
docformatter==1.7.5
iniconfig==2.0.0
Expand All @@ -17,15 +18,18 @@ pydantic==2.5.3
pydantic_core==2.14.6
pydocstyle==6.3.0
pylint==3.0.3
pytest-asyncio==0.23.3
pytest-cov==4.1.0
pytest-httpx==0.28.0
pytest-mock==3.12.0
pytest==7.4.4
python-magic==0.4.27
snowballstemmer==2.2.0
syrupy==4.6.0
tomlkit==0.12.3
types-appdirs==1.4.3.5
types-pyasn1==0.5.0.20240106
types-python-dateutil==2.8.19.20240106
types-python-jose==3.3.4.20240106
untokenize==0.1.1
waylay_registry_api @ git+https://github.com/waylayio/waylay-py-services@7ab6b2cb2d5587d32bdddfa918b0bfb88beffd9c#subdirectory=services/registry/waylay_registry_api
waylay_registry_types @ git+https://github.com/waylayio/waylay-py-services@7ab6b2cb2d5587d32bdddfa918b0bfb88beffd9c#subdirectory=services/registry/waylay_registry_types
waylay_registry_api @ git+https://github.com/waylayio/waylay-py-services@21b3e048e9ff9bcb1718b48fbf500627c9a7a01e#subdirectory=services/registry/waylay_registry_api
waylay_registry_types @ git+https://github.com/waylayio/waylay-py-services@21b3e048e9ff9bcb1718b48fbf500627c9a7a01e#subdirectory=services/registry/waylay_registry_types
5 changes: 4 additions & 1 deletion src/waylay/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
__version__ = '0.0.0'
"""Package version."""


__version__ = '0.0.0'
17 changes: 8 additions & 9 deletions src/waylay/api/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def __sanitize_for_serialization(self, obj):
key: self.__sanitize_for_serialization(val)
for key, val in obj_dict.items()
}

def __deserialize(self, data: Any, klass: Any):
"""Deserializes response content into a `klass` instance."""
if isinstance(klass, str) and klass in _NATIVE_TYPES_MAPPING:
Expand All @@ -288,15 +288,15 @@ def __deserialize(self, data: Any, klass: Any):
return self.__deserialize_date(data)
elif klass == datetime.datetime:
return self.__deserialize_datetime(data)

if isinstance(klass, str):
if klass.startswith('List['):
sub_kls = re.match(r'List\[(.*)]', klass).group(1)
sub_kls = re.match(r'List\[(.*)]', klass).group(1) # type: ignore[union-attr]
return [self.__deserialize(sub_data, sub_kls)
for sub_data in data]

if klass.startswith('Dict['):
sub_kls = re.match(r'Dict\[([^,]*), (.*)]', klass).group(2)
sub_kls = re.match(r'Dict\[([^,]*), (.*)]', klass).group(2) # type: ignore[union-attr]
return {k: self.__deserialize(v, sub_kls)
for k, v in data.items()}

Expand Down Expand Up @@ -422,24 +422,23 @@ def __deserialize_model(self, data, klass):
"""

try:
try:
if callable(getattr(klass, 'from_dict', None)):
return klass.from_dict(data)
return klass.from_dict(data)
except BaseException as e:
pass
return self.__deserialize_simple_namespace(data)


def __deserialize_simple_namespace(self, data):
"""Deserializes dict to a `SimpleNamespace`.
:param data: str.
:return: SimpleNamespace.
"""
if type(data) is list:
if isinstance(data, list):
return list(map(self.__deserialize_simple_namespace, data))
elif type(data) is dict:
elif isinstance(data, dict):
sns = SimpleNamespace()
for key, value in data.items():
setattr(sns, key, self.__deserialize_simple_namespace(value))
Expand Down
1 change: 1 addition & 0 deletions test/unit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Unit tests."""
Loading

0 comments on commit 5b33b6f

Please sign in to comment.