Check Python version instead of catching ImportError

This commit is contained in:
Arkadiy Illarionov 2024-06-22 19:55:52 +03:00
parent 89f1bda4e0
commit 1c020b8264
2 changed files with 6 additions and 6 deletions

View file

@ -45,11 +45,11 @@ from typing import (
Union,
)
try:
# Python 3.10+
if sys.version_info >= (3, 10):
from typing import TypeAlias
except ImportError:
else:
from typing_extensions import TypeAlias
from unidecode import unidecode
from beets.util import hidden

View file

@ -17,6 +17,7 @@
import os
import re
import sys
from dataclasses import dataclass
from mimetypes import guess_type
from typing import ClassVar, Mapping, Type
@ -30,10 +31,9 @@ from flask import (
send_file,
)
try:
# Python 3.11+
if sys.version_info >= (3, 11):
from typing import Self
except ImportError:
else:
from typing_extensions import Self
from beets import config