mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-12 23:54:17 +00:00
Prefer iter(dict) instead of dict.keys()
They are equivalent for iterating so remove the additional function call. Pattern identified as outdated by Lennart Regebro's PyCon 2017 talk "Prehistoric Patterns in Python" https://www.youtube.com/watch?v=V5-JH23Vk0I
This commit is contained in:
parent
d890b8b683
commit
db4f71288e
5 changed files with 6 additions and 6 deletions
|
|
@ -261,7 +261,7 @@ class Application(object):
|
||||||
List of filenames to process
|
List of filenames to process
|
||||||
"""
|
"""
|
||||||
if self.running_against_diff:
|
if self.running_against_diff:
|
||||||
files = sorted(self.parsed_diff.keys())
|
files = sorted(self.parsed_diff)
|
||||||
self.file_checker_manager.start(files)
|
self.file_checker_manager.start(files)
|
||||||
self.file_checker_manager.run()
|
self.file_checker_manager.run()
|
||||||
LOG.info('Finished running')
|
LOG.info('Finished running')
|
||||||
|
|
|
||||||
|
|
@ -36,4 +36,4 @@ def install(option, option_string, value, parser):
|
||||||
|
|
||||||
def choices():
|
def choices():
|
||||||
"""Return the list of VCS choices."""
|
"""Return the list of VCS choices."""
|
||||||
return list(_INSTALLERS.keys())
|
return list(_INSTALLERS)
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ class TrieNode(object):
|
||||||
if not self.children:
|
if not self.children:
|
||||||
return
|
return
|
||||||
|
|
||||||
for prefix in sorted(self.children.keys()):
|
for prefix in sorted(self.children):
|
||||||
child = self.children[prefix]
|
child = self.children[prefix]
|
||||||
yield child
|
yield child
|
||||||
for child in child.traverse():
|
for child in child.traverse():
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class Statistics(object):
|
||||||
:rtype:
|
:rtype:
|
||||||
list(str)
|
list(str)
|
||||||
"""
|
"""
|
||||||
return sorted({key.code for key in self._store.keys()})
|
return sorted({key.code for key in self._store})
|
||||||
|
|
||||||
def record(self, error):
|
def record(self, error):
|
||||||
"""Add the fact that the error was seen in the file.
|
"""Add the fact that the error was seen in the file.
|
||||||
|
|
@ -55,7 +55,7 @@ class Statistics(object):
|
||||||
:returns:
|
:returns:
|
||||||
Generator of instances of :class:`Statistic`
|
Generator of instances of :class:`Statistic`
|
||||||
"""
|
"""
|
||||||
matching_errors = sorted(key for key in self._store.keys()
|
matching_errors = sorted(key for key in self._store
|
||||||
if key.matches(prefix, filename))
|
if key.matches(prefix, filename))
|
||||||
for error_code in matching_errors:
|
for error_code in matching_errors:
|
||||||
yield self._store[error_code]
|
yield self._store[error_code]
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,7 @@ class FakePluginTypeManager(manager.NotifierBuilderMixin):
|
||||||
|
|
||||||
def __init__(self, manager):
|
def __init__(self, manager):
|
||||||
"""Initialize with our fake manager."""
|
"""Initialize with our fake manager."""
|
||||||
self.names = sorted(manager.keys())
|
self.names = sorted(manager)
|
||||||
self.manager = manager
|
self.manager = manager
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue