borg icon indicating copy to clipboard operation
borg copied to clipboard

use more py38 features

Open ThomasWaldmann opened this issue 4 years ago • 3 comments

master branch requires py39+. 1.4-maint branch requires py39+. 1.2-maint branch requires py38+. 1.1-maint won't see any changes.

python 3.6 - https://docs.python.org/3/whatsnew/3.6.html

especially:

  • [X] #5634
  • [X] f-strings: https://docs.python.org/3/whatsnew/3.6.html#whatsnew36-pep498
  • [ ] secrets module: https://docs.python.org/3/whatsnew/3.6.html#whatsnew36-pep506 - we could use that instead of os.urandom at some places. maybe have a better readable random_bytes alias for the secrets.token_bytes function?
  • scrypt maybe, additionally to the currently used pbkdf2? see #747.
  • [x] https://docs.python.org/3/whatsnew/3.6.html#datetime - see the comment in borg.constants about isoformat() being evil - that's not the case any more with timespec != 'auto'!
  • https://docs.python.org/3/whatsnew/3.6.html#enum
  • https://docs.python.org/3/whatsnew/3.6.html#time
  • [ ] try https://docs.python.org/3/whatsnew/3.6.html#pythonmalloc-environment-variable - anything unusual/unexpected?
  • [ ] try https://docs.python.org/3/whatsnew/3.6.html#tracemalloc - anything unusual/unexpected?

python 3.7 - https://docs.python.org/3/whatsnew/3.7.html

  • [ ] data classes: https://docs.python.org/3/whatsnew/3.7.html#dataclasses (but also check hynek's attrs)
  • [x] https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat - see borg.helpers.time.parse_timestamp- needs more testing
  • [X] https://docs.python.org/3/library/hmac.html#hmac.digest - see #6408
  • [X] https://docs.python.org/3/library/os.html#os.scandir can use a FD now - we already use that, we could just remove the py_37_plus check.

python 3.8 - https://docs.python.org/3/whatsnew/3.8.html

  • https://docs.python.org/3/whatsnew/3.8.html#assignment-expressions
  • https://docs.python.org/3/whatsnew/3.8.html#f-strings-support-for-self-documenting-expressions-and-debugging
  • https://docs.python.org/3/whatsnew/3.8.html#tarfile pax by default

ThomasWaldmann avatar Jan 18 '21 19:01 ThomasWaldmann

Consider pyupgrade as helper

RonnyPfannschmidt avatar Jan 18 '21 20:01 RonnyPfannschmidt

https://pypi.org/project/pyupgrade/

# zsh
pyupgrade --py38-plus ./**/*.py

ThomasWaldmann avatar Jan 18 '21 20:01 ThomasWaldmann

https://github.com/borgbackup/borg/pull/6382 < pyupgrade run.

ThomasWaldmann avatar Apr 02 '23 00:04 ThomasWaldmann