refurbishing code (auto-fix)

ruff 'FURB'
This commit is contained in:
un-pogaz 2025-10-11 17:21:25 +02:00
parent e37b4cd1ca
commit e428bb13ce
4 changed files with 14 additions and 14 deletions

View File

@ -105,7 +105,7 @@ quote-style = 'single'
explicit-preview-rules = true
ignore = [
'E402', 'E741',
'UP012', 'UP030', 'C413', 'C420', 'PIE790', 'ISC003',
'UP012', 'UP030', 'C413', 'C420', 'PIE790', 'ISC003', 'FURB122', 'FURB166', 'FURB167', 'FURB116', 'FURB136', 'FURB188',
'RUF001', 'RUF002', 'RUF003', 'RUF005', 'RUF012', 'RUF013', 'RUF015', 'RUF031', 'RUF100',
'PLE1205', 'PLW0602', 'PLW0603', 'PLW1510', 'PLW1641', 'PLW2901', 'PLC0415',
'PLR0911', 'PLR0912', 'PLR0913', 'PLR0914', 'PLR0915', 'PLR0916', 'PLR0917', 'PLR1702', 'PLR1704', 'PLR2004', 'PLR6301',
@ -114,7 +114,7 @@ ignore = [
select = [
'E', 'F', 'I', 'W', 'INT',
'Q', 'UP', 'YTT', 'TID', 'C4', 'COM818', 'PIE', 'RET501', 'ISC',
'PLE', 'PLW', 'PLC', 'PLR', 'ASYNC',
'PLE', 'PLW', 'PLC', 'PLR', 'ASYNC', 'FURB',
'RUF', # note: RUF can flag many unsolicited errors
# preview rules
'RUF051', 'RUF056', # useless dict operation

View File

@ -293,7 +293,7 @@ class Sdist(Command):
self.info('\tRunning git export...')
os.mkdir(tdir)
subprocess.check_call('git archive HEAD | tar -x -C ' + tdir, shell=True)
for x in open('.gitignore').readlines():
for x in open('.gitignore'):
if not x.startswith('/resources/'):
continue
x = x[1:]

View File

@ -31,7 +31,7 @@ def node_mountpoint(node):
return de_mangle(row['mntpoint'].encode('utf-8'))
else:
with open('/proc/mounts', 'rb') as src:
for line in src.readlines():
for line in src:
line = line.split()
if line[0] == node:
return de_mangle(line[1])

View File

@ -21,11 +21,11 @@ def ereader_header_info(header):
if len(h0) == 132:
print('Header Type: Dropbook compatible')
print('')
print()
ereader_header_info132(h0)
elif len(h0) == 202:
print('Header Type: Makebook compatible')
print('')
print()
ereader_header_info202(h0)
else:
raise EreaderError(f'Size mismatch. eReader header record size {len(h0)} KB is not supported.')
@ -33,16 +33,16 @@ def ereader_header_info(header):
def pdb_header_info(header):
print('PDB Header Info:')
print('')
print()
print(f'Identity: {header.ident}')
print(f'Total Sections: {header.num_sections}')
print(f'Title: {header.title}')
print('')
print()
def ereader_header_info132(h0):
print('Ereader Record 0 (Header) Info:')
print('')
print()
print(f"0-2 Version: {struct.unpack('>H', h0[0:2])[0]}")
print(f"2-4: {struct.unpack('>H', h0[2:4])[0]}")
print(f"4-6: {struct.unpack('>H', h0[4:6])[0]}")
@ -74,12 +74,12 @@ def ereader_header_info132(h0):
for i in range(54, 131, 2):
print(f"{i}-{i + 2}: {struct.unpack('>H', h0[i:i + 2])[0]}")
print('')
print()
def ereader_header_info202(h0):
print('Ereader Record 0 (Header) Info:')
print('')
print()
print(f"0-2 Version: {struct.unpack('>H', h0[0:2])[0]}")
print(f"2-4 Garbage: {struct.unpack('>H', h0[2:4])[0]}")
print(f"4-6 Garbage: {struct.unpack('>H', h0[4:6])[0]}")
@ -105,14 +105,14 @@ def ereader_header_info202(h0):
for i in range(116, 202, 2):
print(f"{i}-{i + 2}: {struct.unpack('>H', h0[i:i + 2])[0]}")
print('')
print()
print('* Garbage: Random values.')
print('')
print()
def section_lengths(header):
print('Section Sizes')
print('')
print()
for i in range(header.section_count()):
size = len(header.section_data(i))