stone 3.3.3__tar.gz → 3.3.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. {stone-3.3.3/stone.egg-info → stone-3.3.7}/PKG-INFO +2 -1
  2. {stone-3.3.3 → stone-3.3.7}/ez_setup.py +1 -1
  3. {stone-3.3.3 → stone-3.3.7}/setup.py +1 -1
  4. {stone-3.3.3 → stone-3.3.7}/stone/backends/obj_c_types.py +2 -2
  5. {stone-3.3.3 → stone-3.3.7}/stone/backends/python_rsrc/stone_validators.py +25 -10
  6. {stone-3.3.3 → stone-3.3.7}/stone/frontend/ir_generator.py +2 -0
  7. {stone-3.3.3 → stone-3.3.7}/stone/ir/api.py +2 -2
  8. {stone-3.3.3 → stone-3.3.7/stone.egg-info}/PKG-INFO +2 -1
  9. {stone-3.3.3 → stone-3.3.7}/stone.egg-info/requires.txt +1 -0
  10. {stone-3.3.3 → stone-3.3.7}/test/test_backend.py +2 -2
  11. {stone-3.3.3 → stone-3.3.7}/LICENSE +0 -0
  12. {stone-3.3.3 → stone-3.3.7}/MANIFEST.in +0 -0
  13. {stone-3.3.3 → stone-3.3.7}/README.rst +0 -0
  14. {stone-3.3.3 → stone-3.3.7}/setup.cfg +0 -0
  15. {stone-3.3.3 → stone-3.3.7}/stone/__init__.py +0 -0
  16. {stone-3.3.3 → stone-3.3.7}/stone/backend.py +0 -0
  17. {stone-3.3.3 → stone-3.3.7}/stone/backends/__init__.py +0 -0
  18. {stone-3.3.3 → stone-3.3.7}/stone/backends/helpers.py +0 -0
  19. {stone-3.3.3 → stone-3.3.7}/stone/backends/js_client.py +0 -0
  20. {stone-3.3.3 → stone-3.3.7}/stone/backends/js_helpers.py +0 -0
  21. {stone-3.3.3 → stone-3.3.7}/stone/backends/js_types.py +0 -0
  22. {stone-3.3.3 → stone-3.3.7}/stone/backends/obj_c.py +0 -0
  23. {stone-3.3.3 → stone-3.3.7}/stone/backends/obj_c_client.py +0 -0
  24. {stone-3.3.3 → stone-3.3.7}/stone/backends/obj_c_helpers.py +0 -0
  25. {stone-3.3.3 → stone-3.3.7}/stone/backends/python_client.py +0 -0
  26. {stone-3.3.3 → stone-3.3.7}/stone/backends/python_helpers.py +0 -0
  27. {stone-3.3.3 → stone-3.3.7}/stone/backends/python_rsrc/__init__.py +0 -0
  28. {stone-3.3.3 → stone-3.3.7}/stone/backends/python_rsrc/stone_base.py +0 -0
  29. {stone-3.3.3 → stone-3.3.7}/stone/backends/python_rsrc/stone_serializers.py +0 -0
  30. {stone-3.3.3 → stone-3.3.7}/stone/backends/python_type_mapping.py +0 -0
  31. {stone-3.3.3 → stone-3.3.7}/stone/backends/python_type_stubs.py +0 -0
  32. {stone-3.3.3 → stone-3.3.7}/stone/backends/python_types.py +0 -0
  33. {stone-3.3.3 → stone-3.3.7}/stone/backends/swift.py +0 -0
  34. {stone-3.3.3 → stone-3.3.7}/stone/backends/swift_client.py +0 -0
  35. {stone-3.3.3 → stone-3.3.7}/stone/backends/swift_helpers.py +0 -0
  36. {stone-3.3.3 → stone-3.3.7}/stone/backends/swift_types.py +0 -0
  37. {stone-3.3.3 → stone-3.3.7}/stone/backends/tsd_client.py +0 -0
  38. {stone-3.3.3 → stone-3.3.7}/stone/backends/tsd_helpers.py +0 -0
  39. {stone-3.3.3 → stone-3.3.7}/stone/backends/tsd_types.py +0 -0
  40. {stone-3.3.3 → stone-3.3.7}/stone/cli.py +0 -0
  41. {stone-3.3.3 → stone-3.3.7}/stone/cli_helpers.py +0 -0
  42. {stone-3.3.3 → stone-3.3.7}/stone/compiler.py +0 -0
  43. {stone-3.3.3 → stone-3.3.7}/stone/frontend/__init__.py +0 -0
  44. {stone-3.3.3 → stone-3.3.7}/stone/frontend/ast.py +0 -0
  45. {stone-3.3.3 → stone-3.3.7}/stone/frontend/exception.py +0 -0
  46. {stone-3.3.3 → stone-3.3.7}/stone/frontend/frontend.py +0 -0
  47. {stone-3.3.3 → stone-3.3.7}/stone/frontend/lexer.py +0 -0
  48. {stone-3.3.3 → stone-3.3.7}/stone/frontend/parser.py +0 -0
  49. {stone-3.3.3 → stone-3.3.7}/stone/ir/__init__.py +0 -0
  50. {stone-3.3.3 → stone-3.3.7}/stone/ir/data_types.py +0 -0
  51. {stone-3.3.3 → stone-3.3.7}/stone/py.typed +0 -0
  52. {stone-3.3.3 → stone-3.3.7}/stone/typing_hacks.py +0 -0
  53. {stone-3.3.3 → stone-3.3.7}/stone.egg-info/SOURCES.txt +0 -0
  54. {stone-3.3.3 → stone-3.3.7}/stone.egg-info/dependency_links.txt +0 -0
  55. {stone-3.3.3 → stone-3.3.7}/stone.egg-info/entry_points.txt +0 -0
  56. {stone-3.3.3 → stone-3.3.7}/stone.egg-info/not-zip-safe +0 -0
  57. {stone-3.3.3 → stone-3.3.7}/stone.egg-info/top_level.txt +0 -0
  58. {stone-3.3.3 → stone-3.3.7}/test/requirements.txt +0 -0
  59. {stone-3.3.3 → stone-3.3.7}/test/test_cli.py +0 -0
  60. {stone-3.3.3 → stone-3.3.7}/test/test_js_client.py +0 -0
  61. {stone-3.3.3 → stone-3.3.7}/test/test_python_client.py +0 -0
  62. {stone-3.3.3 → stone-3.3.7}/test/test_python_gen.py +0 -0
  63. {stone-3.3.3 → stone-3.3.7}/test/test_python_type_stubs.py +0 -0
  64. {stone-3.3.3 → stone-3.3.7}/test/test_python_types.py +0 -0
  65. {stone-3.3.3 → stone-3.3.7}/test/test_stone.py +0 -0
  66. {stone-3.3.3 → stone-3.3.7}/test/test_stone_internal.py +0 -0
  67. {stone-3.3.3 → stone-3.3.7}/test/test_stone_route_whitelist.py +0 -0
  68. {stone-3.3.3 → stone-3.3.7}/test/test_tsd_client.py +0 -0
  69. {stone-3.3.3 → stone-3.3.7}/test/test_tsd_types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: stone
