Repository: Azure/msrest-for-python

Issue:
Default argument value is mutable
Hi,

Just want to confirm, I noticed there are some methods in `ServiceClient` contain a mutable default argument, for instance: 
`def get(self, url=None, params={}):
        """Create a GET request object.

        :param str url: The request URL.
        :param dict params: Request URL parameters.
        """
        request = self._request(url, params)
        request.method = 'GET'
        return request`

And the default argument `params` is changed in`self._request(url, params)`. Is that as design? I just think it's a little wired. Thanks!

 

Comments:

Patch:
diff --git a/msrest/exceptions.py b/msrest/exceptions.py
index 85668a6..6ac7dcc 100644
--- a/msrest/exceptions.py
+++ b/msrest/exceptions.py
@@ -113,7 +113,7 @@ class AuthenticationError(ClientException):
 
 
 class HttpOperationError(ClientException):
-    """Client request failed due to server-specificed HTTP operation error.
+    """Client request failed due to server-specified HTTP operation error.
     Attempts to deserialize response into specific error object.
 
     :param Deserializer deserialize: Deserializer with data on custom
diff --git a/msrest/service_client.py b/msrest/service_client.py
index a204089..ac70211 100644
--- a/msrest/service_client.py
+++ b/msrest/service_client.py
@@ -138,7 +138,7 @@ class ServiceClient(object):
 
         return kwargs
 
-    def send_formdata(self, request, headers={}, content={}, **config):
+    def send_formdata(self, request, headers=None, content=None, **config):
         """Send data as a multipart form-data request.
         We only deal with file-like objects or strings at this point.
         The requests is not yet streamed.
@@ -148,11 +148,11 @@ class ServiceClient(object):
         :param dict content: Dictionary of the fields of the formdata.
         :param config: Any specific config overrides.
         """
+        if content is None:
+            content = {}
         file_data = {f: self._format_data(d) for f, d in content.items()}
-        try:
-            del headers['Content-Type']
-        except KeyError:
-            pass
+        if headers:
+            headers.pop('Content-Type', None)
         return self.send(request, headers, None, files=file_data, **config)
 
     def send(self, request, headers=None, content=None, **config):
@@ -290,7 +290,7 @@ class ServiceClient(object):
         """
         self._headers[header] = value
 
-    def get(self, url=None, params={}):
+    def get(self, url=None, params=None):
         """Create a GET request object.
 
         :param str url: The request URL.
@@ -300,7 +300,7 @@ class ServiceClient(object):
         request.method = 'GET'
         return request
 
-    def put(self, url=None, params={}):
+    def put(self, url=None, params=None):
         """Create a PUT request object.
 
         :param str url: The request URL.
@@ -310,7 +310,7 @@ class ServiceClient(object):
         request.method = 'PUT'
         return request
 
-    def post(self, url=None, params={}):
+    def post(self, url=None, params=None):
         """Create a POST request object.
 
         :param str url: The request URL.
@@ -320,7 +320,7 @@ class ServiceClient(object):
         request.method = 'POST'
         return request
 
-    def head(self, url=None, params={}):
+    def head(self, url=None, params=None):
         """Create a HEAD request object.
 
         :param str url: The request URL.
@@ -330,7 +330,7 @@ class ServiceClient(object):
         request.method = 'HEAD'
         return request
 
-    def patch(self, url=None, params={}):
+    def patch(self, url=None, params=None):
         """Create a PATCH request object.
 
         :param str url: The request URL.
@@ -340,7 +340,7 @@ class ServiceClient(object):
         request.method = 'PATCH'
         return request
 
-    def delete(self, url=None, params={}):
+    def delete(self, url=None, params=None):
         """Create a DELETE request object.
 
         :param str url: The request URL.
@@ -350,7 +350,7 @@ class ServiceClient(object):
         request.method = 'DELETE'
         return request
 
-    def merge(self, url=None, params={}):
+    def merge(self, url=None, params=None):
         """Create a MERGE request object.
 
         :param str url: The request URL.


Test patch:
diff --git a/test/unittest_client.py b/test/unittest_client.py
index c22b13e..4a193ee 100644
--- a/test/unittest_client.py
+++ b/test/unittest_client.py
@@ -201,7 +201,7 @@ class TestServiceClient(unittest.TestCase):
         mock_client._format_data.return_value = "formatted"
         request = ClientRequest('GET')
         ServiceClient.send_formdata(mock_client, request)
-        mock_client.send.assert_called_with(request, {}, None, files={})
+        mock_client.send.assert_called_with(request, None, None, files={})
 
         ServiceClient.send_formdata(mock_client, request, {'id':'1234'}, {'Test':'Data'})
         mock_client.send.assert_called_with(request, {'id':'1234'}, None, files={'Test':'formatted'})