From bd09cc90b601c3bab01215c85165dbb219bb0467 Mon Sep 17 00:00:00 2001 From: wisp3rwind <17089248+wisp3rwind@users.noreply.github.com> Date: Tue, 14 Jun 2022 22:15:53 +0200 Subject: [PATCH] drop Python 3.6: docs, a few safe simplifications --- beets/autotag/hooks.py | 8 +------- beets/util/__init__.py | 8 ++------ beets/util/functemplate.py | 13 +------------ beetsplug/smartplaylist.py | 7 +------ docs/changelog.rst | 4 ++++ docs/guides/main.rst | 6 +++--- setup.py | 2 +- 7 files changed, 13 insertions(+), 35 deletions(-) diff --git a/beets/autotag/hooks.py b/beets/autotag/hooks.py index 30904ff29..8bd87d84a 100644 --- a/beets/autotag/hooks.py +++ b/beets/autotag/hooks.py @@ -28,12 +28,6 @@ from unidecode import unidecode log = logging.getLogger('beets') -# The name of the type for patterns in re changed in Python 3.7. -try: - Pattern = re._pattern_type -except AttributeError: - Pattern = re.Pattern - # Classes used to represent candidate options. class AttrDict(dict): @@ -449,7 +443,7 @@ class Distance: be a compiled regular expression, in which case it will be matched against `value2`. """ - if isinstance(value1, Pattern): + if isinstance(value1, re.Pattern): return bool(value1.match(value2)) return value1 == value2 diff --git a/beets/util/__init__.py b/beets/util/__init__.py index 06e02ee08..fa3b17537 100644 --- a/beets/util/__init__.py +++ b/beets/util/__init__.py @@ -868,10 +868,7 @@ def command_output(cmd, shell=False): """ cmd = convert_command_args(cmd) - try: # python >= 3.3 - devnull = subprocess.DEVNULL - except AttributeError: - devnull = open(os.devnull, 'r+b') + devnull = subprocess.DEVNULL proc = subprocess.Popen( cmd, @@ -1054,8 +1051,7 @@ def asciify_path(path, sep_replace): def par_map(transform, items): """Apply the function `transform` to all the elements in the iterable `items`, like `map(transform, items)` but with no return - value. The map *might* happen in parallel: it's parallel on Python 3 - and sequential on Python 2. + value. The parallelism uses threads (not processes), so this is only useful for IO-bound `transform`s. diff --git a/beets/util/functemplate.py b/beets/util/functemplate.py index 289a436de..809207b9a 100644 --- a/beets/util/functemplate.py +++ b/beets/util/functemplate.py @@ -530,18 +530,7 @@ def _parse(template): return Expression(parts) -def cached(func): - """Like the `functools.lru_cache` decorator, but works (as a no-op) - on Python < 3.2. - """ - if hasattr(functools, 'lru_cache'): - return functools.lru_cache(maxsize=128)(func) - else: - # Do nothing when lru_cache is not available. - return func - - -@cached +@functools.lru_cache(maxsize=128) def template(fmt): return Template(fmt) diff --git a/beetsplug/smartplaylist.py b/beetsplug/smartplaylist.py index 4c921eccc..22fce6a63 100644 --- a/beetsplug/smartplaylist.py +++ b/beetsplug/smartplaylist.py @@ -24,12 +24,7 @@ from beets.library import Item, Album, parse_query_string from beets.dbcore import OrQuery from beets.dbcore.query import MultipleSort, ParsingError import os - -try: - from urllib.request import pathname2url -except ImportError: - # python2 is a bit different - from urllib import pathname2url +from urllib.request import pathname2url class SmartPlaylistPlugin(BeetsPlugin): diff --git a/docs/changelog.rst b/docs/changelog.rst index c7f3eb614..f3adcddb4 100755 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -6,6 +6,9 @@ Changelog Changelog goes here! +With this release, beets now requires Python 3.7 or later (it removes support +for Python 3.6). + New features: * We now import the remixer field from Musicbrainz into the library. @@ -125,6 +128,7 @@ Bug fixes: For packagers: +* As noted above, the minimum Python version is now 3.7. * We fixed a version for the dependency on the `Confuse`_ library. :bug:`4167` * The minimum required version of :pypi:`mediafile` is now 0.9.0. diff --git a/docs/guides/main.rst b/docs/guides/main.rst index 2b573ac32..6169ded8c 100644 --- a/docs/guides/main.rst +++ b/docs/guides/main.rst @@ -10,7 +10,7 @@ Installing ---------- You will need Python. -Beets works on Python 3.6 or later. +Beets works on Python 3.7 or later. * **macOS** 11 (Big Sur) includes Python 3.8 out of the box. You can opt for a more recent Python installing it via `Homebrew`_ @@ -94,7 +94,7 @@ Installing on Windows Installing beets on Windows can be tricky. Following these steps might help you get it right: -1. If you don't have it, `install Python`_ (you want at least Python 3.6). The +1. If you don't have it, `install Python`_ (you want at least Python 3.7). The installer should give you the option to "add Python to PATH." Check this box. If you do that, you can skip the next step. @@ -105,7 +105,7 @@ get it right: should open the "System Properties" screen, then select the "Advanced" tab, then hit the "Environmental Variables..." button, and then look for the PATH variable in the table. Add the following to the end of the variable's value: - ``;C:\Python36;C:\Python36\Scripts``. You may need to adjust these paths to + ``;C:\Python37;C:\Python37\Scripts``. You may need to adjust these paths to point to your Python installation. 3. Now install beets by running: ``pip install beets`` diff --git a/setup.py b/setup.py index d49ed65b2..0e8162e4d 100755 --- a/setup.py +++ b/setup.py @@ -166,10 +166,10 @@ setup( 'Environment :: Web Environment', 'Programming Language :: Python', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: Implementation :: CPython', ], )