3
- Version: 3.3.3
3
+ Version: 3.3.7
4
4
  Summary: Stone is an interface description language (IDL) for APIs.
5
5
  Home-page: https://github.com/dropbox/stone
6
6
  Author: Ken Elkabany
@@ -21,6 +21,7 @@ Description-Content-Type: text/x-rst
21
21
  License-File: LICENSE
22
22
  Requires-Dist: ply>=3.4
23
23
  Requires-Dist: six>=1.12.0
24
+ Requires-Dist: packaging>=21.0
24
25
 
25
26
  .. image:: https://cfl.dropboxstatic.com/static/images/sdk/stone_banner.png
26
27
  :target: https://github.com/dropbox/stone
@@ -23,7 +23,7 @@ import sys
23
23
  import tempfile
24
24
  import textwrap
25
25
  import zipfile
26
- from distutils import log
26
+ from setuptools import log
27
27
 
28
28
  try:
29
29
  from site import USER_SITE
@@ -36,7 +36,7 @@ with open('README.rst') as f: # pylint: disable=W1514
36
36
 
37
37
  dist = setup(
38
38
  name='stone',
39
- version='3.3.3',
39
+ version='3.3.7',
40
40
  install_requires=install_reqs,
41
41
  setup_requires=setup_requires,
42
42
  tests_require=test_reqs,
@@ -1006,7 +1006,7 @@ class ObjCTypesBackend(ObjCBaseBackend):
1006
1006
  self.emit(
1007
1007
  'jsonDict[@".tag"] = @"{}";'.format(fmt_var(tag)))
1008
1008
  self.emit()
1009
- self.emit('return [jsonDict count] > 0 ? jsonDict : nil;')
1009
+ self.emit('return jsonDict;')
1010
1010
  self.emit()
1011
1011
 
1012
1012
  def _generate_struct_deserializer(self, struct):
@@ -1152,7 +1152,7 @@ class ObjCTypesBackend(ObjCBaseBackend):
1152
1152
  )
