-
-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drop python<=3.7 support #1587
base: master
Are you sure you want to change the base?
drop python<=3.7 support #1587
Conversation
According to https://endoflife.date/python python 3.7 has been EOSed 27 Jun 2023. Filter all code over `pyupgracde --py38-plus`. Signed-off-by: Tomasz Kłoczko <kloczek@github.com>
Signed-off-by: Tomasz Kłoczko <kloczek@github.com>
Mostly removes unused imports Signed-off-by: Tomasz Kłoczko <kloczek@github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please ensure that f-strings are used where appropriate?
@@ -25,7 +25,7 @@ def update_counters(total, init=False): | |||
if not init: | |||
sys.stderr.write("\033[1A\033[K") | |||
sys.stderr.write("\033[1A\033[K") | |||
sys.stderr.write(("%d words processed\n" % total)) | |||
sys.stderr.write("%d words processed\n" % total) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sys.stderr.write("%d words processed\n" % total) | |
sys.stderr.write(f"{total} words processed\n") |
@@ -79,7 +79,7 @@ def main(): | |||
for rule in suggest_rules: | |||
println("%(opcode)s\t%(text)s\t%(braille)s" % rule) | |||
else: | |||
println("# >>>\t%s\t%s" % (text, braille or "")) | |||
println("# >>>\t{}\t{}".format(text, braille or "")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
println("# >>>\t{}\t{}".format(text, braille or "")) | |
println(f"# >>>\t{text}\t{braille or ""}") |
@@ -34,18 +34,18 @@ def __next__(self): | |||
if not row or row[0].startswith("#"): | |||
return next(self) | |||
if not len(row) == 3: | |||
printerrln('expected 3 columns, got %s: %s' % (len(row),row)) | |||
printerrln('expected 3 columns, got {}: {}'.format(len(row),row)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printerrln('expected 3 columns, got {}: {}'.format(len(row),row)) | |
```suggestion | |
printerrln(f'expected 3 columns, got {len(row)}: {row}') |
exit(1) | ||
maybe_chunked_text, braille = row[1:3] | ||
maybe_chunked_text = to_lowercase(maybe_chunked_text) | ||
text, chunked_text = read_text(maybe_chunked_text) | ||
braille = braille if braille != "" else None | ||
if braille != None: | ||
if '0' in to_dot_pattern(braille).split('-'): | ||
printerrln('invalid braille: %s' % (braille,)) | ||
printerrln('invalid braille: {}'.format(braille)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printerrln(f'invalid braille: {braille}')
@@ -45,7 +45,7 @@ def main(): | |||
for line in fileinput.FileInput(args.FILE, openhook=fileinput.hook_encoded("utf-8")): | |||
m = p.match(line) | |||
if not m: | |||
printerrln("%s: rule is not valid" % (line,)) | |||
printerrln("{}: rule is not valid".format(line)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printerrln("{}: rule is not valid".format(line)) | |
printerrln(f"{line}: rule is not valid") |
@@ -62,16 +62,16 @@ def main(): | |||
rule = list(rule) | |||
if add_or_delete == '-': | |||
if not rule: | |||
printerrln("%s%s %s %s: rule can not be deleted because not in %s" % (nocross,opcode,text,braille,args.CONTRACTION_TABLE)) | |||
printerrln("{}{} {} {}: rule can not be deleted because not in {}".format(nocross,opcode,text,braille,args.CONTRACTION_TABLE)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use f-string formatting
exit(1) | ||
else: | ||
if rule: | ||
printerrln("%s%s %s %s: rule can not be added because already in %s" % (nocross,opcode,text,braille,args.CONTRACTION_TABLE)) | ||
printerrln("{}{} {} {}: rule can not be added because already in {}".format(nocross,opcode,text,braille,args.CONTRACTION_TABLE)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use an f-string
exit(1) | ||
rule = {"opcode": opcode, "nocross": nocross, "text": text, "braille": braille, "comment": comment} | ||
rules.append(rule) | ||
opcode_order = {"word": 1, "always": 2, "begword": 3, "endword": 4, "midword": 5, "begmidword": 6, "midendword": 7, "prfword": 8, "sufword": 9} | ||
for rule in sorted(rules, key=lambda rule: (rule["text"], rule["nocross"], opcode_order[rule["opcode"]])): | ||
println(u"{nocross:<9}{opcode:<10} {text:<10} {braille:<30} {comment}".format(**rule)) | ||
println("{nocross:<9}{opcode:<10} {text:<10} {braille:<30} {comment}".format(**rule)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use an f-string
@@ -39,10 +39,10 @@ def exit_if_not(expression): | |||
liblouis.toLowercase.restype = c_wchar | |||
|
|||
def println(line=""): | |||
sys.stdout.write(("%s\n" % line)) | |||
sys.stdout.write("%s\n" % line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use an f-string
|
||
def printerrln(line=""): | ||
sys.stderr.write(("%s\n" % line)) | ||
sys.stderr.write("%s\n" % line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem as above
@LeonarddeR what do you think? Why do we have to drop the backwards compatibility? |
It is not strictly necessary to do so, but Python <3.7 is out of support so it doesn't make much sense to keep it. On the other hand, if it works, don't break it. |
I'm also for that principle. You never know who is using Liblouis and how (and for what reason they might be stuck with an old Python). |
OK, then we can just drop the Do the other changes make sense (or even work) if you have python 3.7? |
@LeonarddeR any idea? |
As far as I can see, all the changes proposed in here do work with python 3.7. |
OK, thanks |
According to https://endoflife.date/python python 3.7 has been EOSed 27 Jun 2023.
Filter all code over
pyupgracde --py38-plus
.