hypothesis 6.135.12__tar.gz → 6.135.14__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.12 → hypothesis-6.135.14}/PKG-INFO +1 -1
  2. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/ghostwriter.py +3 -1
  3. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/reflection.py +1 -1
  4. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/stateful.py +6 -2
  5. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/core.py +15 -9
  6. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/strategies.py +30 -14
  7. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/version.py +1 -1
  8. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis.egg-info/PKG-INFO +1 -1
  9. {hypothesis-6.135.12 → hypothesis-6.135.14}/LICENSE.txt +0 -0
  10. {hypothesis-6.135.12 → hypothesis-6.135.14}/README.md +0 -0
  11. {hypothesis-6.135.12 → hypothesis-6.135.14}/pyproject.toml +0 -0
  12. {hypothesis-6.135.12 → hypothesis-6.135.14}/setup.cfg +0 -0
  13. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/_hypothesis_ftz_detector.py +0 -0
  14. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/_hypothesis_globals.py +0 -0
  15. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/_hypothesis_pytestplugin.py +0 -0
  16. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/__init__.py +0 -0
  17. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/_settings.py +0 -0
  18. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/configuration.py +0 -0
  19. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/control.py +0 -0
  20. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/core.py +0 -0
  21. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/database.py +0 -0
  22. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/entry_points.py +0 -0
  23. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/errors.py +0 -0
  24. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/__init__.py +0 -0
  25. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/_array_helpers.py +0 -0
  26. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/_patching.py +0 -0
  27. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/array_api.py +0 -0
  28. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/cli.py +0 -0
  29. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/codemods.py +0 -0
  30. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/dateutil.py +0 -0
  31. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/django/__init__.py +0 -0
  32. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/django/_fields.py +0 -0
  33. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/django/_impl.py +0 -0
  34. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/dpcontracts.py +0 -0
  35. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/lark.py +0 -0
  36. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/numpy.py +0 -0
  37. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/pandas/__init__.py +0 -0
  38. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/pandas/impl.py +0 -0
  39. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/pytestplugin.py +0 -0
  40. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/pytz.py +0 -0
  41. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/extra/redis.py +0 -0
  42. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/__init__.py +0 -0
  43. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/cache.py +0 -0
  44. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/cathetus.py +0 -0
  45. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/charmap.py +0 -0
  46. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/compat.py +0 -0
  47. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/__init__.py +0 -0
  48. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/choice.py +0 -0
  49. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/data.py +0 -0
  50. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/datatree.py +0 -0
  51. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/dfa/__init__.py +0 -0
  52. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/dfa/lstar.py +0 -0
  53. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/engine.py +0 -0
  54. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/floats.py +0 -0
  55. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/junkdrawer.py +0 -0
  56. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/optimiser.py +0 -0
  57. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/pareto.py +0 -0
  58. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/provider_conformance.py +0 -0
  59. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/providers.py +0 -0
  60. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/shrinker.py +0 -0
  61. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/shrinking/__init__.py +0 -0
  62. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/shrinking/bytes.py +0 -0
  63. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/shrinking/choicetree.py +0 -0
  64. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/shrinking/collection.py +0 -0
  65. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/shrinking/common.py +0 -0
  66. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/shrinking/floats.py +0 -0
  67. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/shrinking/integer.py +0 -0
  68. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/shrinking/ordering.py +0 -0
  69. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/shrinking/string.py +0 -0
  70. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/conjecture/utils.py +0 -0
  71. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/constants_ast.py +0 -0
  72. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/coverage.py +0 -0
  73. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/detection.py +0 -0
  74. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/entropy.py +0 -0
  75. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/escalation.py +0 -0
  76. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/filtering.py +0 -0
  77. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/floats.py +0 -0
  78. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/healthcheck.py +0 -0
  79. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/intervalsets.py +0 -0
  80. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/observability.py +0 -0
  81. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/scrutineer.py +0 -0
  82. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/internal/validation.py +0 -0
  83. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/provisional.py +0 -0
  84. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/py.typed +0 -0
  85. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/reporting.py +0 -0
  86. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/statistics.py +0 -0
  87. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/__init__.py +0 -0
  88. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/__init__.py +0 -0
  89. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/attrs.py +0 -0
  90. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/collections.py +0 -0
  91. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/datetime.py +0 -0
  92. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/deferred.py +0 -0
  93. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/featureflags.py +0 -0
  94. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/flatmapped.py +0 -0
  95. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/functions.py +0 -0
  96. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/ipaddress.py +0 -0
  97. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/lazy.py +0 -0
  98. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/misc.py +0 -0
  99. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/numbers.py +0 -0
  100. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/random.py +0 -0
  101. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/recursive.py +0 -0
  102. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/regex.py +0 -0
  103. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/shared.py +0 -0
  104. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/strings.py +0 -0
  105. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/types.py +0 -0
  106. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/strategies/_internal/utils.py +0 -0
  107. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/utils/__init__.py +0 -0
  108. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/utils/conventions.py +0 -0
  109. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/utils/dynamicvariables.py +0 -0
  110. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/utils/terminal.py +0 -0
  111. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/vendor/__init__.py +0 -0
  112. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/vendor/pretty.py +0 -0
  113. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis/vendor/tlds-alpha-by-domain.txt +0 -0
  114. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis.egg-info/SOURCES.txt +0 -0
  115. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis.egg-info/dependency_links.txt +0 -0
  116. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis.egg-info/entry_points.txt +0 -0
  117. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis.egg-info/requires.txt +0 -0
  118. {hypothesis-6.135.12 → hypothesis-6.135.14}/src/hypothesis.egg-info/top_level.txt +0 -0
  119. {hypothesis-6.135.12 → hypothesis-6.135.14}/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.12