1153
1153
 
1154
1154
  self.emit()
1155
- self.emit('return [jsonDict count] > 0 ? jsonDict : nil;')
1155
+ self.emit('return jsonDict;')
1156
1156
 
1157
1157
  self.emit()
1158
1158
 
@@ -91,6 +91,17 @@ def generic_type_name(v):
91
91
  return type_name_with_module(type(v))
92
92
 
93
93
 
94
+ def get_value_string(v, max_length=1000):
95
+ # type: (typing.Any, int) -> str
96
+ """Return a truncated version of the input string. If the input string is longer than
97
+ 1000 characters, this will return the first 1000 characters and append with '[The
98
+ string has been truncated due to its length]' to indicate that it has been truncated."""
99
+ v_str = str(v)
100
+ if len(v_str) > max_length:
101
+ return v_str[:max_length] + ' [The string has been truncated due to its length]'
102
+ return v_str
103
+
104
+
94
105
  class Validator(metaclass=ABCMeta):
95
106
  """All primitive and composite data types should be a subclass of this."""
96
107
  __slots__ = ("_redact",)
@@ -322,7 +333,7 @@ class String(Primitive):
322
333
  """
323
334
  if not isinstance(val, str):
324
335
  raise ValidationError("'%s' expected to be a string, got %s"
325
- % (val, generic_type_name(val)))
336
+ % (get_value_string(val), generic_type_name(val)))
326
337
  if not six.PY3 and isinstance(val, str):
327
338
  try:
328
339
  val = val.decode('utf-8')
@@ -331,14 +342,18 @@ class String(Primitive):
331
342
 
332
343
  if self.max_length is not None and len(val) > self.max_length:
333
344
  raise ValidationError("'%s' must be at most %d characters, got %d"
334
- % (val, self.max_length, len(val)))
345
+ % (get_value_string(val), self.max_length, len(val)))
335
346
  if self.min_length is not None and len(val) < self.min_length:
336
347
  raise ValidationError("'%s' must be at least %d characters, got %d"
337
- % (val, self.min_length, len(val)))
348
+ % (get_value_string(val), self.min_length, len(val)))
338
349
 
339
350
  if self.pattern and not self.pattern_re.match(val):
351
+ # Detect if pattern is matching an email address and return redacted error message.
352
+ if self.pattern == "^['#&A-Za-z0-9._%+-]+@[A-Za-z0-9-][A-Za-z0-9.-]*\\.[A-Za-z]{2,15}$":
353
+ val = "*****"
354
+
340
355
  raise ValidationError("'%s' did not match pattern '%s'"
341
- % (val, self.pattern))
356
+ % (get_value_string(val), self.pattern))
342
357
  return val
343
358
 
344
359
 
@@ -366,10 +381,10 @@ class Bytes(Primitive):
366
381
  % generic_type_name(val))
367
382
  elif self.max_length is not None and len(val) > self.max_length:
368
383
  raise ValidationError("'%s' must have at most %d bytes, got %d"
369
- % (val, self.max_length, len(val)))
384
+ % (get_value_string(val), self.max_length, len(val)))
370
385
  elif self.min_length is not None and len(val) < self.min_length:
371
386
  raise ValidationError("'%s' has fewer than %d bytes, got %d"
372
- % (val, self.min_length, len(val)))
387
+ % (get_value_string(val), self.min_length, len(val)))
373
388
  return val
374
389
 
375
390
 
@@ -425,13 +440,13 @@ class List(Composite):
425
440
 
426
441
  def validate(self, val):
427
442
  if not isinstance(val, (tuple, list)):
428
- raise ValidationError('%r is not a valid list' % val)
443
+ raise ValidationError('%r is not a valid list' % get_value_string(val))
429
444
  elif self.max_items is not None and len(val) > self.max_items:
430
445
  raise ValidationError('%r has more than %s items'
431
- % (val, self.max_items))
446
+ % (get_value_string(val), self.max_items))
432
447
  elif self.min_items is not None and len(val) < self.min_items:
433
448
  raise ValidationError('%r has fewer than %s items'
434
- % (val, self.min_items))
449
+ % (get_value_string(val), self.min_items))
435
450
  return [self.item_validator.validate(item) for item in val]
436
451
 
437
452
 
@@ -449,7 +464,7 @@ class Map(Composite):
449
464
 
450
465
  def validate(self, val):
451
466
  if not isinstance(val, dict):
452
- raise ValidationError('%r is not a valid dict' % val)
467
+ raise ValidationError('%r is not a valid dict' % get_value_string(val))
453
468
  return {
454
469
  self.key_validator.validate(key):
455
470
  self.value_validator.validate(value) for key, value in val.items()
@@ -826,6 +826,8 @@ class IRGenerator:
826
826
 
827
827
  # collect data types from subtypes recursively
828
828
  if is_struct_type(data_type) or is_union_type(data_type):
829
+ if data_type.parent_type:
830
+ annotations.update(recurse(data_type.parent_type))
829
831
  for field in data_type.fields:
830
832
  annotations.update(recurse(field.data_type))
831
833
  # annotations can be defined directly on fields
@@ -1,6 +1,6 @@
1
1
  from collections import OrderedDict
2
2
  # See <https://github.com/PyCQA/pylint/issues/73>
3
- from distutils.version import StrictVersion # pylint: disable=deprecated-module
3
+ from packaging.version import Version
4
4
 
5
5
  from .data_types import (
6
6
  doc_unwrap,
@@ -34,7 +34,7 @@ class Api:
34
34
  """
