Bug 1344836 - Enable flake8 rule E713: "test for membership should be 'not in'". r=Dexter

This patch enables flake8 rule E713:
"test for membership should be 'not in'" in toolkit/components/telemetry
by removing the relative E713 entry from toolkit/components/telemetry/.flake8
and fixing the files for which the E713 error was reported.
Precisely 6 errors violating E713 rule were found and solved.

MozReview-Commit-ID: 2AaYGgVkxbU

--HG--
extra : rebase_source : 5f655591a18c4d0b2e7189732ebd8db0f20b0c6a
This commit is contained in:
Federico Padua 2017-03-14 02:03:13 +01:00
Родитель fb18ceba5d
Коммит 8e4d52d31b
4 изменённых файлов: 7 добавлений и 7 удалений

Просмотреть файл

@ -1,5 +1,5 @@
[flake8]
# See http://pep8.readthedocs.io/en/latest/intro.html#configuration
ignore = E121, E123, E126, E129, E133, E226, E241, E242, E704, W503, E402, E128, E501, E713, E202, W602, E127, W601
ignore = E121, E123, E126, E129, E133, E226, E241, E242, E704, W503, E402, E128, E501, E202, W602, E127, W601
max-line-length = 99
filename = *.py, +.lint

Просмотреть файл

@ -40,7 +40,7 @@ def main(output, *filenames):
index = 0
for e in events:
category = e.category
if not category in grouped:
if category not in grouped:
grouped[category] = []
grouped[category].append((index, e))
index += len(e.enum_labels)

Просмотреть файл

@ -134,7 +134,7 @@ symbol that should guard C/C++ definitions associated with the histogram."""
datasets = {'opt-in': 'DATASET_RELEASE_CHANNEL_OPTIN',
'opt-out': 'DATASET_RELEASE_CHANNEL_OPTOUT'}
value = definition.get('releaseChannelCollection', 'opt-in')
if not value in datasets:
if value not in datasets:
raise DefinitionException, "unknown release channel collection policy for " + name
self._dataset = "nsITelemetry::" + datasets[value]
@ -367,14 +367,14 @@ associated with the histogram. Returns None if no guarding is necessary."""
return t.__name__
for key, key_type in type_checked_fields.iteritems():
if not key in definition:
if key not in definition:
continue
if not isinstance(definition[key], key_type):
raise ValueError, ('value for key "{0}" in Histogram "{1}" '
'should be {2}').format(key, name, nice_type_name(key_type))
for key, key_type in type_checked_list_fields.iteritems():
if not key in definition:
if key not in definition:
continue
if not all(isinstance(x, key_type) for x in definition[key]):
raise ValueError, ('all values for list "{0}" in Histogram "{1}" '

Просмотреть файл

@ -169,7 +169,7 @@ class EventData:
rcc_key = 'release_channel_collection'
rcc = definition.get(rcc_key, 'opt-in')
allowed_rcc = ["opt-in", "opt-out"]
if not rcc in allowed_rcc:
if rcc not in allowed_rcc:
raise ValueError, "%s: value for %s should be one of: %s" %\
(self.identifier, rcc_key, ", ".join(allowed_rcc))
@ -190,7 +190,7 @@ class EventData:
regex=IDENTIFIER_PATTERN)
# Check expiry.
if not 'expiry_version' in definition and not 'expiry_date' in definition:
if 'expiry_version' not in definition and 'expiry_date' not in definition:
raise KeyError, "%s: event is missing an expiration - either expiry_version or expiry_date is required" %\
(self.identifier)
expiry_date = definition.get('expiry_date')