hypothesis 6.135.3__tar.gz → 6.135.5__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 (119) hide show
  1. {hypothesis-6.135.3 → hypothesis-6.135.5}/PKG-INFO +1 -1
  2. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/core.py +14 -1
  3. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/providers.py +1 -1
  4. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/constants_ast.py +36 -8
  5. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/version.py +1 -1
  6. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis.egg-info/PKG-INFO +1 -1
  7. {hypothesis-6.135.3 → hypothesis-6.135.5}/LICENSE.txt +0 -0
  8. {hypothesis-6.135.3 → hypothesis-6.135.5}/README.md +0 -0
  9. {hypothesis-6.135.3 → hypothesis-6.135.5}/pyproject.toml +0 -0
  10. {hypothesis-6.135.3 → hypothesis-6.135.5}/setup.cfg +0 -0
  11. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/_hypothesis_ftz_detector.py +0 -0
  12. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/_hypothesis_globals.py +0 -0
  13. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/_hypothesis_pytestplugin.py +0 -0
  14. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/__init__.py +0 -0
  15. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/_settings.py +0 -0
  16. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/configuration.py +0 -0
  17. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/control.py +0 -0
  18. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/database.py +0 -0
  19. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/entry_points.py +0 -0
  20. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/errors.py +0 -0
  21. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/__init__.py +0 -0
  22. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/_array_helpers.py +0 -0
  23. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/_patching.py +0 -0
  24. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/array_api.py +0 -0
  25. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/cli.py +0 -0
  26. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/codemods.py +0 -0
  27. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/dateutil.py +0 -0
  28. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/django/__init__.py +0 -0
  29. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/django/_fields.py +0 -0
  30. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/django/_impl.py +0 -0
  31. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/dpcontracts.py +0 -0
  32. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/ghostwriter.py +0 -0
  33. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/lark.py +0 -0
  34. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/numpy.py +0 -0
  35. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/pandas/__init__.py +0 -0
  36. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/pandas/impl.py +0 -0
  37. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/pytestplugin.py +0 -0
  38. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/pytz.py +0 -0
  39. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/extra/redis.py +0 -0
  40. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/__init__.py +0 -0
  41. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/cache.py +0 -0
  42. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/cathetus.py +0 -0
  43. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/charmap.py +0 -0
  44. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/compat.py +0 -0
  45. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/__init__.py +0 -0
  46. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/choice.py +0 -0
  47. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/data.py +0 -0
  48. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/datatree.py +0 -0
  49. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/dfa/__init__.py +0 -0
  50. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/dfa/lstar.py +0 -0
  51. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/engine.py +0 -0
  52. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/floats.py +0 -0
  53. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/junkdrawer.py +0 -0
  54. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/optimiser.py +0 -0
  55. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/pareto.py +0 -0
  56. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/provider_conformance.py +0 -0
  57. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/shrinker.py +0 -0
  58. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/shrinking/__init__.py +0 -0
  59. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/shrinking/bytes.py +0 -0
  60. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/shrinking/choicetree.py +0 -0
  61. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/shrinking/collection.py +0 -0
  62. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/shrinking/common.py +0 -0
  63. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/shrinking/floats.py +0 -0
  64. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/shrinking/integer.py +0 -0
  65. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/shrinking/ordering.py +0 -0
  66. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/shrinking/string.py +0 -0
  67. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/conjecture/utils.py +0 -0
  68. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/coverage.py +0 -0
  69. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/detection.py +0 -0
  70. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/entropy.py +0 -0
  71. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/escalation.py +0 -0
  72. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/filtering.py +0 -0
  73. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/floats.py +0 -0
  74. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/healthcheck.py +0 -0
  75. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/intervalsets.py +0 -0
  76. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/observability.py +0 -0
  77. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/reflection.py +0 -0
  78. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/scrutineer.py +0 -0
  79. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/internal/validation.py +0 -0
  80. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/provisional.py +0 -0
  81. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/py.typed +0 -0
  82. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/reporting.py +0 -0
  83. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/stateful.py +0 -0
  84. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/statistics.py +0 -0
  85. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/__init__.py +0 -0
  86. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/__init__.py +0 -0
  87. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/attrs.py +0 -0
  88. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/collections.py +0 -0
  89. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/core.py +0 -0
  90. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/datetime.py +0 -0
  91. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/deferred.py +0 -0
  92. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/featureflags.py +0 -0
  93. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/flatmapped.py +0 -0
  94. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/functions.py +0 -0
  95. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/ipaddress.py +0 -0
  96. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/lazy.py +0 -0
  97. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/misc.py +0 -0
  98. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/numbers.py +0 -0
  99. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/random.py +0 -0
  100. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/recursive.py +0 -0
  101. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/regex.py +0 -0
  102. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/shared.py +0 -0
  103. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/strategies.py +0 -0
  104. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/strings.py +0 -0
  105. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/types.py +0 -0
  106. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/strategies/_internal/utils.py +0 -0
  107. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/utils/__init__.py +0 -0
  108. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/utils/conventions.py +0 -0
  109. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/utils/dynamicvariables.py +0 -0
  110. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/utils/terminal.py +0 -0
  111. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/vendor/__init__.py +0 -0
  112. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/vendor/pretty.py +0 -0
  113. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis/vendor/tlds-alpha-by-domain.txt +0 -0
  114. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis.egg-info/SOURCES.txt +0 -0
  115. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis.egg-info/dependency_links.txt +0 -0
  116. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis.egg-info/entry_points.txt +0 -0
  117. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis.egg-info/requires.txt +0 -0
  118. {hypothesis-6.135.3 → hypothesis-6.135.5}/src/hypothesis.egg-info/top_level.txt +0 -0
  119. {hypothesis-6.135.3 → hypothesis-6.135.5}/tests/test_annotated_types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hypothesis
3
- Version: 6.135.3
3
+ Version: 6.135.5
4
4
  Summary: A library for property-based testing
5
5
  Author-email: "David R. MacIver and Zac Hatfield-Dodds" <david@drmaciver.com>
6
6
  License-Expression: MPL-2.0
@@ -1781,7 +1781,20 @@ def given(
1781
1781
  if inspect.isclass(test):
1782
1782
  # Provide a meaningful error to users, instead of exceptions from
1783
1783
  # internals that assume we're dealing with a function.
1784
- raise InvalidArgument("@given cannot be applied to a class.")
1784
+ raise InvalidArgument("@given cannot be applied to a class")
1785
+
1786
+ if (
1787
+ "_pytest" in sys.modules
1788
+ and (
1789
+ tuple(map(int, sys.modules["_pytest"].__version__.split(".")[:2]))
1790
+ >= (8, 4)
1791
+ )
1792
+ and isinstance(
1793
+ test, sys.modules["_pytest"].fixtures.FixtureFunctionDefinition
1794
+ )
1795
+ ): # pragma: no cover # covered by pytest/test_fixtures, but not by cover/
1796
+ raise InvalidArgument("@given cannot be applied to a pytest fixture")
1797
+
1785
1798
  given_arguments = tuple(_given_arguments)
1786
1799
  given_kwargs = dict(_given_kwargs)
1787
1800
 
@@ -568,7 +568,7 @@ class PrimitiveProvider(abc.ABC):
568
568
  .. important::
569
569
 
570
570
  For |PrimitiveProvider.on_observation| to be called by Hypothesis,
571
- |PrimitiveProvider.add_observability_callback| must be set to ``True``,
571
+ |PrimitiveProvider.add_observability_callback| must be set to ``True``.
572
572
 
573
573
  |PrimitiveProvider.on_observation| is explicitly opt-in, as enabling
574
574
  observability might increase runtime or memory usage.
@@ -98,12 +98,24 @@ class Constants:
98
98
  )
99
99
 
100
100
 
