| 1 |
# This file is part of Hypothesis, which may be found at |
| 2 |
# https://github.com/HypothesisWorks/hypothesis/ |
| 3 |
# |
| 4 |
# Copyright the Hypothesis Authors. |
| 5 |
# Individual contributors are listed in AUTHORS.rst and the git log. |
| 6 |
# |
| 7 |
# This Source Code Form is subject to the terms of the Mozilla Public License, |
| 8 |
# v. 2.0. If a copy of the MPL was not distributed with this file, You can |
| 9 |
# obtain one at https://mozilla.org/MPL/2.0/. |
| 10 |
|
| 11 |
import datetime |
| 12 |
import warnings |
| 13 |
|
| 14 |
from hypothesis.errors import HypothesisDeprecationWarning |
| 15 |
|
| 16 |
|
| 17 |
def note_deprecation( |
| 18 |
message: str, *, since: str, has_codemod: bool, stacklevel: int = 0 |
| 19 |
) -> None: |
| 20 |
if since != "RELEASEDAY": |
| 21 |
date = datetime.date.fromisoformat(since) |
| 22 |
assert datetime.date(2021, 1, 1) <= date |
| 23 |
if has_codemod: |
| 24 |
message += ( |
| 25 |
"\n The `hypothesis codemod` command-line tool can automatically " |
| 26 |
"refactor your code to fix this warning." |
| 27 |
) |
| 28 |
warnings.warn(HypothesisDeprecationWarning(message), stacklevel=2 + stacklevel) |