Repository: dropbox/stone

Issue:
Generated .pyi files reference 'long', which is not Python 3 compatible
I can think of two ways to fix this:

1. The easy way: replace `'long'` with `'int'` [here](https://github.com/dropbox/stone/blob/master/stone/backends/python_type_mapping.py#L63)
2. Do something with the override_dict

A potential problem for (1) would be that it will not only change the generated .pyi files but also the generated .py files. I do think that even in Python 2 the distinction between int and long is rarely useful though, so perhaps this is acceptable.

The problem with (2) is that it's a lot more code, since the architecture for the override_dict doesn't really map cleanly to the way is_integer_type() is used. (In order to allow separate mappings for Int32, UIint32, Int64 and UInt64, we'd need 4 isinstance checks.)

Comments:

Patch:
diff --git a/stone/backends/python_helpers.py b/stone/backends/python_helpers.py
index a3c4385..fa58f91 100644
--- a/stone/backends/python_helpers.py
+++ b/stone/backends/python_helpers.py
@@ -37,12 +37,12 @@ _type_table = {
     Float32: 'float',
     Float64: 'float',
     Int32: 'int',
-    Int64: 'long',
+    Int64: 'int',
     List: 'list',
     String: 'str',
     Timestamp: 'datetime',
-    UInt32: 'long',
-    UInt64: 'long',
+    UInt32: 'int',
+    UInt64: 'int',
 }
 
 _reserved_keywords = {
diff --git a/stone/backends/python_type_mapping.py b/stone/backends/python_type_mapping.py
index d28fae0..10b6358 100644
--- a/stone/backends/python_type_mapping.py
+++ b/stone/backends/python_type_mapping.py
@@ -60,7 +60,7 @@ def map_stone_type_to_python_type(ns, data_type, override_dict=None):
     elif is_float_type(data_type):
         return 'float'
     elif is_integer_type(data_type):
-        return 'long'
+        return 'int'
     elif is_void_type(data_type):
         return 'None'
     elif is_timestamp_type(data_type):


Test patch:
diff --git a/test/test_python_type_stubs.py b/test/test_python_type_stubs.py
index 2e6e42e..ec85dea 100644
--- a/test/test_python_type_stubs.py
+++ b/test/test_python_type_stubs.py
@@ -276,15 +276,15 @@ class TestPythonTypeStubs(unittest.TestCase):
 
             class Struct2(object):
                 def __init__(self,
-                             f2: List[long] = ...,
+                             f2: List[int] = ...,
                              f3: datetime.datetime = ...,
-                             f4: Dict[Text, long] = ...) -> None: ...
+                             f4: Dict[Text, int] = ...) -> None: ...
 
                 @property
-                def f2(self) -> List[long]: ...
+                def f2(self) -> List[int]: ...
 
                 @f2.setter
-                def f2(self, val: List[long]) -> None: ...
+                def f2(self, val: List[int]) -> None: ...
 
                 @f2.deleter
                 def f2(self) -> None: ...
@@ -301,10 +301,10 @@ class TestPythonTypeStubs(unittest.TestCase):
 
 
                 @property
-                def f4(self) -> Dict[Text, long]: ...
+                def f4(self) -> Dict[Text, int]: ...
 
                 @f4.setter
-                def f4(self, val: Dict[Text, long]) -> None: ...
+                def f4(self, val: Dict[Text, int]) -> None: ...
 
                 @f4.deleter
                 def f4(self) -> None: ...
@@ -340,24 +340,24 @@ class TestPythonTypeStubs(unittest.TestCase):
 
             class NestedTypes(object):
                 def __init__(self,
-                             list_of_nullables: List[Optional[long]] = ...,
-                             nullable_list: Optional[List[long]] = ...) -> None: ...
+                             list_of_nullables: List[Optional[int]] = ...,
+                             nullable_list: Optional[List[int]] = ...) -> None: ...
 
                 @property
-                def list_of_nullables(self) -> List[Optional[long]]: ...
+                def list_of_nullables(self) -> List[Optional[int]]: ...
 
                 @list_of_nullables.setter
-                def list_of_nullables(self, val: List[Optional[long]]) -> None: ...
+                def list_of_nullables(self, val: List[Optional[int]]) -> None: ...
 
                 @list_of_nullables.deleter
                 def list_of_nullables(self) -> None: ...
 
 
                 @property
-                def nullable_list(self) -> Optional[List[long]]: ...
+                def nullable_list(self) -> Optional[List[int]]: ...
 
                 @nullable_list.setter
-                def nullable_list(self, val: Optional[List[long]]) -> None: ...
+                def nullable_list(self, val: Optional[List[int]]) -> None: ...
 
                 @nullable_list.deleter
                 def nullable_list(self) -> None: ...
diff --git a/test/test_python_types.py b/test/test_python_types.py
index 0f84f49..5c00cc2 100644
--- a/test/test_python_types.py
+++ b/test/test_python_types.py
@@ -165,7 +165,7 @@ class TestGeneratedPythonTypes(unittest.TestCase):
                 @property
                 def annotated_field(self):
                     """
-                    :rtype: long
+                    :rtype: int
                     """
                     if self._annotated_field_present:
                         return self._annotated_field_value
@@ -186,7 +186,7 @@ class TestGeneratedPythonTypes(unittest.TestCase):
                 @property
                 def unannotated_field(self):
                     """
-                    :rtype: long
+                    :rtype: int
                     """
                     if self._unannotated_field_present:
                         return self._unannotated_field_value
@@ -268,14 +268,14 @@ class TestGeneratedPythonTypes(unittest.TestCase):
                     """
                     test parameter
 
-                    :rtype: long
+                    :rtype: int
                     """
                     return self._test_param
 
                 @property
                 def test_default_param(self):
                     """
-                    :rtype: long
+                    :rtype: int
                     """
                     return self._test_default_param