Skip to content

Commit

Permalink
Document using -W with pytest to detect deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Dec 23, 2022
1 parent 464cbff commit 1df7d48
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/development/release-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ SemVer makes it easier to see at a glance how compatible releases are with each
## Deprecation policy

A [feature release](#feature-releases) may deprecate a feature, but it will not remove it until the next major release. A deprecation will be clearly documented in the changelog and in the code.

All deprecated features will emit a `SingerDeprecationWarning` when used, so users can raise them as exceptions when running their tests to ensure that they are not using any deprecated features:

```console
$ pytest -W error::singer_sdk.utils.deprecation.SingerSDKDeprecationWarning
```
3 changes: 2 additions & 1 deletion singer_sdk/streams/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
)
from singer_sdk.plugin_base import PluginBase as TapBaseClass
from singer_sdk.streams.core import Stream
from singer_sdk.utils.deprecation import SingerSDKDeprecationWarning

if TYPE_CHECKING:
from backoff.types import Details
Expand Down Expand Up @@ -484,7 +485,7 @@ def get_new_paginator(self) -> BaseAPIPaginator:
A paginator instance.
"""
if hasattr(self, "get_next_page_token"):
warning = DeprecationWarning(
warning = SingerSDKDeprecationWarning(
"`RESTStream.get_next_page_token` is deprecated and will not be used "
+ "in a future version of the Meltano Singer SDK. "
+ "Override `RESTStream.get_new_paginator` instead."
Expand Down
3 changes: 2 additions & 1 deletion tests/core/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
Property,
StringType,
)
from singer_sdk.utils.deprecation import SingerSDKDeprecationWarning

CONFIG_START_DATE = "2021-01-01"

Expand Down Expand Up @@ -461,7 +462,7 @@ def test_next_page_token_jsonpath(
RestTestStream.next_page_token_jsonpath = path
stream = RestTestStream(tap)

with pytest.warns(DeprecationWarning):
with pytest.warns(SingerSDKDeprecationWarning):
paginator = stream.get_new_paginator()

next_page = paginator.get_next(fake_response)
Expand Down

0 comments on commit 1df7d48

Please sign in to comment.