We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Importing hypothesis mutates global warnings state
`hypothesis.errors` mutates the global warnings state:

https://github.com/HypothesisWorks/hypothesis-python/blob/master/src/hypothesis/errors.py#L182

This causes hypothesis to override any warnings settings that have already been applied. E.g., setting PYTHONWARNINGS="error" will not be respected, because hypothesis will change HypothesisDeprecationWarnings to be instead printed.

The filter there should presumably not do anything if the user has already modified any warnings defaults.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/hypothesis/errors.py`
Content:
```
1 # coding=utf-8
2 #
3 # This file is part of Hypothesis, which may be found at
4 # https://github.com/HypothesisWorks/hypothesis-python
5 #
6 # Most of this work is copyright (C) 2013-2017 David R. MacIver
7 # (david@drmaciver.com), but it contains contributions by others. See
8 # CONTRIBUTING.rst for a full list of people who may hold copyright, and
9 # consult the git log if you need to determine who owns an individual
10 # contribution.
11 #
12 # This Source Code Form is subject to the terms of the Mozilla Public License,
13 # v. 2.0. If a copy of the MPL was not distributed with this file, You can
14 # obtain one at http://mozilla.org/MPL/2.0/.
15 #
16 # END HEADER
17 
18 from __future__ import division, print_function, absolute_import
19 
20 import warnings
21 
22 
23 class HypothesisException(Exception):
24 
25     """Generic parent class for exceptions thrown by Hypothesis."""
26 
27 
28 class CleanupFailed(HypothesisException):
29 
30     """At least one cleanup task failed and no other exception was raised."""
31 
32 
33 class UnsatisfiedAssumption(HypothesisException):
34 
35     """An internal error raised by assume.
36 
37     If you're seeing this error something has gone wrong.
38 
39     """
40 
41 
42 class BadTemplateDraw(HypothesisException):
43 
44     """An internal error raised when something unfortunate happened during
45     template generation and you should restart the draw, preferably with a new
46     parameter.
47 
48     This is not an error condition internally, but if you ever see this
49     in your code it's probably a Hypothesis bug
50 
51     """
52 
53 
54 class NoSuchExample(HypothesisException):
55 
56     """The condition we have been asked to satisfy appears to be always false.
57 
58     This does not guarantee that no example exists, only that we were
59     unable to find one.
60 
61     """
62 
63     def __init__(self, condition_string, extra=''):
64         super(NoSuchExample, self).__init__(
65             'No examples found of condition %s%s' % (
66                 condition_string, extra)
67         )
68 
69 
70 class DefinitelyNoSuchExample(NoSuchExample):  # pragma: no cover
71     """Hypothesis used to be able to detect exhaustive coverage of a search
72     space and no longer can.
73 
74     This exception remains for compatibility reasons for now but can
75     never actually be thrown.
76 
77     """
78 
79 
80 class NoExamples(HypothesisException):
81 
82     """Raised when example() is called on a strategy but we cannot find any
83     examples after enough tries that we really should have been able to if this
84     was ever going to work."""
85 
86 
87 class Unsatisfiable(HypothesisException):
88 
89     """We ran out of time or examples before we could find enough examples
90     which satisfy the assumptions of this hypothesis.
91 
92     This could be because the function is too slow. If so, try upping
93     the timeout. It could also be because the function is using assume
94     in a way that is too hard to satisfy. If so, try writing a custom
95     strategy or using a better starting point (e.g if you are requiring
96     a list has unique values you could instead filter out all duplicate
97     values from the list)
98 
99     """
100 
101 
102 class Flaky(HypothesisException):
103 
104     """This function appears to fail non-deterministically: We have seen it
105     fail when passed this example at least once, but a subsequent invocation
106     did not fail.
107 
108     Common causes for this problem are:
109         1. The function depends on external state. e.g. it uses an external
110            random number generator. Try to make a version that passes all the
111            relevant state in from Hypothesis.
112         2. The function is suffering from too much recursion and its failure
113            depends sensitively on where it's been called from.
114         3. The function is timing sensitive and can fail or pass depending on
115            how long it takes. Try breaking it up into smaller functions which
116            don't do that and testing those instead.
117 
118     """
119 
120 
121 class Timeout(Unsatisfiable):
122 
123     """We were unable to find enough examples that satisfied the preconditions
124     of this hypothesis in the amount of time allotted to us."""
125 
126 
127 class WrongFormat(HypothesisException, ValueError):
128 
129     """An exception indicating you have attempted to serialize a value that
130     does not match the type described by this format."""
131 
132 
133 class BadData(HypothesisException, ValueError):
134 
135     """The data that we got out of the database does not seem to match the data
136     we could have put into the database given this schema."""
137 
138 
139 class InvalidArgument(HypothesisException, TypeError):
140 
141     """Used to indicate that the arguments to a Hypothesis function were in
142     some manner incorrect."""
143 
144 
145 class ResolutionFailed(InvalidArgument):
146 
147     """Hypothesis had to resolve a type to a strategy, but this failed.
148 
149     Type inference is best-effort, so this only happens when an
150     annotation exists but could not be resolved for a required argument
151     to the target of ``builds()``, or where the user passed ``infer``.
152 
153     """
154 
155 
156 class InvalidState(HypothesisException):
157 
158     """The system is not in a state where you were allowed to do that."""
159 
160 
161 class InvalidDefinition(HypothesisException, TypeError):
162 
163     """Used to indicate that a class definition was not well put together and
164     has something wrong with it."""
165 
166 
167 class AbnormalExit(HypothesisException):
168 
169     """Raised when a test running in a child process exits without returning or
170     raising an exception."""
171 
172 
173 class FailedHealthCheck(HypothesisException, Warning):
174     """Raised when a test fails a preliminary healthcheck that occurs before
175     execution."""
176 
177     def __init__(self, message, check):
178         super(FailedHealthCheck, self).__init__(message)
179         self.health_check = check
180 
181 
182 class HypothesisDeprecationWarning(HypothesisException, DeprecationWarning):
183     pass
184 
185 
186 warnings.simplefilter('once', HypothesisDeprecationWarning)
187 
188 
189 class Frozen(HypothesisException):
190 
191     """Raised when a mutation method has been called on a ConjectureData object
192     after freeze() has been called."""
193 
194 
195 class MultipleFailures(HypothesisException):
196     """Indicates that Hypothesis found more than one distinct bug when testing
197     your code."""
198 
199 
200 class DeadlineExceeded(HypothesisException):
201     """Raised when an individual test body has taken too long to run."""
202 
203     def __init__(self, runtime, deadline):
204         super(DeadlineExceeded, self).__init__((
205             'Test took %.2fms, which exceeds the deadline of '
206             '%.2fms') % (runtime, deadline))
207         self.runtime = runtime
208         self.deadline = deadline
209 
210 
211 class StopTest(BaseException):
212 
213     def __init__(self, testcounter):
214         super(StopTest, self).__init__(repr(testcounter))
215         self.testcounter = testcounter
216
```
--- 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/src/hypothesis/errors.py b/src/hypothesis/errors.py
--- a/src/hypothesis/errors.py
+++ b/src/hypothesis/errors.py
@@ -17,8 +17,6 @@
 
 from __future__ import division, print_function, absolute_import
 
-import warnings
-
 
 class HypothesisException(Exception):
 
@@ -179,13 +177,10 @@
         self.health_check = check
 
 
-class HypothesisDeprecationWarning(HypothesisException, DeprecationWarning):
+class HypothesisDeprecationWarning(HypothesisException, FutureWarning):
     pass
 
 
-warnings.simplefilter('once', HypothesisDeprecationWarning)
-
-
 class Frozen(HypothesisException):
 
     """Raised when a mutation method has been called on a ConjectureData object

{"golden_diff": "diff --git a/src/hypothesis/errors.py b/src/hypothesis/errors.py\n--- a/src/hypothesis/errors.py\n+++ b/src/hypothesis/errors.py\n@@ -17,8 +17,6 @@\n \n from __future__ import division, print_function, absolute_import\n \n-import warnings\n-\n \n class HypothesisException(Exception):\n \n@@ -179,13 +177,10 @@\n         self.health_check = check\n \n \n-class HypothesisDeprecationWarning(HypothesisException, DeprecationWarning):\n+class HypothesisDeprecationWarning(HypothesisException, FutureWarning):\n     pass\n \n \n-warnings.simplefilter('once', HypothesisDeprecationWarning)\n-\n-\n class Frozen(HypothesisException):\n \n     \"\"\"Raised when a mutation method has been called on a ConjectureData object\n", "issue": "Importing hypothesis mutates global warnings state\n`hypothesis.errors` mutates the global warnings state:\r\n\r\nhttps://github.com/HypothesisWorks/hypothesis-python/blob/master/src/hypothesis/errors.py#L182\r\n\r\nThis causes hypothesis to override any warnings settings that have already been applied. E.g., setting PYTHONWARNINGS=\"error\" will not be respected, because hypothesis will change HypothesisDeprecationWarnings to be instead printed.\r\n\r\nThe filter there should presumably not do anything if the user has already modified any warnings defaults.\n", "before_files": [{"content": "# coding=utf-8\n#\n# This file is part of Hypothesis, which may be found at\n# https://github.com/HypothesisWorks/hypothesis-python\n#\n# Most of this work is copyright (C) 2013-2017 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 http://mozilla.org/MPL/2.0/.\n#\n# END HEADER\n\nfrom __future__ import division, print_function, absolute_import\n\nimport warnings\n\n\nclass HypothesisException(Exception):\n\n    \"\"\"Generic parent class for exceptions thrown by Hypothesis.\"\"\"\n\n\nclass CleanupFailed(HypothesisException):\n\n    \"\"\"At least one cleanup task failed and no other exception was raised.\"\"\"\n\n\nclass UnsatisfiedAssumption(HypothesisException):\n\n    \"\"\"An internal error raised by assume.\n\n    If you're seeing this error something has gone wrong.\n\n    \"\"\"\n\n\nclass BadTemplateDraw(HypothesisException):\n\n    \"\"\"An internal error raised when something unfortunate happened during\n    template generation and you should restart the draw, preferably with a new\n    parameter.\n\n    This is not an error condition internally, but if you ever see this\n    in your code it's probably a Hypothesis bug\n\n    \"\"\"\n\n\nclass NoSuchExample(HypothesisException):\n\n    \"\"\"The condition we have been asked to satisfy appears to be always false.\n\n    This does not guarantee that no example exists, only that we were\n    unable to find one.\n\n    \"\"\"\n\n    def __init__(self, condition_string, extra=''):\n        super(NoSuchExample, self).__init__(\n            'No examples found of condition %s%s' % (\n                condition_string, extra)\n        )\n\n\nclass DefinitelyNoSuchExample(NoSuchExample):  # pragma: no cover\n    \"\"\"Hypothesis used to be able to detect exhaustive coverage of a search\n    space and no longer can.\n\n    This exception remains for compatibility reasons for now but can\n    never actually be thrown.\n\n    \"\"\"\n\n\nclass NoExamples(HypothesisException):\n\n    \"\"\"Raised when example() is called on a strategy but we cannot find any\n    examples after enough tries that we really should have been able to if this\n    was ever going to work.\"\"\"\n\n\nclass Unsatisfiable(HypothesisException):\n\n    \"\"\"We ran out of time or examples before we could find enough examples\n    which satisfy the assumptions of this hypothesis.\n\n    This could be because the function is too slow. If so, try upping\n    the timeout. It could also be because the function is using assume\n    in a way that is too hard to satisfy. If so, try writing a custom\n    strategy or using a better starting point (e.g if you are requiring\n    a list has unique values you could instead filter out all duplicate\n    values from the list)\n\n    \"\"\"\n\n\nclass Flaky(HypothesisException):\n\n    \"\"\"This function appears to fail non-deterministically: We have seen it\n    fail when passed this example at least once, but a subsequent invocation\n    did not fail.\n\n    Common causes for this problem are:\n        1. The function depends on external state. e.g. it uses an external\n           random number generator. Try to make a version that passes all the\n           relevant state in from Hypothesis.\n        2. The function is suffering from too much recursion and its failure\n           depends sensitively on where it's been called from.\n        3. The function is timing sensitive and can fail or pass depending on\n           how long it takes. Try breaking it up into smaller functions which\n           don't do that and testing those instead.\n\n    \"\"\"\n\n\nclass Timeout(Unsatisfiable):\n\n    \"\"\"We were unable to find enough examples that satisfied the preconditions\n    of this hypothesis in the amount of time allotted to us.\"\"\"\n\n\nclass WrongFormat(HypothesisException, ValueError):\n\n    \"\"\"An exception indicating you have attempted to serialize a value that\n    does not match the type described by this format.\"\"\"\n\n\nclass BadData(HypothesisException, ValueError):\n\n    \"\"\"The data that we got out of the database does not seem to match the data\n    we could have put into the database given this schema.\"\"\"\n\n\nclass InvalidArgument(HypothesisException, TypeError):\n\n    \"\"\"Used to indicate that the arguments to a Hypothesis function were in\n    some manner incorrect.\"\"\"\n\n\nclass ResolutionFailed(InvalidArgument):\n\n    \"\"\"Hypothesis had to resolve a type to a strategy, but this failed.\n\n    Type inference is best-effort, so this only happens when an\n    annotation exists but could not be resolved for a required argument\n    to the target of ``builds()``, or where the user passed ``infer``.\n\n    \"\"\"\n\n\nclass InvalidState(HypothesisException):\n\n    \"\"\"The system is not in a state where you were allowed to do that.\"\"\"\n\n\nclass InvalidDefinition(HypothesisException, TypeError):\n\n    \"\"\"Used to indicate that a class definition was not well put together and\n    has something wrong with it.\"\"\"\n\n\nclass AbnormalExit(HypothesisException):\n\n    \"\"\"Raised when a test running in a child process exits without returning or\n    raising an exception.\"\"\"\n\n\nclass FailedHealthCheck(HypothesisException, Warning):\n    \"\"\"Raised when a test fails a preliminary healthcheck that occurs before\n    execution.\"\"\"\n\n    def __init__(self, message, check):\n        super(FailedHealthCheck, self).__init__(message)\n        self.health_check = check\n\n\nclass HypothesisDeprecationWarning(HypothesisException, DeprecationWarning):\n    pass\n\n\nwarnings.simplefilter('once', HypothesisDeprecationWarning)\n\n\nclass Frozen(HypothesisException):\n\n    \"\"\"Raised when a mutation method has been called on a ConjectureData object\n    after freeze() has been called.\"\"\"\n\n\nclass MultipleFailures(HypothesisException):\n    \"\"\"Indicates that Hypothesis found more than one distinct bug when testing\n    your code.\"\"\"\n\n\nclass DeadlineExceeded(HypothesisException):\n    \"\"\"Raised when an individual test body has taken too long to run.\"\"\"\n\n    def __init__(self, runtime, deadline):\n        super(DeadlineExceeded, self).__init__((\n            'Test took %.2fms, which exceeds the deadline of '\n            '%.2fms') % (runtime, deadline))\n        self.runtime = runtime\n        self.deadline = deadline\n\n\nclass StopTest(BaseException):\n\n    def __init__(self, testcounter):\n        super(StopTest, self).__init__(repr(testcounter))\n        self.testcounter = testcounter\n", "path": "src/hypothesis/errors.py"}], "after_files": [{"content": "# coding=utf-8\n#\n# This file is part of Hypothesis, which may be found at\n# https://github.com/HypothesisWorks/hypothesis-python\n#\n# Most of this work is copyright (C) 2013-2017 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 http://mozilla.org/MPL/2.0/.\n#\n# END HEADER\n\nfrom __future__ import division, print_function, absolute_import\n\n\nclass HypothesisException(Exception):\n\n    \"\"\"Generic parent class for exceptions thrown by Hypothesis.\"\"\"\n\n\nclass CleanupFailed(HypothesisException):\n\n    \"\"\"At least one cleanup task failed and no other exception was raised.\"\"\"\n\n\nclass UnsatisfiedAssumption(HypothesisException):\n\n    \"\"\"An internal error raised by assume.\n\n    If you're seeing this error something has gone wrong.\n\n    \"\"\"\n\n\nclass BadTemplateDraw(HypothesisException):\n\n    \"\"\"An internal error raised when something unfortunate happened during\n    template generation and you should restart the draw, preferably with a new\n    parameter.\n\n    This is not an error condition internally, but if you ever see this\n    in your code it's probably a Hypothesis bug\n\n    \"\"\"\n\n\nclass NoSuchExample(HypothesisException):\n\n    \"\"\"The condition we have been asked to satisfy appears to be always false.\n\n    This does not guarantee that no example exists, only that we were\n    unable to find one.\n\n    \"\"\"\n\n    def __init__(self, condition_string, extra=''):\n        super(NoSuchExample, self).__init__(\n            'No examples found of condition %s%s' % (\n                condition_string, extra)\n        )\n\n\nclass DefinitelyNoSuchExample(NoSuchExample):  # pragma: no cover\n    \"\"\"Hypothesis used to be able to detect exhaustive coverage of a search\n    space and no longer can.\n\n    This exception remains for compatibility reasons for now but can\n    never actually be thrown.\n\n    \"\"\"\n\n\nclass NoExamples(HypothesisException):\n\n    \"\"\"Raised when example() is called on a strategy but we cannot find any\n    examples after enough tries that we really should have been able to if this\n    was ever going to work.\"\"\"\n\n\nclass Unsatisfiable(HypothesisException):\n\n    \"\"\"We ran out of time or examples before we could find enough examples\n    which satisfy the assumptions of this hypothesis.\n\n    This could be because the function is too slow. If so, try upping\n    the timeout. It could also be because the function is using assume\n    in a way that is too hard to satisfy. If so, try writing a custom\n    strategy or using a better starting point (e.g if you are requiring\n    a list has unique values you could instead filter out all duplicate\n    values from the list)\n\n    \"\"\"\n\n\nclass Flaky(HypothesisException):\n\n    \"\"\"This function appears to fail non-deterministically: We have seen it\n    fail when passed this example at least once, but a subsequent invocation\n    did not fail.\n\n    Common causes for this problem are:\n        1. The function depends on external state. e.g. it uses an external\n           random number generator. Try to make a version that passes all the\n           relevant state in from Hypothesis.\n        2. The function is suffering from too much recursion and its failure\n           depends sensitively on where it's been called from.\n        3. The function is timing sensitive and can fail or pass depending on\n           how long it takes. Try breaking it up into smaller functions which\n           don't do that and testing those instead.\n\n    \"\"\"\n\n\nclass Timeout(Unsatisfiable):\n\n    \"\"\"We were unable to find enough examples that satisfied the preconditions\n    of this hypothesis in the amount of time allotted to us.\"\"\"\n\n\nclass WrongFormat(HypothesisException, ValueError):\n\n    \"\"\"An exception indicating you have attempted to serialize a value that\n    does not match the type described by this format.\"\"\"\n\n\nclass BadData(HypothesisException, ValueError):\n\n    \"\"\"The data that we got out of the database does not seem to match the data\n    we could have put into the database given this schema.\"\"\"\n\n\nclass InvalidArgument(HypothesisException, TypeError):\n\n    \"\"\"Used to indicate that the arguments to a Hypothesis function were in\n    some manner incorrect.\"\"\"\n\n\nclass ResolutionFailed(InvalidArgument):\n\n    \"\"\"Hypothesis had to resolve a type to a strategy, but this failed.\n\n    Type inference is best-effort, so this only happens when an\n    annotation exists but could not be resolved for a required argument\n    to the target of ``builds()``, or where the user passed ``infer``.\n\n    \"\"\"\n\n\nclass InvalidState(HypothesisException):\n\n    \"\"\"The system is not in a state where you were allowed to do that.\"\"\"\n\n\nclass InvalidDefinition(HypothesisException, TypeError):\n\n    \"\"\"Used to indicate that a class definition was not well put together and\n    has something wrong with it.\"\"\"\n\n\nclass AbnormalExit(HypothesisException):\n\n    \"\"\"Raised when a test running in a child process exits without returning or\n    raising an exception.\"\"\"\n\n\nclass FailedHealthCheck(HypothesisException, Warning):\n    \"\"\"Raised when a test fails a preliminary healthcheck that occurs before\n    execution.\"\"\"\n\n    def __init__(self, message, check):\n        super(FailedHealthCheck, self).__init__(message)\n        self.health_check = check\n\n\nclass HypothesisDeprecationWarning(HypothesisException, FutureWarning):\n    pass\n\n\nclass Frozen(HypothesisException):\n\n    \"\"\"Raised when a mutation method has been called on a ConjectureData object\n    after freeze() has been called.\"\"\"\n\n\nclass MultipleFailures(HypothesisException):\n    \"\"\"Indicates that Hypothesis found more than one distinct bug when testing\n    your code.\"\"\"\n\n\nclass DeadlineExceeded(HypothesisException):\n    \"\"\"Raised when an individual test body has taken too long to run.\"\"\"\n\n    def __init__(self, runtime, deadline):\n        super(DeadlineExceeded, self).__init__((\n            'Test took %.2fms, which exceeds the deadline of '\n            '%.2fms') % (runtime, deadline))\n        self.runtime = runtime\n        self.deadline = deadline\n\n\nclass StopTest(BaseException):\n\n    def __init__(self, testcounter):\n        super(StopTest, self).__init__(repr(testcounter))\n        self.testcounter = testcounter\n", "path": "src/hypothesis/errors.py"}]}