Skip to content

Commit

Permalink
Clean up py2 support (#1774)
Browse files Browse the repository at this point in the history
* (trivial) fix typo

Update the spelling typo

* Clean up py2 support

The workarounds for python2 support are no longer needed
  • Loading branch information
osoriano authored Jan 14, 2025
1 parent b6c78d2 commit a51fdd7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion deploy-agent/deployd/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def serve_build(self) -> None:
if deploy_report.status_code in [AgentStatus.AGENT_FAILED,
AgentStatus.TOO_MANY_RETRY,
AgentStatus.SCRIPT_TIMEOUT]:
log.error('Unexpeted exceptions: {}, error message {}'.format(
log.error('Unexpected exceptions: {}, error message {}'.format(
deploy_report.status_code, deploy_report.output_msg))
return

Expand Down
7 changes: 1 addition & 6 deletions deploy-agent/deployd/common/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,6 @@ def __init__(self, mtype=None, name=None, value=None, sample_rate=None, tags=Non
self.sample_rate = sample_rate
self.tags = tags
self.ins = ins
try:
self.JSONDecodeError = json.decoder.JSONDecodeError
except AttributeError:
# python2 support
self.JSONDecodeError = ValueError

def serialize(self) -> str:
""" serialize for cache writing """
Expand Down Expand Up @@ -244,7 +239,7 @@ def deserialize(self, ins=None) -> bool:
valid = self._deserialize()
if valid:
return True
except self.JSONDecodeError:
except json.decoder.JSONDecodeError:
return False
except TypeError:
return False
Expand Down
12 changes: 4 additions & 8 deletions deploy-agent/tests/unit/deploy/common/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
import json
import socket
from time import sleep
try:
from unittest import mock
except ImportError:
# python2 support
import mock
from unittest import mock


class TestMetricCacheExceptions(unittest.TestCase):
Expand Down Expand Up @@ -114,7 +110,7 @@ def test__deserialize(self):
sample_rate=None,
tags=None,
ins=invalid_str)
with self.assertRaises(stat.JSONDecodeError):
with self.assertRaises(json.decoder.JSONDecodeError):
stat._deserialize()
invalid_prop = b'{\x48:\x69}'
stat = Stat(mtype=None,
Expand All @@ -123,7 +119,7 @@ def test__deserialize(self):
sample_rate=None,
tags=None,
ins=invalid_prop)
with self.assertRaises(stat.JSONDecodeError):
with self.assertRaises(json.decoder.JSONDecodeError):
stat._deserialize()
invalid_type_1 = list()
stat = Stat(mtype=None,
Expand Down Expand Up @@ -241,4 +237,4 @@ def test_resume(self):
self.elapsed.pause()
self.assertTrue(self.elapsed._is_paused())
self.elapsed.resume()
self.assertFalse(self.elapsed._is_paused())
self.assertFalse(self.elapsed._is_paused())

0 comments on commit a51fdd7

Please sign in to comment.