Skip to content

Commit 8af8ed9

Browse files
committed
Fix deprecation warnings
1 parent 1149c7f commit 8af8ed9

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

plexapi/library.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ def history(self, maxresults=9999999, mindate=None):
838838
"""
839839
return self._server.history(maxresults=maxresults, mindate=mindate, librarySectionID=self.key, accountID=1)
840840

841-
@deprecated('use "collections" (plural) instead')
841+
@deprecated('use "collections" (plural) instead', stacklevel=2)
842842
def collection(self, **kwargs):
843843
return self.collections()
844844

@@ -1596,7 +1596,7 @@ def _loadData(self, data):
15961596
@property
15971597
@deprecated('use "items" instead')
15981598
def children(self):
1599-
return self.fetchItems(self.key)
1599+
return self.items()
16001600

16011601
@property
16021602
def thumbUrl(self):

plexapi/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
tqdm = None
2222

2323
log = logging.getLogger('plexapi')
24-
warnings.simplefilter('default', category=DeprecationWarning)
2524

2625
# Search Types - Plex uses these to filter specific media types when searching.
2726
# Library Types - Populated at runtime
@@ -467,15 +466,15 @@ def base64str(text):
467466
return base64.b64encode(text.encode('utf-8')).decode('utf-8')
468467

469468

470-
def deprecated(message):
469+
def deprecated(message, stacklevel=3):
471470
def decorator(func):
472471
"""This is a decorator which can be used to mark functions
473472
as deprecated. It will result in a warning being emitted
474473
when the function is used."""
475474
@functools.wraps(func)
476475
def wrapper(*args, **kwargs):
477476
msg = 'Call to deprecated function or method "%s", %s.' % (func.__name__, message)
478-
warnings.warn(msg, category=DeprecationWarning, stacklevel=3)
477+
warnings.warn(msg, category=DeprecationWarning, stacklevel=stacklevel)
479478
log.warning(msg)
480479
return func(*args, **kwargs)
481480
return wrapper

0 commit comments

Comments
 (0)