unsorted dunder all/slots (auto-fix)

ruff 'RUF022,RUF023'
This commit is contained in:
un-pogaz 2025-01-24 11:14:19 +01:00
parent 88bae18216
commit d8aecf09ea
21 changed files with 111 additions and 58 deletions

View File

@ -20,7 +20,7 @@ quote-style = 'single'
ignore = [
'E402', 'E722', 'E741',
'UP012', 'UP030', 'UP032', 'UP038', 'C413', 'C420',
'RUF001', 'RUF002', 'RUF003', 'RUF005', 'RUF010', 'RUF012', 'RUF013', 'RUF015', 'RUF019', 'RUF021', 'RUF022', 'RUF023', 'RUF031', 'RUF034', 'RUF100',
'RUF001', 'RUF002', 'RUF003', 'RUF005', 'RUF010', 'RUF012', 'RUF013', 'RUF015', 'RUF019', 'RUF021', 'RUF031', 'RUF034', 'RUF100',
]
select = [
'E', 'F', 'I', 'W', 'INT',
@ -31,6 +31,7 @@ select = [
[lint.per-file-ignores]
"recipes/*" = ['UP']
"manual/plugin_examples/*" = ['UP']
"setup/commands.py" = ['RUF022']
"src/calibre/*" = ['UP031']
"src/calibre/ebooks/unihandecode/*codepoints.py" = ['E501']
"src/calibre/ebooks/metadata/sources/*" = ['UP']

View File

@ -138,8 +138,13 @@ def load_translations(namespace, zfp):
class CalibrePluginLoader:
__slots__ = (
'plugin_name', 'fullname_in_plugin', 'zip_file_path', '_is_package', 'names',
'filename', 'all_names'
'_is_package',
'all_names',
'filename',
'fullname_in_plugin',
'names',
'plugin_name',
'zip_file_path'
)
def __init__(self, plugin_name, fullname_in_plugin, zip_file_path, names, filename, is_package, all_names):

View File

@ -21,9 +21,23 @@ CATEGORY_SORTS = ('name', 'popularity', 'rating') # This has to be a tuple not
class Tag:
__slots__ = ('name', 'original_name', 'id', 'count', 'state', 'is_hierarchical',
'is_editable', 'is_searchable', 'id_set', 'avg_rating', 'sort',
'use_sort_as_name', 'category', 'search_expression', 'original_categories')
__slots__ = (
'avg_rating',
'category',
'count',
'id',
'id_set',
'is_editable',
'is_hierarchical',
'is_searchable',
'name',
'original_categories',
'original_name',
'search_expression',
'sort',
'state',
'use_sort_as_name',
)
def __init__(self, name, id=None, count=0, state=0, avg=0, sort=None,
category=None, id_set=None, search_expression=None,

View File

@ -471,7 +471,7 @@ class OnDeviceField(OneToOneField):
class LazySortMap:
__slots__ = ('default_sort_key', 'sort_key_func', 'id_map', 'cache')
__slots__ = ('cache', 'default_sort_key', 'id_map', 'sort_key_func')
def __init__(self, default_sort_key, sort_key_func, id_map):
self.default_sort_key = default_sort_key
@ -701,7 +701,7 @@ class FormatsField(ManyToManyField):
class LazySeriesSortMap:
__slots__ = ('default_sort_key', 'sort_key_func', 'id_map', 'cache')
__slots__ = ('cache', 'default_sort_key', 'id_map', 'sort_key_func')
def __init__(self, default_sort_key, sort_key_func, id_map):
self.default_sort_key = default_sort_key

View File

@ -164,7 +164,7 @@ def fixcase(x):
class Option:
__slots__ = ['type', 'default', 'label', 'desc', 'name', 'choices']
__slots__ = ['choices', 'default', 'desc', 'label', 'name', 'type']
def __init__(self, name, type_, default, label, desc, choices=None):
'''

View File

@ -22,7 +22,7 @@ _patterns = None
class Patterns:
__slots__ = ('sanitize_invisible_pat', 'split_pat', 'digit_pat', 'fr_elision_pat')
__slots__ = ('digit_pat', 'fr_elision_pat', 'sanitize_invisible_pat', 'split_pat')
def __init__(self):
import regex
@ -56,7 +56,7 @@ class CharCounter:
class Location:
__slots__ = ('file_name', 'sourceline', 'original_word', 'location_node', 'node_item', 'elided_prefix')
__slots__ = ('elided_prefix', 'file_name', 'location_node', 'node_item', 'original_word', 'sourceline')
def __init__(self, file_name=None, elided_prefix='', original_word=None, location_node=None, node_item=(None, None)):
self.file_name, self.elided_prefix, self.original_word = file_name, elided_prefix, original_word

View File

@ -624,7 +624,7 @@ def make_anchors_unique(container, log):
class AnchorLocation:
__slots__ = ('pagenum', 'left', 'top', 'zoom')
__slots__ = ('left', 'pagenum', 'top', 'zoom')
def __init__(self, pagenum=1, left=0, top=0, zoom=0):
self.pagenum, self.left, self.top, self.zoom = pagenum, left, top, zoom

View File

@ -58,7 +58,7 @@ def painter(func):
class SelectionState:
__slots__ = ('last_press_point', 'current_mode', 'rect', 'in_selection', 'drag_corner', 'dragging', 'last_drag_pos')
__slots__ = ('current_mode', 'drag_corner', 'dragging', 'in_selection', 'last_drag_pos', 'last_press_point', 'rect')
def __init__(self):
self.reset()

View File

@ -144,7 +144,7 @@ IN_COMMENT_CONTENT = 5
class CSSState:
__slots__ = ('parse', 'blocks')
__slots__ = ('blocks', 'parse')
def __init__(self):
self.parse = NORMAL

View File

@ -109,7 +109,7 @@ class Heading(QWidget): # {{{
class Cell: # {{{
__slots__ = ('rect', 'text', 'right_align', 'color_role', 'override_color', 'swatch', 'is_overriden')
__slots__ = ('color_role', 'is_overriden', 'override_color', 'rect', 'right_align', 'swatch', 'text')
SIDE_MARGIN = 5
FLAGS = Qt.AlignmentFlag.AlignVCenter | Qt.TextFlag.TextSingleLine | Qt.TextFlag.TextIncludeTrailingSpaces
@ -386,7 +386,7 @@ class Box(QWidget):
class Property:
__slots__ = 'name', 'value', 'important', 'color', 'specificity', 'is_overriden'
__slots__ = 'color', 'important', 'is_overriden', 'name', 'specificity', 'value'
def __init__(self, prop, specificity=()):
self.name, self.value, self.important, self.color = prop

View File

@ -78,7 +78,7 @@ def parse_html(raw):
class ParseItem:
__slots__ = ('name', 'length', 'fingerprint', 'parsing_done', 'parsed_data')
__slots__ = ('fingerprint', 'length', 'name', 'parsed_data', 'parsing_done')
def __init__(self, name):
self.name = name

View File

@ -183,9 +183,18 @@ class SearchFinished:
class SearchResult:
__slots__ = (
'search_query', 'before', 'text', 'after', 'q', 'spine_idx',
'index', 'file_name', 'is_hidden', 'offset', 'toc_nodes',
'result_num'
'after',
'before',
'file_name',
'index',
'is_hidden',
'offset',
'q',
'result_num',
'search_query',
'spine_idx',
'text',
'toc_nodes'
)
def __init__(self, search_query, before, text, after, q, name, spine_idx, index, offset, result_num):

View File

@ -40,7 +40,7 @@ from calibre.utils.localization import _
class Action:
__slots__ = ('icon', 'text', 'shortcut_action')
__slots__ = ('icon', 'shortcut_action', 'text')
def __init__(self, icon=None, text=None, shortcut_action=None):
self.icon, self.text, self.shortcut_action = QIcon.ic(icon), text, shortcut_action

View File

@ -32,7 +32,7 @@ not_present = object()
class UserDictionary:
__slots__ = ('name', 'is_active', 'words')
__slots__ = ('is_active', 'name', 'words')
def __init__(self, **kwargs):
self.name = kwargs['name']

View File

@ -134,7 +134,7 @@ class HTTPHeaderParser:
Headers which are repeated are folded together using a comma if their
specification so dictates.
'''
__slots__ = ('hdict', 'lines', 'finished')
__slots__ = ('finished', 'hdict', 'lines')
def __init__(self):
self.hdict = MultiDict()

View File

@ -49,7 +49,7 @@ class ReadBuffer: # {{{
' A ring buffer used to speed up the readline() implementation by minimizing recv() calls '
__slots__ = ('ba', 'buf', 'read_pos', 'write_pos', 'full_state')
__slots__ = ('ba', 'buf', 'full_state', 'read_pos', 'write_pos')
def __init__(self, size=4096):
self.ba = bytearray(size)

View File

@ -213,7 +213,7 @@ CategoriesSettings = namedtuple(
class GroupedSearchTerms:
__slots__ = ('keys', 'vals', 'hash')
__slots__ = ('hash', 'keys', 'vals')
def __init__(self, src):
self.keys = frozenset(src)

View File

@ -226,7 +226,12 @@ def process_item(ctx, haystack, needle):
class PyScorer:
__slots__ = (
'level1', 'level2', 'level3', 'max_score_per_char', 'items', 'memory'
'items',
'level1',
'level2',
'level3',
'max_score_per_char',
'memory'
)
def __init__(

View File

@ -54,10 +54,20 @@ from sys import stderr
from polyglot.builtins import string_or_bytes
__all__ = ['SMTPException', 'SMTPServerDisconnected', 'SMTPResponseException',
'SMTPSenderRefused', 'SMTPRecipientsRefused', 'SMTPDataError',
'SMTPConnectError', 'SMTPHeloError', 'SMTPAuthenticationError',
'quoteaddr', 'quotedata', 'SMTP']
__all__ = [
'SMTP',
'SMTPAuthenticationError',
'SMTPConnectError',
'SMTPDataError',
'SMTPException',
'SMTPHeloError',
'SMTPRecipientsRefused',
'SMTPResponseException',
'SMTPSenderRefused',
'SMTPServerDisconnected',
'quoteaddr',
'quotedata',
]
SMTP_PORT = 25
SMTP_SSL_PORT = 465

View File

@ -31,12 +31,12 @@ Website : http://chrisarndt.de/en/software/python/threadpool/
'''
__all__ = [
'makeRequests',
'NoResultsPending',
'NoWorkersAvailable',
'ThreadPool',
'WorkRequest',
'WorkerThread'
'NoResultsPending',
'NoWorkersAvailable',
'ThreadPool',
'WorkRequest',
'WorkerThread',
'makeRequests'
]
__author__ = 'Christopher Arndt'

View File

@ -26,8 +26,17 @@ except ImportError:
zlib = None
crc32 = binascii.crc32
__all__ = ['BadZipfile', 'error', 'ZIP_STORED', 'ZIP_DEFLATED', 'is_zipfile',
'ZipInfo', 'ZipFile', 'PyZipFile', 'LargeZipFile']
__all__ = [
'ZIP_DEFLATED',
'ZIP_STORED',
'BadZipfile',
'LargeZipFile',
'PyZipFile',
'ZipFile',
'ZipInfo',
'error',
'is_zipfile',
]
def decode_zip_internal_file_name(fname, flags):
@ -305,26 +314,26 @@ class ZipInfo :
'''Class with attributes describing each file in the ZIP archive.'''
__slots__ = (
'orig_filename',
'filename',
'date_time',
'compress_type',
'comment',
'extra',
'create_system',
'create_version',
'extract_version',
'reserved',
'flag_bits',
'volume',
'internal_attr',
'external_attr',
'header_offset',
'CRC',
'compress_size',
'file_size',
'_raw_time',
'file_offset',
'CRC',
'_raw_time',
'comment',
'compress_size',
'compress_type',
'create_system',
'create_version',
'date_time',
'external_attr',
'extra',
'extract_version',
'file_offset',
'file_size',
'filename',
'flag_bits',
'header_offset',
'internal_attr',
'orig_filename',
'reserved',
'volume',
)
def __init__(self, filename='NoName', date_time=(1980,1,1,0,0,0)):