Skip to content

Commit 6e1dd89

Browse files
committed
Fix some pylint and ruff check warnings.
1 parent 37f61e3 commit 6e1dd89

12 files changed

+28
-33
lines changed

scintilla/scripts/EastAsianWidth.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# https://www.unicode.org/reports/tr41/
1+
# East Asian Width
22
# https://www.unicode.org/reports/tr11/
33

4-
from FileGenerator import Regenerate
54
from MultiStageTable import *
65
from UnicodeData import *
76

scintilla/scripts/GenerateCaseConvert.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ def conversionSets():
4949
complexes = []
5050
symmetrics = []
5151
for ch in range(UnicodeCharacterCount):
52-
if ch >= 0xd800 and ch <= 0xDBFF:
52+
if 0xd800 <= ch <= 0xDBFF:
5353
continue
54-
if ch >= 0xdc00 and ch <= 0xDFFF:
54+
if 0xdc00 <= ch <= 0xDFFF:
5555
continue
5656
uch = chr(ch)
5757

scintilla/scripts/GenerateCharTable.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ def BytesFromLead(leadByte):
2323
def UTF8IsLeadByte(ch):
2424
if ch <= 0x7F:
2525
return True
26-
if ch >= 0xC2 and ch <= 0xF4:
26+
if 0xC2 <= ch <= 0xF4:
2727
return True
2828
return False
2929

3030
def UTF8IsTrailByte(ch):
31-
return ch >= 0x80 and ch <= 0xBF
31+
return 0x80 <= ch <= 0xBF
3232

3333
def UTF8IntervalNumber(ch):
3434
# UTF8-1
@@ -45,12 +45,12 @@ def UTF8IntervalNumber(ch):
4545
if ch == 0xC0 or ch == 0xC1:
4646
return 11
4747
# UTF8-2
48-
if ch >= 0xC2 and ch <= 0xDF:
48+
if 0xC2 <= ch <= 0xDF:
4949
return 4
5050
# UTF8-3
5151
if ch == 0xE0:
5252
return 5
53-
if ch >= 0xE1 and ch <= 0xEC:
53+
if 0xE1 <= ch <= 0xEC:
5454
return 6
5555
if ch == 0xED:
5656
return 7
@@ -59,7 +59,7 @@ def UTF8IntervalNumber(ch):
5959
# UTF8-4
6060
if ch == 0xF0:
6161
return 8
62-
if ch >= 0xF1 and ch <= 0xF3:
62+
if 0xF1 <= ch <= 0xF3:
6363
return 9
6464
if ch == 0xF4:
6565
return 10

scintilla/scripts/GenerateCharacterCategory.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ def GetPreferredCharacterClass(values):
7979
# https://en.wikipedia.org/wiki/Private_Use_Areas
8080
# Category: Other, private use (Co)
8181
def isPrivateChar(c):
82-
return (c >= 0xE000 and c <= 0xF8FF) \
83-
or (c >= 0xF0000 and c <= 0xFFFFD) \
84-
or (c >= 0x100000 and c <= 0x10FFFD)
82+
return (0xE000 <= c <= 0xF8FF) \
83+
or (0xF0000 <= c <= 0xFFFFD) \
84+
or (0x100000 <= c <= 0x10FFFD)
8585

8686
# https://en.wikipedia.org/wiki/Unicode_block
8787
# https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane
@@ -157,7 +157,7 @@ def isCJKCharacter(category, ch):
157157
return False
158158

159159
for block in CJKBlockList:
160-
if ch >= block[0] and ch <= block[1]:
160+
if block[0] <= ch <= block[1]:
161161
return True
162162

163163
return False
@@ -490,18 +490,18 @@ def isReservedOrUDC_GBK(ch, buf):
490490
ch1 = buf[0]
491491
ch2 = buf[1]
492492
# user-defined 1 and 2
493-
if ((ch1 >= 0xAA and ch1 <= 0xAF) or (ch1 >= 0xF8 and ch1 <= 0xFE)) \
494-
and (ch2 >= 0xA1 and ch2 <= 0xFE):
493+
if ((0xAA <= ch1 <= 0xAF) or (0xF8 <= ch1 <= 0xFE)) \
494+
and (0xA1 <= ch2 <= 0xFE):
495495
return True
496496
# user-defined 3
497-
if (ch1 >= 0xA1 and ch1 <= 0xA7) and (ch2 >= 0x40 and ch2 <= 0xA0 and ch2 != 0x7F):
497+
if (0xA1 <= ch1 <= 0xA7) and ((0x40 <= ch2 <= 0xA0) and ch2 != 0x7F):
498498
return True
499499
return False
500500

501501
# https://en.wikipedia.org/wiki/Big5
502502
def isReservedOrUDC_Big5(ch, buf):
503503
for block in [(0x8140, 0xA0FE), (0xA3C0, 0xA3FE), (0xC6A1, 0xC8FE), (0xF9D6, 0xFEFE)]:
504-
if ch >= block[0] and ch <= block[1]:
504+
if block[0] <= ch <= block[1]:
505505
return True
506506
return False
507507

