Skip to content

Commit

Permalink
remove unnecessary if else statement
Browse files Browse the repository at this point in the history
  • Loading branch information
iscai-msft committed Aug 19, 2021
1 parent 62a8e5c commit 59fc8d5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 2 additions & 0 deletions sdk/core/azure-core/azure/core/rest/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ def get_charset_encoding(response):

def decode_to_text(encoding, content):
# type: (Optional[str], bytes) -> str
if not content:
return ""
if encoding == "utf-8":
encoding = "utf-8-sig"
if encoding:
Expand Down
7 changes: 2 additions & 5 deletions sdk/core/azure-core/azure/core/rest/_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,8 @@ def text(self, encoding=None):
:return: The response's content decoded as a string.
"""
if self._text is None or encoding:
if not self.content:
self._text = ""
else:
encoding_to_pass = encoding or self.encoding
self._text = decode_to_text(encoding_to_pass, self.content)
encoding_to_pass = encoding or self.encoding
self._text = decode_to_text(encoding_to_pass, self.content)
return self._text

def json(self):
Expand Down
7 changes: 2 additions & 5 deletions sdk/core/azure-core/azure/core/rest/_rest_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,8 @@ def text(self, encoding: Optional[str] = None) -> str:
:return: The response's content decoded as a string.
"""
if self._text is None or encoding:
if not self.content:
self._text = ""
else:
encoding_to_pass = encoding or self.encoding
self._text = decode_to_text(encoding_to_pass, self.content)
encoding_to_pass = encoding or self.encoding
self._text = decode_to_text(encoding_to_pass, self.content)
return self._text

def json(self) -> Any:
Expand Down

0 comments on commit 59fc8d5

Please sign in to comment.