We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `hypothesis-python/src/hypothesis/control.py`
Content:
```
1 # This file is part of Hypothesis, which may be found at
2 # https://github.com/HypothesisWorks/hypothesis/
3 #
4 # Most of this work is copyright (C) 2013-2021 David R. MacIver
5 # (david@drmaciver.com), but it contains contributions by others. See
6 # CONTRIBUTING.rst for a full list of people who may hold copyright, and
7 # consult the git log if you need to determine who owns an individual
8 # contribution.
9 #
10 # This Source Code Form is subject to the terms of the Mozilla Public License,
11 # v. 2.0. If a copy of the MPL was not distributed with this file, You can
12 # obtain one at https://mozilla.org/MPL/2.0/.
13 #
14 # END HEADER
15 
16 import math
17 import traceback
18 from typing import NoReturn, Union
19 
20 from hypothesis import Verbosity, settings
21 from hypothesis.errors import CleanupFailed, InvalidArgument, UnsatisfiedAssumption
22 from hypothesis.internal.conjecture.data import ConjectureData
23 from hypothesis.internal.validation import check_type
24 from hypothesis.reporting import report, verbose_report
25 from hypothesis.utils.dynamicvariables import DynamicVariable
26 
27 
28 def reject() -> NoReturn:
29     raise UnsatisfiedAssumption()
30 
31 
32 def assume(condition: object) -> bool:
33     """Calling ``assume`` is like an :ref:`assert <python:assert>` that marks
34     the example as bad, rather than failing the test.
35 
36     This allows you to specify properties that you *assume* will be
37     true, and let Hypothesis try to avoid similar examples in future.
38     """
39     if not condition:
40         raise UnsatisfiedAssumption()
41     return True
42 
43 
44 _current_build_context = DynamicVariable(None)
45 
46 
47 def currently_in_test_context() -> bool:
48     """Return ``True`` if the calling code is currently running inside an
49     :func:`@given <hypothesis.given>` or :doc:`stateful <stateful>` test,
50     ``False`` otherwise.
51 
52     This is useful for third-party integrations and assertion helpers which
53     may be called from traditional or property-based tests, but can only use
54     :func:`~hypothesis.assume` or :func:`~hypothesis.target` in the latter case.
55     """
56     return _current_build_context.value is not None
57 
58 
59 def current_build_context():
60     context = _current_build_context.value
61     if context is None:
62         raise InvalidArgument("No build context registered")
63     return context
64 
65 
66 class BuildContext:
67     def __init__(self, data, is_final=False, close_on_capture=True):
68         assert isinstance(data, ConjectureData)
69         self.data = data
70         self.tasks = []
71         self.is_final = is_final
72         self.close_on_capture = close_on_capture
73         self.close_on_del = False
74 
75     def __enter__(self):
76         self.assign_variable = _current_build_context.with_value(self)
77         self.assign_variable.__enter__()
78         return self
79 
80     def __exit__(self, exc_type, exc_value, tb):
81         self.assign_variable.__exit__(exc_type, exc_value, tb)
82         if self.close() and exc_type is None:
83             raise CleanupFailed()
84 
85     def close(self):
86         any_failed = False
87         for task in self.tasks:
88             try:
89                 task()
90             except BaseException:
91                 any_failed = True
92                 report(traceback.format_exc())
93         return any_failed
94 
95 
96 def cleanup(teardown):
97     """Register a function to be called when the current test has finished
98     executing. Any exceptions thrown in teardown will be printed but not
99     rethrown.
100 
101     Inside a test this isn't very interesting, because you can just use
102     a finally block, but note that you can use this inside map, flatmap,
103     etc. in order to e.g. insist that a value is closed at the end.
104     """
105     context = _current_build_context.value
106     if context is None:
107         raise InvalidArgument("Cannot register cleanup outside of build context")
108     context.tasks.append(teardown)
109 
110 
111 def should_note():
112     context = _current_build_context.value
113     if context is None:
114         raise InvalidArgument("Cannot make notes outside of a test")
115     return context.is_final or settings.default.verbosity >= Verbosity.verbose
116 
117 
118 def note(value: str) -> None:
119     """Report this value in the final execution."""
120     if should_note():
121         report(value)
122 
123 
124 def event(value: str) -> None:
125     """Record an event that occurred this test. Statistics on number of test
126     runs with each event will be reported at the end if you run Hypothesis in
127     statistics reporting mode.
128 
129     Events should be strings or convertible to them.
130     """
131     context = _current_build_context.value
132     if context is None:
133         raise InvalidArgument("Cannot make record events outside of a test")
134 
135     context.data.note_event(value)
136 
137 
138 def target(observation: Union[int, float], *, label: str = "") -> Union[int, float]:
139     """Calling this function with an ``int`` or ``float`` observation gives it feedback
140     with which to guide our search for inputs that will cause an error, in
141     addition to all the usual heuristics.  Observations must always be finite.
142 
143     Hypothesis will try to maximize the observed value over several examples;
144     almost any metric will work so long as it makes sense to increase it.
145     For example, ``-abs(error)`` is a metric that increases as ``error``
146     approaches zero.
147 
148     Example metrics:
149 
150     - Number of elements in a collection, or tasks in a queue
151     - Mean or maximum runtime of a task (or both, if you use ``label``)
152     - Compression ratio for data (perhaps per-algorithm or per-level)
153     - Number of steps taken by a state machine
154 
155     The optional ``label`` argument can be used to distinguish between
156     and therefore separately optimise distinct observations, such as the
157     mean and standard deviation of a dataset.  It is an error to call
158     ``target()`` with any label more than once per test case.
159 
160     .. note::
161         **The more examples you run, the better this technique works.**
162 
163         As a rule of thumb, the targeting effect is noticeable above
164         :obj:`max_examples=1000 <hypothesis.settings.max_examples>`,
165         and immediately obvious by around ten thousand examples
166         *per label* used by your test.
167 
168     :ref:`statistics` include the best score seen for each label,
169     which can help avoid `the threshold problem
170     <https://hypothesis.works/articles/threshold-problem/>`__ when the minimal
171     example shrinks right down to the threshold of failure (:issue:`2180`).
172     """
173     check_type((int, float), observation, "observation")
174     if not math.isfinite(observation):
175         raise InvalidArgument(f"observation={observation!r} must be a finite float.")
176     check_type(str, label, "label")
177 
178     context = _current_build_context.value
179     if context is None:
180         raise InvalidArgument(
181             "Calling target() outside of a test is invalid.  "
182             "Consider guarding this call with `if currently_in_test_context(): ...`"
183         )
184     verbose_report(f"Saw target(observation={observation!r}, label={label!r})")
185 
186     if label in context.data.target_observations:
187         raise InvalidArgument(
188             f"Calling target({observation!r}, label={label!r}) would overwrite "
189             f"target({context.data.target_observations[label]!r}, label={label!r})"
190         )
191     else:
192         context.data.target_observations[label] = observation
193 
194     return observation
195
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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 note(value: str) -> None:
-    """Report this value in the final execution."""
+    """Report this value for the minimal failing example."""
     if should_note():
         report(value)

{"golden_diff": "diff --git a/hypothesis-python/src/hypothesis/control.py b/hypothesis-python/src/hypothesis/control.py\n--- a/hypothesis-python/src/hypothesis/control.py\n+++ b/hypothesis-python/src/hypothesis/control.py\n@@ -116,7 +116,7 @@\n \n \n def note(value: str) -> None:\n-    \"\"\"Report this value in the final execution.\"\"\"\n+    \"\"\"Report this value for the minimal failing example.\"\"\"\n     if should_note():\n         report(value)\n", "issue": "clarification on `note`\nhttps://hypothesis.readthedocs.io/en/latest/details.html#hypothesis.note states\r\n\r\n`Report this value in the final execution.`\r\n\r\nFrom my test, `note` wasn't printed on successful run and was printed on falsified run.\r\n\r\nPlease help me understand this functionality\r\n\r\n\n", "before_files": [{"content": "# This file is part of Hypothesis, which may be found at\n# https://github.com/HypothesisWorks/hypothesis/\n#\n# Most of this work is copyright (C) 2013-2021 David R. MacIver\n# (david@drmaciver.com), but it contains contributions by others. See\n# CONTRIBUTING.rst for a full list of people who may hold copyright, and\n# consult the git log if you need to determine who owns an individual\n# contribution.\n#\n# This Source Code Form is subject to the terms of the Mozilla Public License,\n# v. 2.0. If a copy of the MPL was not distributed with this file, You can\n# obtain one at https://mozilla.org/MPL/2.0/.\n#\n# END HEADER\n\nimport math\nimport traceback\nfrom typing import NoReturn, Union\n\nfrom hypothesis import Verbosity, settings\nfrom hypothesis.errors import CleanupFailed, InvalidArgument, UnsatisfiedAssumption\nfrom hypothesis.internal.conjecture.data import ConjectureData\nfrom hypothesis.internal.validation import check_type\nfrom hypothesis.reporting import report, verbose_report\nfrom hypothesis.utils.dynamicvariables import DynamicVariable\n\n\ndef reject() -> NoReturn:\n    raise UnsatisfiedAssumption()\n\n\ndef assume(condition: object) -> bool:\n    \"\"\"Calling ``assume`` is like an :ref:`assert <python:assert>` that marks\n    the example as bad, rather than failing the test.\n\n    This allows you to specify properties that you *assume* will be\n    true, and let Hypothesis try to avoid similar examples in future.\n    \"\"\"\n    if not condition:\n        raise UnsatisfiedAssumption()\n    return True\n\n\n_current_build_context = DynamicVariable(None)\n\n\ndef currently_in_test_context() -> bool:\n    \"\"\"Return ``True`` if the calling code is currently running inside an\n    :func:`@given <hypothesis.given>` or :doc:`stateful <stateful>` test,\n    ``False`` otherwise.\n\n    This is useful for third-party integrations and assertion helpers which\n    may be called from traditional or property-based tests, but can only use\n    :func:`~hypothesis.assume` or :func:`~hypothesis.target` in the latter case.\n    \"\"\"\n    return _current_build_context.value is not None\n\n\ndef current_build_context():\n    context = _current_build_context.value\n    if context is None:\n        raise InvalidArgument(\"No build context registered\")\n    return context\n\n\nclass BuildContext:\n    def __init__(self, data, is_final=False, close_on_capture=True):\n        assert isinstance(data, ConjectureData)\n        self.data = data\n        self.tasks = []\n        self.is_final = is_final\n        self.close_on_capture = close_on_capture\n        self.close_on_del = False\n\n    def __enter__(self):\n        self.assign_variable = _current_build_context.with_value(self)\n        self.assign_variable.__enter__()\n        return self\n\n    def __exit__(self, exc_type, exc_value, tb):\n        self.assign_variable.__exit__(exc_type, exc_value, tb)\n        if self.close() and exc_type is None:\n            raise CleanupFailed()\n\n    def close(self):\n        any_failed = False\n        for task in self.tasks:\n            try:\n                task()\n            except BaseException:\n                any_failed = True\n                report(traceback.format_exc())\n        return any_failed\n\n\ndef cleanup(teardown):\n    \"\"\"Register a function to be called when the current test has finished\n    executing. Any exceptions thrown in teardown will be printed but not\n    rethrown.\n\n    Inside a test this isn't very interesting, because you can just use\n    a finally block, but note that you can use this inside map, flatmap,\n    etc. in order to e.g. insist that a value is closed at the end.\n    \"\"\"\n    context = _current_build_context.value\n    if context is None:\n        raise InvalidArgument(\"Cannot register cleanup outside of build context\")\n    context.tasks.append(teardown)\n\n\ndef should_note():\n    context = _current_build_context.value\n    if context is None:\n        raise InvalidArgument(\"Cannot make notes outside of a test\")\n    return context.is_final or settings.default.verbosity >= Verbosity.verbose\n\n\ndef note(value: str) -> None:\n    \"\"\"Report this value in the final execution.\"\"\"\n    if should_note():\n        report(value)\n\n\ndef event(value: str) -> None:\n    \"\"\"Record an event that occurred this test. Statistics on number of test\n    runs with each event will be reported at the end if you run Hypothesis in\n    statistics reporting mode.\n\n    Events should be strings or convertible to them.\n    \"\"\"\n    context = _current_build_context.value\n    if context is None:\n        raise InvalidArgument(\"Cannot make record events outside of a test\")\n\n    context.data.note_event(value)\n\n\ndef target(observation: Union[int, float], *, label: str = \"\") -> Union[int, float]:\n    \"\"\"Calling this function with an ``int`` or ``float`` observation gives it feedback\n    with which to guide our search for inputs that will cause an error, in\n    addition to all the usual heuristics.  Observations must always be finite.\n\n    Hypothesis will try to maximize the observed value over several examples;\n    almost any metric will work so long as it makes sense to increase it.\n    For example, ``-abs(error)`` is a metric that increases as ``error``\n    approaches zero.\n\n    Example metrics:\n\n    - Number of elements in a collection, or tasks in a queue\n    - Mean or maximum runtime of a task (or both, if you use ``label``)\n    - Compression ratio for data (perhaps per-algorithm or per-level)\n    - Number of steps taken by a state machine\n\n    The optional ``label`` argument can be used to distinguish between\n    and therefore separately optimise distinct observations, such as the\n    mean and standard deviation of a dataset.  It is an error to call\n    ``target()`` with any label more than once per test case.\n\n    .. note::\n        **The more examples you run, the better this technique works.**\n\n        As a rule of thumb, the targeting effect is noticeable above\n        :obj:`max_examples=1000 <hypothesis.settings.max_examples>`,\n        and immediately obvious by around ten thousand examples\n        *per label* used by your test.\n\n    :ref:`statistics` include the best score seen for each label,\n    which can help avoid `the threshold problem\n    <https://hypothesis.works/articles/threshold-problem/>`__ when the minimal\n    example shrinks right down to the threshold of failure (:issue:`2180`).\n    \"\"\"\n    check_type((int, float), observation, \"observation\")\n    if not math.isfinite(observation):\n        raise InvalidArgument(f\"observation={observation!r} must be a finite float.\")\n    check_type(str, label, \"label\")\n\n    context = _current_build_context.value\n    if context is None:\n        raise InvalidArgument(\n            \"Calling target() outside of a test is invalid.  \"\n            \"Consider guarding this call with `if currently_in_test_context(): ...`\"\n        )\n    verbose_report(f\"Saw target(observation={observation!r}, label={label!r})\")\n\n    if label in context.data.target_observations:\n        raise InvalidArgument(\n            f\"Calling target({observation!r}, label={label!r}) would overwrite \"\n            f\"target({context.data.target_observations[label]!r}, label={label!r})\"\n        )\n    else:\n        context.data.target_observations[label] = observation\n\n    return observation\n", "path": "hypothesis-python/src/hypothesis/control.py"}], "after_files": [{"content": "# This file is part of Hypothesis, which may be found at\n# https://github.com/HypothesisWorks/hypothesis/\n#\n# Most of this work is copyright (C) 2013-2021 David R. MacIver\n# (david@drmaciver.com), but it contains contributions by others. See\n# CONTRIBUTING.rst for a full list of people who may hold copyright, and\n# consult the git log if you need to determine who owns an individual\n# contribution.\n#\n# This Source Code Form is subject to the terms of the Mozilla Public License,\n# v. 2.0. If a copy of the MPL was not distributed with this file, You can\n# obtain one at https://mozilla.org/MPL/2.0/.\n#\n# END HEADER\n\nimport math\nimport traceback\nfrom typing import NoReturn, Union\n\nfrom hypothesis import Verbosity, settings\nfrom hypothesis.errors import CleanupFailed, InvalidArgument, UnsatisfiedAssumption\nfrom hypothesis.internal.conjecture.data import ConjectureData\nfrom hypothesis.internal.validation import check_type\nfrom hypothesis.reporting import report, verbose_report\nfrom hypothesis.utils.dynamicvariables import DynamicVariable\n\n\ndef reject() -> NoReturn:\n    raise UnsatisfiedAssumption()\n\n\ndef assume(condition: object) -> bool:\n    \"\"\"Calling ``assume`` is like an :ref:`assert <python:assert>` that marks\n    the example as bad, rather than failing the test.\n\n    This allows you to specify properties that you *assume* will be\n    true, and let Hypothesis try to avoid similar examples in future.\n    \"\"\"\n    if not condition:\n        raise UnsatisfiedAssumption()\n    return True\n\n\n_current_build_context = DynamicVariable(None)\n\n\ndef currently_in_test_context() -> bool:\n    \"\"\"Return ``True`` if the calling code is currently running inside an\n    :func:`@given <hypothesis.given>` or :doc:`stateful <stateful>` test,\n    ``False`` otherwise.\n\n    This is useful for third-party integrations and assertion helpers which\n    may be called from traditional or property-based tests, but can only use\n    :func:`~hypothesis.assume` or :func:`~hypothesis.target` in the latter case.\n    \"\"\"\n    return _current_build_context.value is not None\n\n\ndef current_build_context():\n    context = _current_build_context.value\n    if context is None:\n        raise InvalidArgument(\"No build context registered\")\n    return context\n\n\nclass BuildContext:\n    def __init__(self, data, is_final=False, close_on_capture=True):\n        assert isinstance(data, ConjectureData)\n        self.data = data\n        self.tasks = []\n        self.is_final = is_final\n        self.close_on_capture = close_on_capture\n        self.close_on_del = False\n\n    def __enter__(self):\n        self.assign_variable = _current_build_context.with_value(self)\n        self.assign_variable.__enter__()\n        return self\n\n    def __exit__(self, exc_type, exc_value, tb):\n        self.assign_variable.__exit__(exc_type, exc_value, tb)\n        if self.close() and exc_type is None:\n            raise CleanupFailed()\n\n    def close(self):\n        any_failed = False\n        for task in self.tasks:\n            try:\n                task()\n            except BaseException:\n                any_failed = True\n                report(traceback.format_exc())\n        return any_failed\n\n\ndef cleanup(teardown):\n    \"\"\"Register a function to be called when the current test has finished\n    executing. Any exceptions thrown in teardown will be printed but not\n    rethrown.\n\n    Inside a test this isn't very interesting, because you can just use\n    a finally block, but note that you can use this inside map, flatmap,\n    etc. in order to e.g. insist that a value is closed at the end.\n    \"\"\"\n    context = _current_build_context.value\n    if context is None:\n        raise InvalidArgument(\"Cannot register cleanup outside of build context\")\n    context.tasks.append(teardown)\n\n\ndef should_note():\n    context = _current_build_context.value\n    if context is None:\n        raise InvalidArgument(\"Cannot make notes outside of a test\")\n    return context.is_final or settings.default.verbosity >= Verbosity.verbose\n\n\ndef note(value: str) -> None:\n    \"\"\"Report this value for the minimal failing example.\"\"\"\n    if should_note():\n        report(value)\n\n\ndef event(value: str) -> None:\n    \"\"\"Record an event that occurred this test. Statistics on number of test\n    runs with each event will be reported at the end if you run Hypothesis in\n    statistics reporting mode.\n\n    Events should be strings or convertible to them.\n    \"\"\"\n    context = _current_build_context.value\n    if context is None:\n        raise InvalidArgument(\"Cannot make record events outside of a test\")\n\n    context.data.note_event(value)\n\n\ndef target(observation: Union[int, float], *, label: str = \"\") -> Union[int, float]:\n    \"\"\"Calling this function with an ``int`` or ``float`` observation gives it feedback\n    with which to guide our search for inputs that will cause an error, in\n    addition to all the usual heuristics.  Observations must always be finite.\n\n    Hypothesis will try to maximize the observed value over several examples;\n    almost any metric will work so long as it makes sense to increase it.\n    For example, ``-abs(error)`` is a metric that increases as ``error``\n    approaches zero.\n\n    Example metrics:\n\n    - Number of elements in a collection, or tasks in a queue\n    - Mean or maximum runtime of a task (or both, if you use ``label``)\n    - Compression ratio for data (perhaps per-algorithm or per-level)\n    - Number of steps taken by a state machine\n\n    The optional ``label`` argument can be used to distinguish between\n    and therefore separately optimise distinct observations, such as the\n    mean and standard deviation of a dataset.  It is an error to call\n    ``target()`` with any label more than once per test case.\n\n    .. note::\n        **The more examples you run, the better this technique works.**\n\n        As a rule of thumb, the targeting effect is noticeable above\n        :obj:`max_examples=1000 <hypothesis.settings.max_examples>`,\n        and immediately obvious by around ten thousand examples\n        *per label* used by your test.\n\n    :ref:`statistics` include the best score seen for each label,\n    which can help avoid `the threshold problem\n    <https://hypothesis.works/articles/threshold-problem/>`__ when the minimal\n    example shrinks right down to the threshold of failure (:issue:`2180`).\n    \"\"\"\n    check_type((int, float), observation, \"observation\")\n    if not math.isfinite(observation):\n        raise InvalidArgument(f\"observation={observation!r} must be a finite float.\")\n    check_type(str, label, \"label\")\n\n    context = _current_build_context.value\n    if context is None:\n        raise InvalidArgument(\n            \"Calling target() outside of a test is invalid.  \"\n            \"Consider guarding this call with `if currently_in_test_context(): ...`\"\n        )\n    verbose_report(f\"Saw target(observation={observation!r}, label={label!r})\")\n\n    if label in context.data.target_observations:\n        raise InvalidArgument(\n            f\"Calling target({observation!r}, label={label!r}) would overwrite \"\n            f\"target({context.data.target_observations[label]!r}, label={label!r})\"\n        )\n    else:\n        context.data.target_observations[label] = observation\n\n    return observation\n", "path": "hypothesis-python/src/hypothesis/control.py"}]}