scintilla/scripts/HFacerCheck.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def checkLexerDefinition():
102102
lexer = prefixMap[prefix]
103103
valList = lexrList.setdefault(lexer, {})
104104
value = int(value)
105-
if value >= STYLE_FIRSTPREDEFINED and value <= STYLE_LASTPREDEFINED:
105+
if STYLE_FIRSTPREDEFINED <= value <= STYLE_LASTPREDEFINED:
106106
print(f'error value: {value} {name}')
107107
values = valList.setdefault(value, [])
108108
if values:

scintilla/scripts/HFacerLexer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def printLexHFile(f):
4141
if name.startswith("SCE_"):
4242
if autoValue == STYLE_FIRSTPREDEFINED:
4343
autoValue = STYLE_LASTPREDEFINED + 1
44-
if val >= STYLE_FIRSTPREDEFINED and val <= STYLE_LASTPREDEFINED:
44+
if STYLE_FIRSTPREDEFINED <= val <= STYLE_LASTPREDEFINED:
4545
raise ValueError(f"Invalid Style Value: {name} = {val}")
4646
out.append(f"#define {name} {value}")
4747
return out

scintilla/scripts/HeaderCheck.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def ExcludeName(name, excludes):
2525
return any(exclude in name for exclude in excludes)
2626

2727
def SortLike(incs, order):
28-
return sorted(incs, key = lambda i: order.index(i))
28+
return sorted(incs, key = order.index)
2929

3030
basePrefix = "//base:"
3131
sourcePrefix = "//source:"

scintilla/scripts/LaTeXInput.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
import os.path
32
import re
43
import string
@@ -159,12 +158,10 @@ def update_latex_input_data_hash(input_name, input_map, multiplier, hash_size):
159158
items = hash_map[hash_key]
160159
items.sort(key=lambda m: (m['magic'], m['hash_key']))
161160
collision = len(items)
162-
if collision > max_collision:
163-
max_collision = collision
161+
max_collision = max(max_collision, collision)
164162
counter = fast_counter(info['magic'] for info in items)
165163
comparison = max(counter.values())
166-
if comparison > max_comparison:
167-
max_comparison = comparison
164+
max_collision = max(max_comparison, comparison)
168165

169166
if BuildDataForLookupOnly:
170167
key_list = [info['sequence'][1:] for info in items]

scintilla/scripts/MultiStageTable.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,8 @@ def runBlockEncode(head, table, tableName=''):
540540
blockSize = 1 << shift
541541
print(f'{head} run block value bit: {totalBit} {valueBit}, length: {len(values)}, size: {minSize} {minSize/1024}, block: {len(blockList)} {blockSize}')
542542

543+
output = []
543544
if tableName and (len(table) & (blockSize - 1)) == 0:
544-
output = []
545545
mask = (1 << valueBit) - 1
546546
for value in values:
547547
index = value & mask
@@ -555,7 +555,7 @@ def runBlockEncode(head, table, tableName=''):
555555
output = []
556556
blockData = list(itertools.chain.from_iterable(blockList))
557557
_dumpRunBlock(output, tableName, values, blockData, valueBit, shift)
558-
return output
558+
return output
559559

560560
def skipBlockEncode(head, table, tableName=''):
561561
itemSize = getItemSize(table)
@@ -590,6 +590,7 @@ def skipBlockEncode(head, table, tableName=''):
590590
blockSize = 1 << shift
591591
print(f'{head} skip block lookup: {length} {length.bit_length()}, size: {minSize} {minSize/1024}, block: {len(blockList)} {blockSize} default: {defaultValue}')
592592

593+
output = []
593594
if tableName and defaultBlock and (len(table) & (blockSize - 1)) == 0:
594595
bitCount = (len(blockList) - 1).bit_length()
595596
offsetList = []
@@ -606,11 +607,10 @@ def skipBlockEncode(head, table, tableName=''):
606607
assert minSize == size, (minSize, size)
607608
assert output == table
608609

609-
output = []
610610
if defaultValue:
611611
output.append(f'constexpr {_sizeTypeMap[itemSize]} {tableName}DefaultValue = {defaultValue};')
612612
_dumpRunBlock(output, tableName, offsetList, blockData, bitCount, shift)
613-
return output
613+
return output
614614

615615
def _compressTableMergedEx(table, itemSize, level):
616616
minSize = sys.maxsize

tools/AccessKey.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def find_free_access_key(menu, path):
4343
print('Error:', line)
4444
continue
4545

46-
if end_cut > 0 and end_cut < end:
46+
if 0 < end_cut < end:
4747
end = end_cut
4848

4949
used = line.endswith('//#')

tools/KeywordCore.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def sub_extract(pattern, doc, flags=0):
184184
def extract(m):
185185
lines.append(m.group(0))
186186
return ''
187-
doc = re.sub(pattern, lambda m: extract(m), doc, flags=flags)
187+
doc = re.sub(pattern, extract, doc, flags=flags)
188188
return doc, '\n'.join(lines)
189189

190190
def split_api_section(doc, comment, commentKind=0):

tools/Misc.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
import os.path
32
import re
43
import json
@@ -33,7 +32,7 @@ def get_value():
3332

3433
def check_encoding_list(path):
3534
def is_tag_char(ch):
36-
return (ch >= 'a' and ch <= 'z') or (ch >= '0' and ch <= '9')
35+
return ('a' <= ch <= 'z') or ('0' <= ch <= '9')
3736

3837
with open(path, encoding='utf-8', newline='\n') as fd:
3938
doc = fd.read()

0 commit comments

Comments
 (0)