Skip to content

Commit

Permalink
cleanup; fix bug in last-resort depr. warning
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanceNCounter committed Nov 3, 2020
1 parent 668df05 commit e5a960d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
4 changes: 2 additions & 2 deletions lingua_franca/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _translate_word(name, lang=''):
"""
from lingua_franca.internal import resolve_resource_file
if not lang:
if lang == None:
if lang is None:
warn(NoneLangWarning)
lang = get_default_loc()

Expand Down Expand Up @@ -387,7 +387,7 @@ def nice_duration(duration, lang='', speech=True):
str: timespan as a string
"""
if not lang:
if lang == None:
if lang is None:
warn(NoneLangWarning)
lang = get_default_loc()
if not is_supported_full_lang(lang):
Expand Down
20 changes: 7 additions & 13 deletions lingua_franca/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@
# commit 35efd0661a178e82f6745ad17e10e607c0d83472 for the "proper" state
# of affairs, raising the errors below instead of deprecation warnings

# For ease of development, in order to be able to type `if not lang:`
# the default parameter to all functions should be changed back from
# lang='' to lang=None when the deprecation is complete
# Once the deprecation is complete, functions which have had their default
# parameter changed from lang=None to lang='' should be switched back

if version[:3] == '3.5':
warn(DeprecationWarning("Python 3.5 is EOL, and no longer supported. "
Expand Down Expand Up @@ -300,7 +299,7 @@ def set_default_lang(lang_code):

def get_primary_lang_code(lang=''):
if not lang:
if lang == None:
if lang is None:
warn(NoneLangWarning)
lang = get_default_loc()
# if not (lang):
Expand Down Expand Up @@ -353,7 +352,7 @@ def __get_primary_lang_code_deprecation_warning(lang=''):

def get_full_lang_code(lang=''):
if not lang:
if lang == None:
if lang is None:
warn(NoneLangWarning)
lang = get_default_loc()
if not is_supported_full_lang(lang):
Expand Down Expand Up @@ -507,22 +506,17 @@ def _call_localized_function(func, *args, **kwargs):
else:
warn(DeprecationWarning("The following warning will "
"become an exception in a future "
"version of Lingua Franca.".append(
__error
)))
# warn(__error)
"version of Lingua Franca." +
str(__error)))
lang_code = get_default_lang()
full_lang_code = get_full_lang_code()
__use_tmp = False
# _raise_unsupported_language(lang_code)
if lang_code not in _SUPPORTED_LANGUAGES:
_raise_unsupported_language(lang_code)
if __use_tmp:
full_lang_code = tmp
else:
full_lang_code = get_full_lang_code(lang_code) # if \
# lang_code != get_default_lang() \
# else get_full_lang_code()
full_lang_code = get_full_lang_code(lang_code)

# Here comes the ugly business.
_module_name = func.__module__.split('.')[-1]
Expand Down

0 comments on commit e5a960d

Please sign in to comment.