mirror of
https://github.com/fergalmoran/picard.git
synced 2026-03-24 22:25:13 +00:00
Upgrade to isort 5 (#2164)
* Upgrade to isort 5 isort 5 now can also handle imports not at top, hence some new locations now get sorted automatically. * Move isort config from .isort.cfg to pyproject.toml * isort: remove exclusion of some source files isort now only ignores auto-generated files. The other files had been excluded because old isort could not handle imports not placed on the top. * isort: use skip_glob to ignore resources.py This should fix issues with the `skip` parameter on Windows.
This commit is contained in:
2
.github/workflows/run-tests.yml
vendored
2
.github/workflows/run-tests.yml
vendored
@@ -28,7 +28,7 @@ jobs:
|
||||
pip install -r requirements.txt
|
||||
- name: Check coding style
|
||||
run: |
|
||||
pip install flake8 "isort<5"
|
||||
pip install flake8 "isort>=5"
|
||||
flake8 picard test --count --show-source --statistics
|
||||
isort --check-only --diff --recursive picard test
|
||||
- name: Test with pytest
|
||||
|
||||
28
.isort.cfg
28
.isort.cfg
@@ -1,28 +0,0 @@
|
||||
# Configuration for isort tool
|
||||
# https://github.com/timothycrosley/isort
|
||||
#
|
||||
# Possible settings are listed at https://github.com/timothycrosley/isort/wiki/isort-Settings
|
||||
#
|
||||
# It can easily be installed using `pip install isort`
|
||||
#
|
||||
[settings]
|
||||
combine_as_imports=True
|
||||
default_section=LOCALFOLDER
|
||||
force_grid_wrap=True
|
||||
force_sort_within_sections=True
|
||||
include_trailing_comma=True
|
||||
indent=' '
|
||||
known_picard=picard
|
||||
known_picard_ui=picard.ui
|
||||
known_qt=PyQt5
|
||||
known_resources=picard.resources
|
||||
known_test=test.*
|
||||
known_third_party=mutagen
|
||||
multi_line_output=3
|
||||
order_by_type=True
|
||||
sections=FUTURE,STDLIB,THIRDPARTY,QT,TEST,PICARD,LOCALFOLDER,RESOURCES,PICARD_UI
|
||||
skip_glob=**/ui_*.py
|
||||
skip=./tagger.py,picard/resources.py,scripts/picard.in,picard/const/__init__.py
|
||||
not_skip=__init__.py
|
||||
use_parentheses=1
|
||||
lines_after_imports=2
|
||||
@@ -102,8 +102,15 @@ def crash_handler():
|
||||
|
||||
# Display the crash information to the user as a dialog. This requires
|
||||
# importing Qt5 and has some potential to fail if things are broken.
|
||||
from PyQt5.QtCore import QCoreApplication, Qt, QUrl
|
||||
from PyQt5.QtWidgets import QApplication, QMessageBox
|
||||
from PyQt5.QtCore import (
|
||||
QCoreApplication,
|
||||
Qt,
|
||||
QUrl,
|
||||
)
|
||||
from PyQt5.QtWidgets import (
|
||||
QApplication,
|
||||
QMessageBox,
|
||||
)
|
||||
app = QCoreApplication.instance()
|
||||
if not app:
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
@@ -36,8 +36,9 @@ import builtins
|
||||
from collections import OrderedDict
|
||||
|
||||
from picard import PICARD_VERSION
|
||||
from picard.const.attributes import MB_ATTRIBUTES
|
||||
from picard.const import appdirs
|
||||
from picard.const.attributes import MB_ATTRIBUTES
|
||||
|
||||
|
||||
# Install gettext "noop" function in case const.py gets imported directly.
|
||||
builtins.__dict__['N_'] = lambda a: a
|
||||
@@ -112,17 +113,23 @@ for k, v in MB_ATTRIBUTES.items():
|
||||
elif k.startswith('DB:release_status/name:'):
|
||||
RELEASE_STATUS[v] = v
|
||||
|
||||
# List of available charsets
|
||||
from picard.const.scripts import SCRIPTS # noqa: F401,E402 # pylint: disable=unused-import
|
||||
|
||||
# Release countries
|
||||
from picard.const.countries import RELEASE_COUNTRIES # noqa: F401,E402 # pylint: disable=unused-import
|
||||
|
||||
from picard.const.countries import ( # noqa: F401,E402 # pylint: disable=unused-import
|
||||
RELEASE_COUNTRIES,
|
||||
)
|
||||
# List of available user interface languages
|
||||
from picard.const.languages import UI_LANGUAGES # noqa: F401,E402 # pylint: disable=unused-import
|
||||
|
||||
from picard.const.languages import ( # noqa: F401,E402 # pylint: disable=unused-import
|
||||
UI_LANGUAGES,
|
||||
)
|
||||
# List of alias locales
|
||||
from picard.const.locales import ALIAS_LOCALES # noqa: F401,E402 # pylint: disable=unused-import
|
||||
from picard.const.locales import ( # noqa: F401,E402 # pylint: disable=unused-import
|
||||
ALIAS_LOCALES,
|
||||
)
|
||||
# List of available charsets
|
||||
from picard.const.scripts import ( # noqa: F401,E402 # pylint: disable=unused-import
|
||||
SCRIPTS,
|
||||
)
|
||||
|
||||
|
||||
# List of official musicbrainz servers - must support SSL for mblogin requests (such as collections).
|
||||
MUSICBRAINZ_SERVERS = [
|
||||
|
||||
@@ -34,11 +34,11 @@ __all__ = ["TAK", "Open", "delete"]
|
||||
|
||||
try:
|
||||
from mutagen.tak import (
|
||||
Open,
|
||||
TAK,
|
||||
Open,
|
||||
TAKHeaderError,
|
||||
TAKInfo,
|
||||
delete
|
||||
delete,
|
||||
)
|
||||
|
||||
native_tak = True
|
||||
|
||||
@@ -36,10 +36,10 @@ from picard.metadata import Metadata
|
||||
|
||||
|
||||
try:
|
||||
import mutagen.wave
|
||||
from mutagen._iff import assert_valid_chunk_id
|
||||
from mutagen._riff import RiffFile
|
||||
from mutagen._util import loadfile
|
||||
import mutagen.wave
|
||||
|
||||
# See https://exiftool.org/TagNames/RIFF.html
|
||||
TRANSLATE_RIFF_INFO = {
|
||||
|
||||
@@ -55,8 +55,8 @@ from picard.util import (
|
||||
win32api = None
|
||||
if IS_WIN:
|
||||
try:
|
||||
import win32api # isort:skip
|
||||
import pywintypes
|
||||
import win32api
|
||||
except ImportError as e:
|
||||
log.warning('pywin32 not available: %s', e)
|
||||
|
||||
|
||||
@@ -165,6 +165,7 @@ def _update_state(obj, state):
|
||||
# TODO: use functools.singledispatch when py3 is supported
|
||||
def _get_state(obj):
|
||||
from picard.album import Album
|
||||
|
||||
from picard.ui.item import FileListItem
|
||||
|
||||
state = ImageListState()
|
||||
|
||||
@@ -48,9 +48,9 @@ from picard.util import sanitize_filename
|
||||
|
||||
|
||||
if IS_WIN:
|
||||
import win32pipe # type: ignore
|
||||
import win32file # type: ignore
|
||||
from pywintypes import error as WinApiError # type: ignore
|
||||
import win32file # type: ignore
|
||||
import win32pipe # type: ignore
|
||||
|
||||
|
||||
class PipeError(Exception):
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=62.4.0"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.isort]
|
||||
sections = [
|
||||
"FUTURE", "STDLIB", "THIRDPARTY", "QT", "TEST", "PICARD", "LOCALFOLDER",
|
||||
"RESOURCES", "PICARD_UI"
|
||||
]
|
||||
default_section = "LOCALFOLDER"
|
||||
known_picard = ["picard"]
|
||||
known_picard_ui = ["picard.ui"]
|
||||
known_qt = ["PyQt5"]
|
||||
known_resources = ["picard.resources"]
|
||||
known_test = ["test.*"]
|
||||
known_third_party = ["dateutil", "fasteners", "mutagen", "yaml"]
|
||||
skip_glob = ["**/ui_*.py", "picard/resources.py"]
|
||||
combine_as_imports = true
|
||||
float_to_top = false
|
||||
force_grid_wrap = 2
|
||||
force_sort_within_sections = true
|
||||
include_trailing_comma = true
|
||||
indent = " "
|
||||
lines_after_imports = 2
|
||||
multi_line_output = 3
|
||||
order_by_type = true
|
||||
use_parentheses = true
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
autopep8
|
||||
Babel>=2.6.0
|
||||
flake8
|
||||
isort>=4.3.10,<5
|
||||
isort>=5.0
|
||||
pycodestyle
|
||||
pylint>=2.6.0
|
||||
transifex-client
|
||||
|
||||
Reference in New Issue
Block a user