3
+ Version: 6.135.14
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
@@ -687,9 +687,11 @@ def _valid_syntax_repr(strategy):
687
687
  elems.append(s)
688
688
  seen.add(repr(s))
689
689
  strategy = st.one_of(elems or st.nothing())
690
- # Trivial special case because the wrapped repr for text() is terrible.
690
+ # hardcode some special cases for nicer reprs
691
691
  if strategy == st.text().wrapped_strategy:
692
692
  return set(), "text()"
693
+ if strategy == st.from_type(type):
694
+ return set(), "from_type(type)"
693
695
  # Remove any typevars; we don't exploit them so they're just clutter here
694
696
  if (
695
697
  isinstance(strategy, LazyStrategy)
@@ -453,7 +453,7 @@ def get_pretty_function_description(f: object) -> str:
453
453
  return pretty(f)
454
454
  if not hasattr(f, "__name__"):
455
455
  return repr(f)
456
- name = f.__name__ # type: ignore # validated by hasattr above
456
+ name = f.__name__ # type: ignore
457
457
  if name == "<lambda>":
458
458
  return extract_lambda_source(f)
459
459
  elif isinstance(f, (types.MethodType, types.BuiltinMethodType)):
@@ -504,8 +504,12 @@ class Rule:
504
504
  self.bundles = tuple(bundles)
505
505
 
506
506
  def __repr__(self) -> str:
507
- rep = get_pretty_function_description
508
- bits = [f"{k}={rep(v)}" for k, v in dataclasses.asdict(self).items() if v]
507
+ bits = [
508
+ f"{field.name}="
509
+ f"{get_pretty_function_description(getattr(self, field.name))}"
510
+ for field in dataclasses.fields(self)
511
+ if getattr(self, field.name)
512
+ ]
509
513
  return f"{self.__class__.__name__}({', '.join(bits)})"
510
514
 
511
515
 
@@ -196,13 +196,17 @@ def sampled_from(
196
196
  that behaviour, use ``sampled_from(seq) if seq else nothing()``.
197
197
  """
198
198
  values = check_sample(elements, "sampled_from")
199
- try:
200
- if isinstance(elements, type) and issubclass(elements, enum.Enum):
201
- repr_ = f"sampled_from({elements.__module__}.{elements.__name__})"
202
- else:
203
- repr_ = f"sampled_from({elements!r})"
204
- except Exception: # pragma: no cover
205
- repr_ = None
199
+ force_repr = None
200
+ # check_sample converts to tuple unconditionally, but we want to preserve
201
+ # square braces for list reprs.
202
+ # This will not cover custom sequence implementations which return different
203
+ # braces (or other, more unusual things) for their reprs, but this is a tradeoff
204
+ # between repr accuracy and greedily-evaluating all sequence reprs (at great
205
+ # cost for large sequences).
206
+ force_repr_braces = ("[", "]") if isinstance(elements, list) else None
207
+ if isinstance(elements, type) and issubclass(elements, enum.Enum):
208
+ force_repr = f"sampled_from({elements.__module__}.{elements.__name__})"
209
+
206
210
  if isclass(elements) and issubclass(elements, enum.Flag):
207
211
  # Combinations of enum.Flag members (including empty) are also members. We generate these
208
212
  # dynamically, because static allocation takes O(2^n) memory. LazyStrategy is used for the
@@ -237,7 +241,7 @@ def sampled_from(
237
241
  .flatmap(lambda r: sets(sampled_from(flags), min_size=r, max_size=r))
238
242
  .map(lambda s: elements(reduce(operator.or_, s))),
239
243
  ]
240
- return LazyStrategy(one_of, args=inner, kwargs={}, force_repr=repr_)
244
+ return LazyStrategy(one_of, args=inner, kwargs={}, force_repr=force_repr)
241
245
  if not values:
242
246
  if (
243
247
  isinstance(elements, type)
@@ -253,7 +257,9 @@ def sampled_from(
253
257
  raise InvalidArgument("Cannot sample from a length-zero sequence.")
254
258
  if len(values) == 1:
255
259
  return just(values[0])
256
- return SampledFromStrategy(values, repr_)
260
+ return SampledFromStrategy(
261
+ values, force_repr=force_repr, force_repr_braces=force_repr_braces
262
+ )
257
263
 
258
264
 
259
265
  @cacheable
@@ -537,7 +537,9 @@ class SampledFromStrategy(SearchStrategy[Ex]):
537
537
  def __init__(
538
538
  self,
539
539
  elements: Sequence[Ex],
540
- repr_: Optional[str] = None,
540
+ *,
541
+ force_repr: Optional[str] = None,
542
+ force_repr_braces: Optional[tuple[str, str]] = None,
541
543
  transformations: tuple[
542
544
  tuple[Literal["filter", "map"], Callable[[Ex], Any]],
543
545
  ...,
@@ -546,13 +548,17 @@ class SampledFromStrategy(SearchStrategy[Ex]):
546
548
  super().__init__()
547
549
  self.elements = cu.check_sample(elements, "sampled_from")
548
550
  assert self.elements
549
- self.repr_ = repr_
551
+ self.force_repr = force_repr
552
+ self.force_repr_braces = force_repr_braces
550
553
  self._transformations = transformations
551
554
 
555
+ self._cached_repr: Optional[str] = None
556
+
552
557
  def map(self, pack: Callable[[Ex], T]) -> SearchStrategy[T]:
553
558
  s = type(self)(
554
559
  self.elements,
555
- repr_=self.repr_,
560
+ force_repr=self.force_repr,
561
+ force_repr_braces=self.force_repr_braces,
556
562
  transformations=(*self._transformations, ("map", pack)),
557
563
  )
558
564
  # guaranteed by the ("map", pack) transformation
@@ -561,20 +567,30 @@ class SampledFromStrategy(SearchStrategy[Ex]):
561
567
  def filter(self, condition: Callable[[Ex], Any]) -> SearchStrategy[Ex]:
562
568
  return type(self)(
563
569
  self.elements,
564
- repr_=self.repr_,
570
+ force_repr=self.force_repr,
571
+ force_repr_braces=self.force_repr_braces,
565
572
  transformations=(*self._transformations, ("filter", condition)),
566
573
  )
567
574
 
568
- def __repr__(self) -> str:
569
- return (
570
- self.repr_
571
- or "sampled_from(["
572
- + ", ".join(map(get_pretty_function_description, self.elements))
573
- + "])"
574
- ) + "".join(
575
- f".{name}({get_pretty_function_description(f)})"
576
- for name, f in self._transformations
577
- )
575
+ def __repr__(self):
576
+ if self._cached_repr is None:
577
+ rep = get_pretty_function_description
578
+ elements_s = (
579
+ ", ".join(rep(v) for v in self.elements[:512]) + ", ..."
580
+ if len(self.elements) > 512
581
+ else ", ".join(rep(v) for v in self.elements)
582
+ )
583
+ braces = self.force_repr_braces or ("(", ")")
584
+ instance_s = (
585
+ self.force_repr or f"sampled_from({braces[0]}{elements_s}{braces[1]})"
586
+ )
587
+ transforms_s = "".join(
588
+ f".{name}({get_pretty_function_description(f)})"
589
+ for name, f in self._transformations
590
+ )
591
+ repr_s = instance_s + transforms_s
592
+ self._cached_repr = repr_s
593
+ return self._cached_repr
578
594
 
579
595
  def calc_label(self) -> int:
580
596
  # strategy.label is effectively an under-approximation of structural
@@ -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, 12)
11
+ __version_info__ = (6, 135, 14)
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.12
3
+ Version: 6.135.14
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