Skip to content

Commit

Permalink
Enable E741 (ambiguous variable name) lint
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Jan 18, 2023
1 parent cca00d9 commit b973635
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 44 deletions.
6 changes: 3 additions & 3 deletions babel/messages/pofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,10 @@ def normalize(string: str, prefix: str = '', width: int = 76) -> str:
buf = []
size = 2
while chunks:
l = len(escape(chunks[-1])) - 2 + prefixlen
if size + l < width:
length = len(escape(chunks[-1])) - 2 + prefixlen
if size + length < width:
buf.append(chunks.pop())
size += l
size += length
else:
if not buf:
# handle long chunks by putting them on a
Expand Down
2 changes: 1 addition & 1 deletion babel/plural.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ def value(self):

def _binary_compiler(tmpl):
"""Compiler factory for the `_Compiler`."""
return lambda self, l, r: tmpl % (self.compile(l), self.compile(r))
return lambda self, left, right: tmpl % (self.compile(left), self.compile(right))


def _unary_compiler(tmpl):
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ select = [
ignore = [
"C901", # Complexity
"E501", # Line length
"E741", # Ambiguous variable name
]
extend-exclude = [
"tests/messages/data/project",
Expand Down
52 changes: 26 additions & 26 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,36 +96,36 @@ def test_negotiate_custom_separator(self):
assert (de_DE.language, de_DE.territory) == ('de', 'DE')

def test_parse(self):
l = Locale.parse('de-DE', sep='-')
assert l.display_name == 'Deutsch (Deutschland)'
locale = Locale.parse('de-DE', sep='-')
assert locale.display_name == 'Deutsch (Deutschland)'

de_DE = Locale.parse(l)
de_DE = Locale.parse(locale)
assert (de_DE.language, de_DE.territory) == ('de', 'DE')

def test_parse_likely_subtags(self):
l = Locale.parse('zh-TW', sep='-')
assert l.language == 'zh'
assert l.territory == 'TW'
assert l.script == 'Hant'

l = Locale.parse('zh_CN')
assert l.language == 'zh'
assert l.territory == 'CN'
assert l.script == 'Hans'

l = Locale.parse('zh_SG')
assert l.language == 'zh'
assert l.territory == 'SG'
assert l.script == 'Hans'

l = Locale.parse('und_AT')
assert l.language == 'de'
assert l.territory == 'AT'

l = Locale.parse('und_UK')
assert l.language == 'en'
assert l.territory == 'GB'
assert l.script is None
locale = Locale.parse('zh-TW', sep='-')
assert locale.language == 'zh'
assert locale.territory == 'TW'
assert locale.script == 'Hant'

locale = Locale.parse('zh_CN')
assert locale.language == 'zh'
assert locale.territory == 'CN'
assert locale.script == 'Hans'

locale = Locale.parse('zh_SG')
assert locale.language == 'zh'
assert locale.territory == 'SG'
assert locale.script == 'Hans'

locale = Locale.parse('und_AT')
assert locale.language == 'de'
assert locale.territory == 'AT'

locale = Locale.parse('und_UK')
assert locale.language == 'en'
assert locale.territory == 'GB'
assert locale.script is None

def test_get_display_name(self):
zh_CN = Locale('zh', 'CN', script='Hans')
Expand Down
18 changes: 9 additions & 9 deletions tests/test_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,17 @@ def test_timezone_walltime_long(self, timezone_getter):
assert dates.DateTimeFormat(t, locale='fr_FR')['vvvv'] == 'heure d’Europe centrale'

def test_hour_formatting(self):
l = 'en_US'
locale = 'en_US'
t = time(0, 0, 0)
assert dates.format_time(t, 'h a', locale=l) == '12 AM'
assert dates.format_time(t, 'H', locale=l) == '0'
assert dates.format_time(t, 'k', locale=l) == '24'
assert dates.format_time(t, 'K a', locale=l) == '0 AM'
assert dates.format_time(t, 'h a', locale=locale) == '12 AM'
assert dates.format_time(t, 'H', locale=locale) == '0'
assert dates.format_time(t, 'k', locale=locale) == '24'
assert dates.format_time(t, 'K a', locale=locale) == '0 AM'
t = time(12, 0, 0)
assert dates.format_time(t, 'h a', locale=l) == '12 PM'
assert dates.format_time(t, 'H', locale=l) == '12'
assert dates.format_time(t, 'k', locale=l) == '12'
assert dates.format_time(t, 'K a', locale=l) == '0 PM'
assert dates.format_time(t, 'h a', locale=locale) == '12 PM'
assert dates.format_time(t, 'H', locale=locale) == '12'
assert dates.format_time(t, 'k', locale=locale) == '12'
assert dates.format_time(t, 'K a', locale=locale) == '0 PM'


class FormatDateTestCase:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_localedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def test_merge():


def test_locale_identification():
for l in localedata.locale_identifiers():
assert localedata.exists(l)
for locale in localedata.locale_identifiers():
assert localedata.exists(locale)


def test_unique_ids():
Expand All @@ -84,9 +84,9 @@ def test_unique_ids():


def test_mixedcased_locale():
for l in localedata.locale_identifiers():
for locale in localedata.locale_identifiers():
locale_id = ''.join([
methodcaller(random.choice(['lower', 'upper']))(c) for c in l])
methodcaller(random.choice(['lower', 'upper']))(c) for c in locale])
assert localedata.exists(locale_id)


Expand Down

0 comments on commit b973635

Please sign in to comment.