internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: HypothesisWorks/hypothesis

Issue:
arrays() returns views of arrays
Any non-empty array drawn by `arrays()` [will be a view of another array](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.base.html). This is [guaranteed by this line](https://github.com/HypothesisWorks/hypothesis/blob/a81a86caaa25212f7320574bee4655be06eb81e5/hypothesis-python/src/hypothesis/extra/numpy.py#L281).

The obvious problem with this is that the end-user would likely assume that the arrays being drawn are the owners of their own memory. I.e. one would expect the following to pass

```python
@given(arr=arrays(shape=(2, 2), dtype=float)
def test_array_base(arr):
    view = arr[:]
    assert arr.base is None
    assert view.base is arr
```

I hit this issue while working on [this](https://github.com/rsokl/MyGrad/pull/295)

The easiest solution to this is for `arrays()` to simply make a copy before returning the drawn array. I would guess that the added time for copying is minimal relative to the logic of generating the array's contents to begin with.

I will try modifying `arrays()` and will see how it affects the timing for [MyGrad's](https://github.com/rsokl/MyGrad) test-suite. This result will likely be a reliable worse-case-scenario among libraries that leverage `hypothesis.extra.numpy`.


Discussion:

Resolving patch:
diff --git a/hypothesis-python/src/hypothesis/extra/numpy.py b/hypothesis-python/src/hypothesis/extra/numpy.py
--- a/hypothesis-python/src/hypothesis/extra/numpy.py
+++ b/hypothesis-python/src/hypothesis/extra/numpy.py
@@ -278,7 +278,11 @@ def do_draw(self, data):
                 )
             result = out
 
-        return result.reshape(self.shape)
+        result = result.reshape(self.shape).copy()
+
+        assert result.base is None
+
+        return result
 
 
 @check_function


Test patch:
diff --git a/hypothesis-python/tests/numpy/test_gen_data.py b/hypothesis-python/tests/numpy/test_gen_data.py
--- a/hypothesis-python/tests/numpy/test_gen_data.py
+++ b/hypothesis-python/tests/numpy/test_gen_data.py
@@ -1276,3 +1276,14 @@ def test_arrays_selects_consistent_time_unit(data, dtype_str):
 def test_arrays_gives_useful_error_on_inconsistent_time_unit():
     with pytest.raises(InvalidArgument, match="mismatch of time units in dtypes"):
         nps.arrays("m8[Y]", 10, elements=nps.from_dtype(np.dtype("m8[D]"))).example()
+
+
+# addresses https://github.com/HypothesisWorks/hypothesis/issues/2582
+@given(
+    nps.arrays(
+        shape=nps.array_shapes(min_dims=0, min_side=0), dtype=nps.floating_dtypes()
+    )
+)
+def test_array_owns_memory(x: np.ndarray):
+    assert x.base is None
+    assert x[...].base is x
Repository: HypothesisWorks/hypothesis

Issue:
Indicate when a failing example comes from an @example
It would be helpful if hypothesis indicated it in the error message when a failing example case comes from an @example decorator. 


Discussion:
The relevant code will be https://github.com/HypothesisWorks/hypothesis/blob/1bb062f7e0d6ccb6381487cbdd481e1825bf5562/hypothesis-python/src/hypothesis/core.py#L363

Once you've changed this to read e.g. `"Failing example from @example decorator:"`, run the tests - if any fail, update them and you're good to go.  If the all pass, we'll need to write a new test which fails before and passes after this change (and I'll help work out where).

Resolving patch:
diff --git a/hypothesis-python/src/hypothesis/core.py b/hypothesis-python/src/hypothesis/core.py
--- a/hypothesis-python/src/hypothesis/core.py
+++ b/hypothesis-python/src/hypothesis/core.py
@@ -358,8 +358,12 @@ def execute_explicit_examples(state, wrapped_test, arguments, kwargs):
                 if state.settings.report_multiple_bugs:
                     continue
                 break
+            finally:
+                assert fragments_reported[0].startswith("Falsifying example")
+                fragments_reported[0] = fragments_reported[0].replace(
+                    "Falsifying example", "Falsifying explicit example", 1
+                )
 
-            assert fragments_reported[0].startswith("Falsifying example")
             verbose_report(fragments_reported[0].replace("Falsifying", "Trying", 1))
             for f in fragments_reported[1:]:
                 verbose_report(f)


Test patch:
diff --git a/hypothesis-python/tests/cover/test_falsifying_example_output.py b/hypothesis-python/tests/cover/test_falsifying_example_output.py
--- a/hypothesis-python/tests/cover/test_falsifying_example_output.py
+++ b/hypothesis-python/tests/cover/test_falsifying_example_output.py
@@ -19,14 +19,14 @@
 from tests.common.utils import capture_out
 
 OUTPUT_NO_LINE_BREAK = """
-Falsifying example: test(
+Falsifying explicit example: test(
     x=%(input)s, y=%(input)s,
 )
 """
 
 
 OUTPUT_WITH_LINE_BREAK = """
-Falsifying example: test(
+Falsifying explicit example: test(
     x=%(input)s,
     y=%(input)s,
 )
Repository: HypothesisWorks/hypothesis

Issue:
`hypothesis --version` does not work
When I use `pip install hypothesis` in a clear env and run `hypothesis --version`, this happens:

```python
» hypothesis --version
Traceback (most recent call last):
  File "/Users/sobolev/Documents/github/returns/.venv/bin/hypothesis", line 6, in <module>
    from hypothesis.extra.cli import main
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/hypothesis/extra/cli.py", line 35, in <module>
    from hypothesis.extra import ghostwriter
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/hypothesis/extra/ghostwriter.py", line 57, in <module>
    import black
ModuleNotFoundError: No module named 'black'
```

Looks like `black` is treated as a required dependency right now.

After installing `black`:

```
» hypothesis --version
hypothesis, version 5.33.0
```


Discussion:

Resolving patch:
diff --git a/hypothesis-python/src/hypothesis/extra/cli.py b/hypothesis-python/src/hypothesis/extra/cli.py
--- a/hypothesis-python/src/hypothesis/extra/cli.py
+++ b/hypothesis-python/src/hypothesis/extra/cli.py
@@ -32,7 +32,14 @@
 import sys
 from difflib import get_close_matches
 
-from hypothesis.extra import ghostwriter
+MESSAGE = """
+The Hypothesis command-line interface requires the `{}` package,
+which you do not have installed.  Run:
+
+    python -m pip install --upgrade hypothesis[cli]
+
+and try again.
+"""
 
 try:
     import click
@@ -40,16 +47,7 @@
 
     def main():
         """If `click` is not installed, tell the user to install it then exit."""
-        sys.stderr.write(
-            """
-The Hypothesis command-line interface requires the `click` package,
-which you do not have installed.  Run:
-
-    python -m pip install --upgrade hypothesis[cli]
-
-and try again.
-"""
-        )
+        sys.stderr.write(MESSAGE.format("click"))
         sys.exit(1)
 
 
@@ -142,4 +140,10 @@ def write(func, writer, except_, style):  # noqa: D301  # \b disables autowrap
         elif writer == "equivalent" and len(func) == 1:
             writer = "fuzz"
 
+        try:
+            from hypothesis.extra import ghostwriter
+        except ImportError:
+            sys.stderr.write(MESSAGE.format("black"))
+            sys.exit(1)
+
         print(getattr(ghostwriter, writer)(*func, except_=except_ or (), style=style))


Test patch:
Repository: HypothesisWorks/hypothesis

Issue:
provisional.urls strategy does not treat ~ (tilde) as url-safe character
According to [RFC 3986](https://tools.ietf.org/html/rfc3986) tilde character as one of [unreserved characters](https://tools.ietf.org/html/rfc3986#section-2.3) should not be escaped (like dash, underscore or period).


Discussion:

Resolving patch:
diff --git a/hypothesis-python/src/hypothesis/provisional.py b/hypothesis-python/src/hypothesis/provisional.py
--- a/hypothesis-python/src/hypothesis/provisional.py
+++ b/hypothesis-python/src/hypothesis/provisional.py
@@ -34,7 +34,7 @@
 from hypothesis.strategies._internal.ipaddress import ip_addresses
 from hypothesis.strategies._internal.strategies import SearchStrategy
 
-URL_SAFE_CHARACTERS = frozenset(string.ascii_letters + string.digits + "$-_.+!*'(),")
+URL_SAFE_CHARACTERS = frozenset(string.ascii_letters + string.digits + "$-_.+!*'(),~")
 
 
 # This file is sourced from http://data.iana.org/TLD/tlds-alpha-by-domain.txt


Test patch:
diff --git a/hypothesis-python/tests/cover/test_provisional_strategies.py b/hypothesis-python/tests/cover/test_provisional_strategies.py
--- a/hypothesis-python/tests/cover/test_provisional_strategies.py
+++ b/hypothesis-python/tests/cover/test_provisional_strategies.py
@@ -28,7 +28,7 @@
 
 @given(urls())
 def test_is_URL(url):
-    allowed_chars = set(string.ascii_letters + string.digits + "$-_.+!*'(),%/")
+    allowed_chars = set(string.ascii_letters + string.digits + "$-_.+!*'(),~%/")
     url_schemeless = url.split("://", 1)[1]
     path = url_schemeless.split("/", 1)[1] if "/" in url_schemeless else ""
     assert all(c in allowed_chars for c in path)
Repository: HypothesisWorks/hypothesis

Issue:
Framework to migrate CI/CD pipelines to Github Actions
This pull request migrates the Linux and macOS tests from Azure Pipelines to Github Actions, as well as the deploy steps from Travis CI.  It also adds a shell task for migrating the Windows tests.


Discussion:
Thanks @lisushka, this looks awesome :heart_eyes: 

For other reviewers: you can see what runs look like at https://github.com/lisushka/hypothesis/actions

@DRMacIver - you'll need to enable Actions for this repo before it'll have any effect.  If you can also add a `PYPI_DEPLOY_TOKEN` scoped to make new release to the secrets in github settings, I can do the rest.
I can't get rebasing working, so for the authors file, please credit me as Dawn E. Collett.  =)
Closing, as this has been superseded by #2674. 🙂
Thanks again @lisushka - it's mostly your work and I couldn't have done it without you 😊

Resolving patch:
diff --git a/tooling/src/hypothesistooling/__main__.py b/tooling/src/hypothesistooling/__main__.py
--- a/tooling/src/hypothesistooling/__main__.py
+++ b/tooling/src/hypothesistooling/__main__.py
@@ -31,7 +31,7 @@
 TASKS = {}
 BUILD_FILES = tuple(
     os.path.join(tools.ROOT, f)
-    for f in ["tooling", "requirements", ".travis.yml", "hypothesis-python/tox.ini"]
+    for f in ["tooling", "requirements", ".github", "hypothesis-python/tox.ini"]
 )
 
 


Test patch:
Repository: HypothesisWorks/hypothesis

Issue:
Add a PyPy 3.7 ci job
[PyPy now implements Python 3.7](https://morepypy.blogspot.com/2020/09/pypy-732-triple-release-python-27-36.html), so we should add a CI job to test on it once [pyenv adds it to this list](https://github.com/pyenv/pyenv/tree/master/plugins/python-build/share/python-build) (https://github.com/pyenv/pyenv/issues/1699).

Draft: https://github.com/HypothesisWorks/hypothesis/compare/master...Zac-HD:ci-310


Discussion:

Resolving patch:
diff --git a/tooling/src/hypothesistooling/__main__.py b/tooling/src/hypothesistooling/__main__.py
--- a/tooling/src/hypothesistooling/__main__.py
+++ b/tooling/src/hypothesistooling/__main__.py
@@ -361,6 +361,7 @@ def run_tox(task, version):
 PY38 = "3.8.6"
 PY39 = "3.9.0"
 PYPY36 = "pypy3.6-7.3.1"
+PYPY37 = "pypy3.7-7.3.2"
 
 
 @task()
@@ -369,7 +370,7 @@ def install_core():
 
 
 # ALIASES are the executable names for each Python version
-ALIASES = {PYPY36: "pypy3"}
+ALIASES = {PYPY36: "pypy3", PYPY37: "pypy3"}
 
 for n in [PY36, PY37, PY38, PY39]:
     major, minor, patch = n.replace("-dev", ".").split(".")
@@ -410,6 +411,11 @@ def check_pypy36():
     run_tox("pypy3-full", PYPY36)
 
 
+@python_tests
+def check_pypy37():
+    run_tox("pypy3-full", PYPY37)
+
+
 def standard_tox_task(name):
     TASKS["check-" + name] = python_tests(lambda: run_tox(name, PY36))
 


Test patch:
Repository: HypothesisWorks/hypothesis

Issue:
Test against Django 3.2, drop tests for 3.0
https://www.djangoproject.com/weblog/2021/apr/06/django-32-released/


Discussion:

Resolving patch:
diff --git a/tooling/src/hypothesistooling/__main__.py b/tooling/src/hypothesistooling/__main__.py
--- a/tooling/src/hypothesistooling/__main__.py
+++ b/tooling/src/hypothesistooling/__main__.py
@@ -414,7 +414,7 @@ def standard_tox_task(name):
 standard_tox_task("nose")
 standard_tox_task("pytest46")
 
-for n in [22, 30, 31]:
+for n in [22, 31, 32]:
     standard_tox_task(f"django{n}")
 for n in [25, 100, 111]:
     standard_tox_task(f"pandas{n}")


Test patch:
Repository: HypothesisWorks/hypothesis

Issue:
`st.from_regex("", fullmatch=True)` should not generate nonempty strings
```python
@given(st.from_regex("", fullmatch=True))
def test(r):
    assert re.fullmatch("", r)
```

is currently broken, because we have a fast path for the empty pattern which does not check for `fullmatch`:

https://github.com/HypothesisWorks/hypothesis/blob/d4aea1f8ae920ab499e1181a61cb2b798afd5fb0/hypothesis-python/src/hypothesis/strategies/_internal/regex.py#L221-L233

Thanks to @doni69 for reporting this as part of a student project at ANU :slightly_smiling_face: 


Discussion:

Resolving patch:
diff --git a/hypothesis-python/src/hypothesis/strategies/_internal/regex.py b/hypothesis-python/src/hypothesis/strategies/_internal/regex.py
--- a/hypothesis-python/src/hypothesis/strategies/_internal/regex.py
+++ b/hypothesis-python/src/hypothesis/strategies/_internal/regex.py
@@ -226,6 +226,11 @@ def regex_strategy(regex, fullmatch):
 
     parsed = sre_parse.parse(regex.pattern, flags=regex.flags)
 
+    if fullmatch:
+        if not parsed:
+            return st.just("" if is_unicode else b"")
+        return base_regex_strategy(regex, parsed).filter(regex.fullmatch)
+
     if not parsed:
         if is_unicode:
             return st.text()
@@ -244,9 +249,7 @@ def regex_strategy(regex, fullmatch):
     right_pad = base_padding_strategy
     left_pad = base_padding_strategy
 
-    if fullmatch:
-        right_pad = empty
-    elif parsed[-1][0] == sre.AT:
+    if parsed[-1][0] == sre.AT:
         if parsed[-1][1] == sre.AT_END_STRING:
             right_pad = empty
         elif parsed[-1][1] == sre.AT_END:
@@ -256,9 +259,7 @@ def regex_strategy(regex, fullmatch):
                 )
             else:
                 right_pad = st.one_of(empty, newline)
-    if fullmatch:
-        left_pad = empty
-    elif parsed[0][0] == sre.AT:
+    if parsed[0][0] == sre.AT:
         if parsed[0][1] == sre.AT_BEGINNING_STRING:
             left_pad = empty
         elif parsed[0][1] == sre.AT_BEGINNING:


Test patch:
diff --git a/hypothesis-python/tests/cover/test_regex.py b/hypothesis-python/tests/cover/test_regex.py
--- a/hypothesis-python/tests/cover/test_regex.py
+++ b/hypothesis-python/tests/cover/test_regex.py
@@ -432,6 +432,10 @@ def test_fullmatch_generates_example(pattern, matching_str):
 @pytest.mark.parametrize(
     "pattern,eqiv_pattern",
     [
+        (r"", r"\A\Z"),
+        (b"", br"\A\Z"),
+        (r"(?#comment)", r"\A\Z"),
+        (br"(?#comment)", br"\A\Z"),
         ("a", "\\Aa\\Z"),
         ("[Aa]", "\\A[Aa]\\Z"),
         ("[ab]*", "\\A[ab]*\\Z"),
Repository: HypothesisWorks/hypothesis

Issue:
Add PyPy 3.8 to our CI matrix
Now that PyPy has released a version supporting Python 3.8 ([download](https://www.pypy.org/download.html), [changelog](https://doc.pypy.org/en/latest/release-v7.3.6.html)), and [it's been added to `pyenv`](https://github.com/pyenv/pyenv/pull/2111), we should add that to our CI matrix - in [tooling here](https://github.com/HypothesisWorks/hypothesis/blob/4fe7e3c104a4918b0cf99ae3d9f46144f031939a/tooling/src/hypothesistooling/__main__.py#L368-L373), [`tox.ini` here](https://github.com/HypothesisWorks/hypothesis/blob/4fe7e3c104a4918b0cf99ae3d9f46144f031939a/hypothesis-python/tox.ini#L2), and [github actions here](https://github.com/HypothesisWorks/hypothesis/blob/1336278fb4129fa30d36c894f7e6c73dfc2e357a/.github/workflows/main.yml#L29-L30).


Discussion:

Resolving patch:
diff --git a/tooling/src/hypothesistooling/__main__.py b/tooling/src/hypothesistooling/__main__.py
--- a/tooling/src/hypothesistooling/__main__.py
+++ b/tooling/src/hypothesistooling/__main__.py
@@ -360,21 +360,26 @@ def run_tox(task, version):
 
 
 # See update_python_versions() above
+# When adding or removing a version, also update the env lists in tox.ini and
+# workflows/main.yml, and the corresponding @python_tests function below.
 PY36 = "3.6.15"
 PY37 = "3.7.12"
 PY38 = PYMAIN = "3.8.12"  # Sync PYMAIN minor version with GH Actions main.yml
 PY39 = "3.9.7"
 PY310 = "3.10.0"
 PYPY36 = "pypy3.6-7.3.3"
-PYPY37 = "pypy3.7-7.3.5"
+PYPY37 = "pypy3.7-7.3.6"
+PYPY38 = "pypy3.8-7.3.6"
 
 
 # ALIASES are the executable names for each Python version
-ALIASES = {PYPY36: "pypy3", PYPY37: "pypy3"}
-
-for n in [PY36, PY37, PY38, PY39, PY310]:
-    major, minor, patch = n.replace("-dev", ".").split(".")
-    ALIASES[n] = f"python{major}.{minor}"
+ALIASES = {}
+for name, value in list(globals().items()):
+    if name.startswith("PYPY"):
+        ALIASES[value] = "pypy3"
+    elif name.startswith("PY"):
+        major, minor, patch = value.replace("-dev", ".").split(".")
+        ALIASES[value] = f"python{major}.{minor}"
 
 
 python_tests = task(
@@ -422,6 +427,11 @@ def check_pypy37():
     run_tox("pypy3-full", PYPY37)
 
 
+@python_tests
+def check_pypy38():
+    run_tox("pypy3-full", PYPY38)
+
+
 def standard_tox_task(name):
     TASKS["check-" + name] = python_tests(lambda: run_tox(name, PYMAIN))
 


Test patch:
Repository: HypothesisWorks/hypothesis

Issue:
clarification on `note`
https://hypothesis.readthedocs.io/en/latest/details.html#hypothesis.note states

`Report this value in the final execution.`

From my test, `note` wasn't printed on successful run and was printed on falsified run.

Please help me understand this functionality




Discussion:
This is working as intended, the docs could read "for the minimal failing example" instead.

Resolving patch:
diff --git a/hypothesis-python/src/hypothesis/control.py b/hypothesis-python/src/hypothesis/control.py
--- a/hypothesis-python/src/hypothesis/control.py
+++ b/hypothesis-python/src/hypothesis/control.py
@@ -116,7 +116,7 @@ def should_note():
 
 
 def note(value: str) -> None:
-    """Report this value in the final execution."""
+    """Report this value for the minimal failing example."""
     if should_note():
         report(value)
 


Test patch:
Repository: HypothesisWorks/hypothesis

Issue:
Test against Pyjion JIT in CI
https://github.com/tonybaloney/Pyjion has recently reached version 1.0, and so I think it would be appropriate to test against it in our CI.  Implementation-wise, that means installing *CPython* as usual, then adding `pip install pyjion` and running tests with `pyjion -m pytest ...`.  Probably easiest as a new Actions group.


Discussion:

Resolving patch:
diff --git a/tooling/src/hypothesistooling/__main__.py b/tooling/src/hypothesistooling/__main__.py
--- a/tooling/src/hypothesistooling/__main__.py
+++ b/tooling/src/hypothesistooling/__main__.py
@@ -448,6 +448,11 @@ def check_py310():
     run_tox("py310-full", PY310)
 
 
+@python_tests
+def check_py310_pyjion():
+    run_tox("py310-pyjion", PY310)
+
+
 @python_tests
 def check_pypy36():
     run_tox("pypy3-full", PYPY36)
@@ -472,7 +477,7 @@ def standard_tox_task(name):
 
 for n in [22, 31, 32]:
     standard_tox_task(f"django{n}")
-for n in [25, 100, 111]:
+for n in [25, 10, 11, 12, 13]:
     standard_tox_task(f"pandas{n}")
 
 standard_tox_task("coverage")


Test patch:
diff --git a/hypothesis-python/tests/common/setup.py b/hypothesis-python/tests/common/setup.py
--- a/hypothesis-python/tests/common/setup.py
+++ b/hypothesis-python/tests/common/setup.py
@@ -17,6 +17,12 @@
 from tempfile import mkdtemp
 from warnings import filterwarnings
 
+if os.getenv("HYPOTHESIS_PYJION") == "true":
+    # Hacky workaround for upstream bug; see comment in tox.ini
+    import pyjion
+
+    pyjion.enable()
+
 from hypothesis import Verbosity, settings
 from hypothesis._settings import not_set
 from hypothesis.configuration import set_hypothesis_home_dir
Repository: HypothesisWorks/hypothesis

Issue:
DataFrame examples are nearly unreadable
I have a test that takes a couple of Pandas DataFrames as input.  When the test fails, the examples in the output can be very hard to make sense of:

```
Falsifying example: test_always_increasing(
    df_a=            A
    2021-01-01  1, df_b=            A
    2021-01-01  0
    2021-01-02  0,
)
```

If I add the following line in my test setup:

```
pd.DataFrame._repr_pretty_ = lambda self, p, cycle: p.text(f"\n{self}\n")
```

then the output is much clearer:

```
Falsifying example: test_always_increasing(
    df_a=
            A
2021-01-01  1
,
    df_b=
            A
2021-01-01  0
2021-01-02  0
,
)
```

Would you accept a patch that always sets `pd.DataFrame._repr_pretty_`?  (Assuming Pandas is installed and that `pd.DataFrame._repr_pretty_` isn't already set...)


Discussion:

Resolving patch:
diff --git a/hypothesis-python/src/hypothesis/vendor/pretty.py b/hypothesis-python/src/hypothesis/vendor/pretty.py
--- a/hypothesis-python/src/hypothesis/vendor/pretty.py
+++ b/hypothesis-python/src/hypothesis/vendor/pretty.py
@@ -837,14 +837,16 @@ def _counter_pprint(obj, p, cycle):
             p.pretty(dict(obj))
 
 
+def _repr_dataframe(obj, p, cycle):  # pragma: no cover
+    with p.indent(4):
+        p.break_()
+        _repr_pprint(obj, p, cycle)
+    p.break_()
+
+
 for_type_by_name("collections", "defaultdict", _defaultdict_pprint)
 for_type_by_name("collections", "OrderedDict", _ordereddict_pprint)
 for_type_by_name("ordereddict", "OrderedDict", _ordereddict_pprint)
 for_type_by_name("collections", "deque", _deque_pprint)
 for_type_by_name("collections", "Counter", _counter_pprint)
-for_type_by_name("counter", "Counter", _counter_pprint)
-
-for_type_by_name("_collections", "defaultdict", _defaultdict_pprint)
-for_type_by_name("_collections", "OrderedDict", _ordereddict_pprint)
-for_type_by_name("_collections", "deque", _deque_pprint)
-for_type_by_name("_collections", "Counter", _counter_pprint)
+for_type_by_name("pandas.core.frame", "DataFrame", _repr_dataframe)


Test patch: