Repository: HypothesisWorks/hypothesis

Issue:
Deprecated `HealthCheck.all()` and add a codemod to convert it to `list(HealthCheck)`
As discussed in https://github.com/HypothesisWorks/hypothesis/pull/3581#discussion_r1133324142

https://github.com/HypothesisWorks/hypothesis/blob/b288c2ab56c107296f8652b67870c503026a39d7/hypothesis-python/src/hypothesis/_settings.py#L464-L468
Turn the `return_value` and `not_a_test_method` health checks into strict errors
This is pretty much just code cleanup: unlike the other healthchecks which are basically performance checks, I'm pretty sure there's *never* a situation where disabling these allows you to do something useful.  I think we should therefore:

- Turn the `return_value` and `not_a_test_method` health checks into strict errors.
- Define `HealthCheck.__iter__()` and `.all()` such that they're omitted from that
- Use `note_deprecation()` if the attributes are accessed on `HealthCheck`
- Merge [the healthcheck docs](https://hypothesis.readthedocs.io/en/latest/healthchecks.html) into the main settings docs
- [me, after we merge] add a redirect on readthedocs to avoid 404'ing links
Compatibility of hypothesis with Python3.11x
Hi Folks,
According to the [PyPi Doc](https://pypi.org/project/hypothesis/) the latest support of hypothesis is for Python 3.10.
Does it also supports python 3.11x?
if not is there any plan to support it?


Discussion:

Resolving patch:
diff --git a/hypothesis-python/setup.py b/hypothesis-python/setup.py
--- a/hypothesis-python/setup.py
+++ b/hypothesis-python/setup.py
@@ -122,6 +122,7 @@ def local_file(name):
         "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: 3.9",
         "Programming Language :: Python :: 3.10",
+        "Programming Language :: Python :: 3.11",
         "Programming Language :: Python :: Implementation :: CPython",
         "Programming Language :: Python :: Implementation :: PyPy",
         "Topic :: Education :: Testing",
diff --git a/hypothesis-python/src/hypothesis/_settings.py b/hypothesis-python/src/hypothesis/_settings.py
--- a/hypothesis-python/src/hypothesis/_settings.py
+++ b/hypothesis-python/src/hypothesis/_settings.py
@@ -464,7 +464,11 @@ def __repr__(self):
     @classmethod
     def all(cls) -> List["HealthCheck"]:
         # Skipping of deprecated attributes is handled in HealthCheckMeta.__iter__
-        # TODO: note_deprecation() and write a codemod for HC.all() -> list(HC)
+        note_deprecation(
+            f"`Healthcheck.all()` is deprecated; use `list(HealthCheck)` instead.",
+            since="RELEASEDAY",
+            has_codemod=True,
+        )
         return list(HealthCheck)
 
     data_too_large = 1
diff --git a/hypothesis-python/src/hypothesis/extra/codemods.py b/hypothesis-python/src/hypothesis/extra/codemods.py
--- a/hypothesis-python/src/hypothesis/extra/codemods.py
+++ b/hypothesis-python/src/hypothesis/extra/codemods.py
@@ -222,3 +222,16 @@ def leave_Call(self, original_node, updated_node):
             for p, arg in zip(params, updated_node.args)
         ]
         return updated_node.with_changes(args=newargs)
+
+
+class HypothesisFixHealthcheckAll(VisitorBasedCodemodCommand):
+    """Replace Healthcheck.all() with list(Healthcheck)"""
+
+    DESCRIPTION = "Replace Healthcheck.all() with list(Healthcheck)"
+
+    @m.leave(m.Call(func=m.Attribute(m.Name("Healthcheck"), m.Name("all")), args=[]))
+    def replace_healthcheck(self, original_node, updated_node):
+        return updated_node.with_changes(
+            func=cst.Name("list"),
+            args=[cst.Arg(value=cst.Name("Healthcheck"))],
+        )


Test patch:
diff --git a/hypothesis-python/tests/codemods/test_codemods.py b/hypothesis-python/tests/codemods/test_codemods.py
--- a/hypothesis-python/tests/codemods/test_codemods.py
+++ b/hypothesis-python/tests/codemods/test_codemods.py
@@ -131,3 +131,19 @@ def test_noop_with_too_many_arguments_passed(self) -> None:
             st.sets(st.integers(), 0, 1, True)
         """
         self.assertCodemod(before=before, after=before)
+
+
+class TestHealthcheckAll(CodemodTest):
+    TRANSFORM = codemods.HypothesisFixHealthcheckAll
+
+    def test_noop_other_attributes(self):
+        # Test that calls to other attributes of Healthcheck are not modified
+        before = "result = Healthcheck.data_too_large"
+        self.assertCodemod(before=before, after=before)
+
+    def test_substitution(self) -> None:
+        # Test that Healthcheck.all() is replaced with list(Healthcheck)
+        before = "result = Healthcheck.all()"
+        after = "result = list(Healthcheck)"
+        # self.assertEqual(run_codemod(input_code), expected_code)
+        self.assertCodemod(before=before, after=after)
diff --git a/hypothesis-python/tests/cover/test_settings.py b/hypothesis-python/tests/cover/test_settings.py
--- a/hypothesis-python/tests/cover/test_settings.py
+++ b/hypothesis-python/tests/cover/test_settings.py
@@ -34,7 +34,12 @@
 from hypothesis.stateful import RuleBasedStateMachine, rule
 from hypothesis.utils.conventions import not_set
 
-from tests.common.utils import counts_calls, fails_with, validate_deprecation
+from tests.common.utils import (
+    checks_deprecated_behaviour,
+    counts_calls,
+    fails_with,
+    validate_deprecation,
+)
 
 
 def test_has_docstrings():
@@ -492,6 +497,7 @@ def test_deprecated_settings_warn_on_set_settings():
         settings(suppress_health_check=[HealthCheck.not_a_test_method])
 
 
+@checks_deprecated_behaviour
 def test_deprecated_settings_not_in_settings_all_list():
     al = HealthCheck.all()
     ls = list(HealthCheck)