unnecessary collection call and some dict with keyword arguments (auto-fix)

ruff 'C408'
This commit is contained in:
un-pogaz 2025-01-24 11:14:19 +01:00
parent 9d46c5344c
commit bd59bf631e
15 changed files with 27 additions and 24 deletions

View File

@ -22,5 +22,5 @@ class ParisReview(BasicNewsRecipe):
# keep_only_tags = []
remove_tags = []
# remove_tags_before = dict()
remove_tags_after = dict()
remove_tags_after = {}
feeds = [('Posts', 'http://feeds.feedburner.com/TheParisReviewBlog')]

View File

@ -74,7 +74,7 @@ class SolHaberRecipe(BasicNewsRecipe):
def parse_index(self):
result = []
articles_dict = dict()
articles_dict = {}
author_regexp = re.compile('^http://.*?/yazarlar/(.*?)/.*$')
category_regexp = re.compile('^http://.*?/(.+?)/.*$')

View File

@ -19,7 +19,7 @@ quote-style = 'single'
[lint]
ignore = [
'E402', 'E722', 'E741',
'UP012', 'UP030', 'UP032', 'UP038', 'C408', 'C413', 'C420',
'UP012', 'UP030', 'UP032', 'UP038', 'C413', 'C420',
]
select = [
'E', 'F', 'I', 'W', 'INT',
@ -50,6 +50,9 @@ section-order = ['__python__', "future", "standard-library", "third-party", "fir
[lint.isort.sections]
'__python__' = ['__python__']
[lint.flake8-comprehensions]
allow-dict-calls-with-keyword-arguments = true
[lint.flake8-quotes]
avoid-escape = true
docstring-quotes = 'single'

View File

@ -66,7 +66,7 @@ class ConnectionListener(Thread):
self.daemon = True
self.driver = driver
self.keep_running = True
self.all_ip_addresses = dict()
self.all_ip_addresses = {}
def stop(self):
self.keep_running = False
@ -980,7 +980,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
self._debug('timeout -- disconnected')
else:
try:
if self._call_client('NOOP', dict())[0] is None:
if self._call_client('NOOP', {})[0] is None:
self._close_device_socket()
except:
self._close_device_socket()
@ -1229,7 +1229,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
def get_device_information(self, end_session=True):
self._debug()
self.report_progress(1.0, _('Get device information...'))
opcode, result = self._call_client('GET_DEVICE_INFORMATION', dict())
opcode, result = self._call_client('GET_DEVICE_INFORMATION', {})
if opcode == 'OK':
self.driveinfo = result['device_info']
self._update_driveinfo_record(self.driveinfo, self.PREFIX, 'main')

View File

@ -446,7 +446,7 @@ class HTMLConverter:
@return: A dictionary with one entry for each property where the key
is the property name and the value is the property value.
'''
prop = dict()
prop = {}
for s in props.split(';'):
l = s.split(':',1)
if len(l)==2:

View File

@ -2301,7 +2301,7 @@ class ImageStream(LrsObject, LrsContainer):
class Image(LrsObject, LrsContainer, LrsAttributes):
defaults = dict()
defaults = {}
def __init__(self, refstream, x0=0, x1=0,
y0=0, y1=0, xsize=0, ysize=0, **settings):

View File

@ -339,11 +339,11 @@ class TestOPF3(unittest.TestCase):
set_user_metadata(root, read_prefixes(root), read_refines(root), val)
return ru(root)
root = self.get_opf('''<meta name="calibre:user_metadata:#a" content='{"1":1}'/>''')
self.ae({'#a': {'1': 1, 'is_multiple': dict()}}, ru(root))
self.ae({'#a': {'1': 1, 'is_multiple': {}}}, ru(root))
root = self.get_opf('''<meta name="calibre:user_metadata:#a" content='{"1":1}'/>'''
'''<meta property="calibre:user_metadata">{"#b":{"2":2}}</meta>''')
self.ae({'#b': {'2': 2, 'is_multiple': dict()}}, ru(root))
self.ae({'#c': {'3': 3, 'is_multiple': {}, 'is_multiple2': dict()}}, su(root, {'#c':{'3':3}}))
self.ae({'#b': {'2': 2, 'is_multiple': {}}}, ru(root))
self.ae({'#c': {'3': 3, 'is_multiple': {}, 'is_multiple2': {}}}, su(root, {'#c':{'3':3}}))
# }}}

View File

@ -81,8 +81,8 @@ class AllGUIActions(InterfaceAction):
# Get display names of builtin and user plugins. We tell the difference
# using the class full module name. Plugins start with 'calibre_plugins'
builtin_actions = list()
user_plugins = list()
builtin_actions = []
user_plugins = []
for display_name, act_data in name_data.items():
act = model.name_to_action(act_data['action_name'], self.gui)
if act is not None:

View File

@ -149,7 +149,7 @@ class MarkBooksAction(InterfaceActionWithLibraryDrop):
num = len(frozenset(marked_ids).intersection(db.new_api.all_book_ids()))
text = _('Show marked book') if num == 1 else (_('Show marked books') + (' (%d)' % num))
self.show_marked_action.setText(text)
counts = dict()
counts = {}
for v in marked_ids.values():
counts[v] = counts.get(v, 0) + 1
labels = sorted(counts.keys(), key=sort_key)

View File

@ -24,7 +24,7 @@ class OpenFolderAction(InterfaceAction):
va = self.gui.iactions['View'].view_folder
self.qaction.triggered.connect(va)
a = self.create_menu_action(self.qaction.menu(), 'show-data-folder',
_('Open book data folder'), icon='document_open.png', shortcut=tuple())
_('Open book data folder'), icon='document_open.png', shortcut=())
a.triggered.connect(partial(va, data_folder=True))
def location_selected(self, loc):

View File

@ -31,7 +31,7 @@ class ShowTemplateTesterAction(InterfaceAction):
# text=self.non_modal_window_title,
# icon='debug.png',
# triggered=partial(self.show_template_editor, modal=False))
self.non_modal_dialogs = list()
self.non_modal_dialogs = []
def last_template_text(self):
return self.previous_text

View File

@ -260,8 +260,8 @@ class BookInfo(QDialog, DropMixin):
mi = dbn.get_metadata(book_id, get_cover=False)
mi.cover_data = [None, dbn.cover(book_id, as_image=True)]
mi.path = None
mi.format_files = dict()
mi.formats = list()
mi.format_files = {}
mi.formats = []
mi.marked = ''
mi.field_metadata = db.field_metadata
mi.external_library_path = library_path

View File

@ -19,7 +19,7 @@ def ipaddr_sort_key(ipaddr):
def get_all_ip_addresses():
ipaddrs = list()
ipaddrs = []
for iface in itervalues(get_all_ips()):
for addrs in iface:
if 'broadcast' in addrs and addrs['addr'] != '127.0.0.1':

View File

@ -769,7 +769,7 @@ class _Parser:
# Eat the opening paren, parse the argument list, then eat the closing paren
self.consume()
arguments = list()
arguments = []
while not self.token_op_is(')'):
# parse an argument expression (recursive call)
arguments.append(self.expression_list())
@ -983,7 +983,7 @@ class _Interpreter:
self.parent_book = parent.book
self.funcs = funcs
self.locals = {'$':val}
self.local_functions = dict()
self.local_functions = {}
self.override_line_number = None
self.global_vars = global_vars if isinstance(global_vars, dict) else {}
if break_reporter:
@ -1128,7 +1128,7 @@ class _Interpreter:
self.error(_("Unknown identifier '{0}'").format(prog.name), prog.line_number)
def do_node_func(self, prog):
args = list()
args = []
for arg in prog.expression_list:
# evaluate the expression (recursive call)
args.append(self.expr(arg))
@ -1192,7 +1192,7 @@ class _Interpreter:
len(prog.arguments),
len(argument_list)),
prog.line_number)
new_locals = dict()
new_locals = {}
for i,arg in enumerate(argument_list):
if len(prog.arguments) > i:
new_locals[arg.left] = self.expr(prog.arguments[i])

View File

@ -1873,7 +1873,7 @@ program:
"associated separator"))
# Starting in python 3.7 dicts preserve order so we don't need OrderedDict
result = dict()
result = {}
i = 0
while i < len(args):
lst = [v.strip() for v in args[i].split(args[i+1]) if v.strip()]