Start removing pre-Python 3.8 code#214
Conversation
3b1f85e to
a8a370b
Compare
|
|
e6b6b6d to
3e63ada
Compare
|
Actually, I don't mind looking at this as one big PR. But #124 should go in first. |
|
#124 is in. Want to take off the "Draft" status? |
src/cffi/api.py
Outdated
| @@ -7,7 +7,7 @@ | |||
| callable | |||
| except NameError: | |||
| # Python 3.1 | |||
There was a problem hiding this comment.
| # Python 3.1 |
src/cffi/recompiler.py
Outdated
| if isinstance(s, unicode): | ||
| s = s.encode('ascii') | ||
| super(NativeIO, self).write(s) | ||
| NativeIO = io.StringIO |
There was a problem hiding this comment.
Could probably refactor out NativeIO
src/cffi/vengine_gen.py
Outdated
| prefix = 'PyInit_' | ||
| modname = self.verifier.get_module_name() | ||
| prnt("void %s%s(void) { }\n" % (prefix, modname)) |
There was a problem hiding this comment.
What about
| prefix = 'PyInit_' | |
| modname = self.verifier.get_module_name() | |
| prnt("void %s%s(void) { }\n" % (prefix, modname)) | |
| modname = self.verifier.get_module_name() | |
| prnt(f"void PyInit_{modname}(void) {{ }}\n") |
mattip
left a comment
There was a problem hiding this comment.
There is a lot here, and probably a lot more to do. It is fine to do this in a couple of PRs though, we don't have to get it all in one PR.
|
Yes, I'm mostly applying pyupgrade and refurb ruff rules, to handle everything that can be fixed or at least detected automatically. I was thinking of starting a manual pass once this PR is in. But sure, I can apply the above suggestions. Still haven't applied UP030, UP031, UP032. I suggest a dedicated PR for these rules. |
3e63ada to
1f61c83
Compare
2bc183e to
d396812
Compare
d396812 to
d499d89
Compare
UP004 Class inherits from `object`
UP008 Use `super()` instead of `super(__class__, self)`
UP009 UTF-8 encoding declaration is unnecessary
UP010 Unnecessary `__future__` import for target Python version Manually removed comments about Unicode literals.
In Python 3, `io.open` is an alias for `open`. This is a manual change, not detected by ruff.
UP024 Replace aliased errors with `OSError`
UP025 Remove unicode literals from strings
UP028 Replace `yield` over `for` loop with `yield from`
UP035 Import from `collections.abc` instead: `Callable` Co-authored-by: Matti Picus <matti.picus@gmail.com>
FURB129 Instead of calling `readlines()`, iterate over file object directly
FURB188 Prefer `str.removeprefix()` over conditionally replacing with slice.
E703 Statement ends with an unnecessary semicolon
E711 Comparison to `None` should be `cond is not None`
E713 Test for membership should be `not in`
d499d89 to
fc735bf
Compare
|
Rebased and deferred UP036 to a PR of its own. |
|
Thanks @DimitriPapadopoulos |
Companion to #124.
Mostly applied ruff pyupgrade (UP) rules, and some pycodestyle (E) and refurb (FURB) rules.
Edit: I have left out some pyupgrade (UP) rules: