diff --git a/plexapi/collection.py b/plexapi/collection.py index 4a07a20a3..74034be4a 100644 --- a/plexapi/collection.py +++ b/plexapi/collection.py @@ -75,7 +75,7 @@ def _loadData(self, data): self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt')) @property - @deprecated('use "items" instead') + @deprecated('use "items" instead', stacklevel=3) def children(self): return self.items() diff --git a/plexapi/utils.py b/plexapi/utils.py index a56d87abe..e4225941c 100644 --- a/plexapi/utils.py +++ b/plexapi/utils.py @@ -21,7 +21,6 @@ tqdm = None log = logging.getLogger('plexapi') -warnings.simplefilter('default', category=DeprecationWarning) # Search Types - Plex uses these to filter specific media types when searching. # Library Types - Populated at runtime @@ -467,7 +466,7 @@ def base64str(text): return base64.b64encode(text.encode('utf-8')).decode('utf-8') -def deprecated(message): +def deprecated(message, stacklevel=2): def decorator(func): """This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted @@ -475,7 +474,7 @@ def decorator(func): @functools.wraps(func) def wrapper(*args, **kwargs): msg = 'Call to deprecated function or method "%s", %s.' % (func.__name__, message) - warnings.warn(msg, category=DeprecationWarning, stacklevel=3) + warnings.warn(msg, category=DeprecationWarning, stacklevel=stacklevel) log.warning(msg) return func(*args, **kwargs) return wrapper