35
35
  def __init__(self, version):
36
36
  # type: (str) -> None
37
- self.version = StrictVersion(version)
37
+ self.version = Version(version)
38
38
  self.namespaces = OrderedDict() # type: NamespaceDict
39
39
  self.route_schema = None # type: typing.Optional[Struct]
40
40
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: stone
3
- Version: 3.3.3
3
+ Version: 3.3.7
4
4
  Summary: Stone is an interface description language (IDL) for APIs.
5
5
  Home-page: https://github.com/dropbox/stone
6
6
  Author: Ken Elkabany
@@ -21,6 +21,7 @@ Description-Content-Type: text/x-rst
21
21
  License-File: LICENSE
22
22
  Requires-Dist: ply>=3.4
23
23
  Requires-Dist: six>=1.12.0
24
+ Requires-Dist: packaging>=21.0
24
25
 
25
26
  .. image:: https://cfl.dropboxstatic.com/static/images/sdk/stone_banner.png
26
27
  :target: https://github.com/dropbox/stone
@@ -1,2 +1,3 @@
1
1
  ply>=3.4
2
2
  six>=1.12.0
3
+ packaging>=21.0
@@ -282,7 +282,7 @@ int sq(int x) <
282
282
  self.assertIsInstance(string_type, String)
283
283
 
284
284
  def test_preserve_aliases_from_api(self):
285
- api = Api(version=None)
285
+ api = Api(version="0.1b1")
286
286
  # Ensure imports come after 'preserve_alias' lexiographicaly
287
287
  # to catch namespace ordering bugs
288
288
  api.ensure_namespace('preserve_alias')
@@ -390,7 +390,7 @@ int sq(int x) <
390
390
  self.assertIsInstance(field.data_type, Alias)
391
391
 
392
392
  def test_no_preserve_aliases_from_api(self):
393
- api = Api(version=None)
393
+ api = Api(version="0.1b1")
394
394
  # Ensure imports come after 'preserve_alias' lexiographicaly
395
395
  # to catch namespace ordering bugs
396
396
  api.ensure_namespace('preserve_alias')
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes