diff --git a/recipes/parisreview.recipe b/recipes/parisreview.recipe index e670ff7a53..62e6663195 100644 --- a/recipes/parisreview.recipe +++ b/recipes/parisreview.recipe @@ -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')] diff --git a/recipes/sol_haber.recipe b/recipes/sol_haber.recipe index 164ff1da5f..b2b1c9d421 100644 --- a/recipes/sol_haber.recipe +++ b/recipes/sol_haber.recipe @@ -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://.*?/(.+?)/.*$') diff --git a/ruff-strict-pep8.toml b/ruff-strict-pep8.toml index fb6af8e1e9..ff2c6e4b67 100644 --- a/ruff-strict-pep8.toml +++ b/ruff-strict-pep8.toml @@ -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' diff --git a/src/calibre/devices/smart_device_app/driver.py b/src/calibre/devices/smart_device_app/driver.py index 136d7020e2..22196790c9 100644 --- a/src/calibre/devices/smart_device_app/driver.py +++ b/src/calibre/devices/smart_device_app/driver.py @@ -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') diff --git a/src/calibre/ebooks/lrf/html/convert_from.py b/src/calibre/ebooks/lrf/html/convert_from.py index 0fbef54a27..0bed5ac710 100644 --- a/src/calibre/ebooks/lrf/html/convert_from.py +++ b/src/calibre/ebooks/lrf/html/convert_from.py @@ -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: diff --git a/src/calibre/ebooks/lrf/pylrs/pylrs.py b/src/calibre/ebooks/lrf/pylrs/pylrs.py index 4594295730..6d7aa0b14e 100644 --- a/src/calibre/ebooks/lrf/pylrs/pylrs.py +++ b/src/calibre/ebooks/lrf/pylrs/pylrs.py @@ -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): diff --git a/src/calibre/ebooks/metadata/opf3_test.py b/src/calibre/ebooks/metadata/opf3_test.py index ebb265027c..ba7f97f419 100644 --- a/src/calibre/ebooks/metadata/opf3_test.py +++ b/src/calibre/ebooks/metadata/opf3_test.py @@ -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('''''') - self.ae({'#a': {'1': 1, 'is_multiple': dict()}}, ru(root)) + self.ae({'#a': {'1': 1, 'is_multiple': {}}}, ru(root)) root = self.get_opf('''''' '''{"#b":{"2":2}}''') - 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}})) # }}} diff --git a/src/calibre/gui2/actions/all_actions.py b/src/calibre/gui2/actions/all_actions.py index a89f9e632b..12f0d2c30e 100644 --- a/src/calibre/gui2/actions/all_actions.py +++ b/src/calibre/gui2/actions/all_actions.py @@ -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: diff --git a/src/calibre/gui2/actions/mark_books.py b/src/calibre/gui2/actions/mark_books.py index e1f75061f6..49ffa9f93f 100644 --- a/src/calibre/gui2/actions/mark_books.py +++ b/src/calibre/gui2/actions/mark_books.py @@ -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) diff --git a/src/calibre/gui2/actions/open.py b/src/calibre/gui2/actions/open.py index 2d3c5f6c41..b5fbeb586b 100644 --- a/src/calibre/gui2/actions/open.py +++ b/src/calibre/gui2/actions/open.py @@ -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): diff --git a/src/calibre/gui2/actions/show_template_tester.py b/src/calibre/gui2/actions/show_template_tester.py index dbd2c9da8e..f751ce98a9 100644 --- a/src/calibre/gui2/actions/show_template_tester.py +++ b/src/calibre/gui2/actions/show_template_tester.py @@ -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 diff --git a/src/calibre/gui2/dialogs/book_info.py b/src/calibre/gui2/dialogs/book_info.py index f2cee736b3..919872de43 100644 --- a/src/calibre/gui2/dialogs/book_info.py +++ b/src/calibre/gui2/dialogs/book_info.py @@ -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 diff --git a/src/calibre/gui2/dialogs/smartdevice.py b/src/calibre/gui2/dialogs/smartdevice.py index a47cd42745..b539473a5d 100644 --- a/src/calibre/gui2/dialogs/smartdevice.py +++ b/src/calibre/gui2/dialogs/smartdevice.py @@ -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': diff --git a/src/calibre/utils/formatter.py b/src/calibre/utils/formatter.py index ba3d8b33a4..cfa12ecf47 100644 --- a/src/calibre/utils/formatter.py +++ b/src/calibre/utils/formatter.py @@ -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]) diff --git a/src/calibre/utils/formatter_functions.py b/src/calibre/utils/formatter_functions.py index 8f5672ec01..6aa2b072c4 100644 --- a/src/calibre/utils/formatter_functions.py +++ b/src/calibre/utils/formatter_functions.py @@ -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()]