101
+ class TooManyConstants(Exception):
102
+ # a control flow exception which we raise in ConstantsVisitor when the
103
+ # number of constants in a module gets too large.
104
+ pass
105
+
106
+
101
107
  class ConstantVisitor(NodeVisitor):
102
- def __init__(self):
108
+ CONSTANTS_LIMIT: int = 1024
109
+
110
+ def __init__(self, *, limit: bool):
103
111
  super().__init__()
104
112
  self.constants = Constants()
113
+ self.limit = limit
105
114
 
106
115
  def _add_constant(self, value: object) -> None:
116
+ if self.limit and len(self.constants) >= self.CONSTANTS_LIMIT:
117
+ raise TooManyConstants
118
+
107
119
  if isinstance(value, str) and (
108
120
  value.isspace()
109
121
  or value == ""
@@ -166,15 +178,22 @@ class ConstantVisitor(NodeVisitor):
166
178
  self.generic_visit(node)
167
179
 
168
180
 
169
- def _constants_from_source(source: Union[str, bytes]) -> Constants:
181
+ def _constants_from_source(source: Union[str, bytes], *, limit: bool) -> Constants:
170
182
  tree = ast.parse(source)
171
- visitor = ConstantVisitor()
172
- visitor.visit(tree)
183
+ visitor = ConstantVisitor(limit=limit)
184
+
185
+ try:
186
+ visitor.visit(tree)
187
+ except TooManyConstants:
188
+ # in the case of an incomplete collection, return nothing, to avoid
189
+ # muddying caches etc.
190
+ return Constants()
191
+
173
192
  return visitor.constants
174
193
 
175
194
 
176
195
  @lru_cache(4096)
177
- def constants_from_module(module: ModuleType) -> Constants:
196
+ def constants_from_module(module: ModuleType, *, limit: bool = True) -> Constants:
178
197
  try:
179
198
  module_file = inspect.getsourcefile(module)
180
199
  # use type: ignore because we know this might error
@@ -182,17 +201,26 @@ def constants_from_module(module: ModuleType) -> Constants:
182
201
  except Exception:
183
202
  return Constants()
184
203
 
204
+ if limit and len(source_bytes) > 512 * 1024:
205
+ # Skip files over 512kb. For reference, the largest source file
206
+ # in Hypothesis is strategies/_internal/core.py at 107kb at time
207
+ # of writing.
208
+ return Constants()
209
+
185
210
  source_hash = hashlib.sha1(source_bytes).hexdigest()[:16]
186
- cache_p = storage_directory("constants") / source_hash
211
+ # separate cache files for each limit param. see discussion in pull/4398
212
+ cache_p = storage_directory("constants") / (
213
+ source_hash + ("" if limit else "_nolimit")
214
+ )
187
215
  try:
188
- return _constants_from_source(cache_p.read_bytes())
216
+ return _constants_from_source(cache_p.read_bytes(), limit=limit)
189
217
  except Exception:
190
218
  # if the cached location doesn't exist, or it does exist but there was
191
219
  # a problem reading it, fall back to standard computation of the constants
192
220
  pass
193
221
 
194
222
  try:
195
- constants = _constants_from_source(source_bytes)
223
+ constants = _constants_from_source(source_bytes, limit=limit)
196
224
  except Exception:
197
225
  # A bunch of things can go wrong here.
198
226
  # * ast.parse may fail on the source code
@@ -8,5 +8,5 @@
8
8
  # v. 2.0. If a copy of the MPL was not distributed with this file, You can
9
9
  # obtain one at https://mozilla.org/MPL/2.0/.
10
10
 
11
- __version_info__ = (6, 135, 3)
11
+ __version_info__ = (6, 135, 5)
12
12
  __version__ = ".".join(map(str, __version_info__))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hypothesis
3
- Version: 6.135.3
3
+ Version: 6.135.5
4
4
  Summary: A library for property-based testing
5
5
  Author-email: "David R. MacIver and Zac Hatfield-Dodds" <david@drmaciver.com>
6
6
  License-Expression: MPL-2.0
File without changes
File without changes
File without changes