Skip to content

Commit

Permalink
Silence deprecated locale warning (#1401)
Browse files Browse the repository at this point in the history
* silence faker warning for deprecated locale

* use warnings context manager
  • Loading branch information
frances-h authored May 1, 2023
1 parent 9bf8527 commit 898850a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sdv/metadata/anonymization.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Anonymization module for the ``DataProcessor``."""

import inspect
import warnings

from faker import Faker
from faker.config import AVAILABLE_LOCALES
Expand Down Expand Up @@ -57,7 +58,9 @@ def is_faker_function(function_name):
True if the ``function_name`` is know to ``Faker``, otherwise False.
"""
try:
getattr(Faker(AVAILABLE_LOCALES), function_name)
with warnings.catch_warnings():
warnings.filterwarnings('ignore', module='faker')
getattr(Faker(AVAILABLE_LOCALES), function_name)
except AttributeError:
return False

Expand Down

0 comments on commit 898850a

Please sign in to comment.