Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small APIdocs improvement #2828

Merged
merged 5 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ lint: .venv
apidocs: .venv
@$(VENV_PATH)/bin/pip install --editable .
@$(VENV_PATH)/bin/pip install -U -r ./docs-requirements.txt
rm -rf docs/_build
szokeasaurusrex marked this conversation as resolved.
Show resolved Hide resolved
@$(VENV_PATH)/bin/sphinx-build -vv -W -b html docs/ docs/_build
.PHONY: apidocs

Expand Down
55 changes: 38 additions & 17 deletions sentry_sdk/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,28 @@

@_attr_setter
def level(self, value):
# type: (Optional[LogLevelStr]) -> None
"""When set this overrides the level. Deprecated in favor of set_level."""
# type: (LogLevelStr) -> None
"""
When set this overrides the level.

.. deprecated:: 1.0.0
Use :func:`set_level` instead.

:param value: The level to set.
"""
logger.warning(

Check warning on line 453 in sentry_sdk/scope.py

View check run for this annotation

Codecov / codecov/patch

sentry_sdk/scope.py#L453

Added line #L453 was not covered by tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antonpirker Why are you emitting the warning with logger? When I have had to emit deprecation warnings, I usually do so as follows:

warnings.warn("blah blah blah", DeprecationWarning, stacklevel=2)

Is there any significant difference with using logger.warning vs warnings.warn? Do we have a preference in the SDKs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just used it because all the other deprecation warnings in that file do it the same way.

"Deprecated: use .set_level() instead. This will be removed in the future."
)

self._level = value
szokeasaurusrex marked this conversation as resolved.
Show resolved Hide resolved

def set_level(self, value):
# type: (Optional[LogLevelStr]) -> None
"""Sets the level for the scope."""
# type: (LogLevelStr) -> None
"""
Sets the level for the scope.

:param value: The level to set.
"""
self._level = value

@_attr_setter
Expand Down Expand Up @@ -555,20 +570,24 @@

self._profile = profile

def set_tag(
self,
key, # type: str
value, # type: Any
):
# type: (...) -> None
"""Sets a tag for a key to a specific value."""
def set_tag(self, key, value):
# type: (str, Any) -> None
"""
Sets a tag for a key to a specific value.

:param key: Key of the tag to set.

:param value: Value of the tag to set.
"""
self._tags[key] = value

def remove_tag(
self, key # type: str
):
# type: (...) -> None
"""Removes a specific tag."""
def remove_tag(self, key):
# type: (str) -> None
"""
Removes a specific tag.

:param key: Key of the tag to remove.
"""
self._tags.pop(key, None)

def set_context(
Expand All @@ -577,7 +596,9 @@
value, # type: Dict[str, Any]
):
# type: (...) -> None
"""Binds a context at a certain key to a specific value."""
"""
Binds a context at a certain key to a specific value.
"""
self._contexts[key] = value

def remove_context(
Expand Down
Loading