[go: up one dir, main page]

Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

drop python<=3.7 support #1587

wants to merge 3 commits into from

Conversation

kloczek
Copy link
@kloczek kloczek commented Jun 12, 2024

According to https://endoflife.date/python python 3.7 has been EOSed 27 Jun 2023.
Filter all code over pyupgracde --py38-plus.

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>
@egli egli added this to the 3.31 milestone Jun 13, 2024
@egli egli added python An issue concerning the Python bindings cleanup Cleanup (possibly removing features) to make the code more maintainable labels Jun 13, 2024
Copy link
Member
@LeonarddeR LeonarddeR left a 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 ""))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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))
Copy link
Member

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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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))
Copy link
Member

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))
Copy link
Member

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))
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem as above

@egli egli added the needs news Update to NEWS file needed label Aug 19, 2024
@egli
Copy link
Member
egli commented Aug 19, 2024

@LeonarddeR what do you think? Why do we have to drop the backwards compatibility?

@LeonarddeR
Copy link
Member

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.

@bertfrees
Copy link
Member

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).

@egli
Copy link
Member
egli commented Aug 20, 2024

OK, then we can just drop the python_requires=">=3.8" part.

Do the other changes make sense (or even work) if you have python 3.7?

@egli
Copy link
Member
egli commented Aug 30, 2024

Do the other changes make sense (or even work) if you have python 3.7?

@LeonarddeR any idea?

@egli egli removed this from the 3.31 milestone Aug 30, 2024
@LeonarddeR
Copy link
Member

As far as I can see, all the changes proposed in here do work with python 3.7.

@egli
Copy link
Member
egli commented Aug 30, 2024

As far as I can see, all the changes proposed in here do work with python 3.7.

OK, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Cleanup (possibly removing features) to make the code more maintainable needs news Update to NEWS file needed python An issue concerning the Python bindings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants