12 import multiprocessing |
12 import multiprocessing |
13 import pathlib |
13 import pathlib |
14 |
14 |
15 from dataclasses import dataclass |
15 from dataclasses import dataclass |
16 |
16 |
17 from isort.settings import Config |
17 from isort import settings |
18 from isort.api import check_file, sort_file |
18 from isort.api import check_file, sort_file |
19 |
19 |
20 from PyQt6.QtCore import pyqtSlot, Qt, QCoreApplication |
20 from PyQt6.QtCore import pyqtSlot, Qt, QCoreApplication |
21 from PyQt6.QtWidgets import ( |
21 from PyQt6.QtWidgets import ( |
22 QAbstractButton, |
22 QAbstractButton, |
90 # Create an isort Config object and pre-load it with parameters contained in |
90 # Create an isort Config object and pre-load it with parameters contained in |
91 # project specific configuration files (like pyproject.toml). The configuration |
91 # project specific configuration files (like pyproject.toml). The configuration |
92 # given as a dictionary (i.e. data entered in the configuration dialog) |
92 # given as a dictionary (i.e. data entered in the configuration dialog) |
93 # overwrites these. If the project is not passed, the isort config is based on |
93 # overwrites these. If the project is not passed, the isort config is based on |
94 # the isort defaults. |
94 # the isort defaults. |
95 self.__isortConfig = ( |
95 if project: |
96 Config(settings_path=project.getProjectPath(), **self.__config) |
96 # clear the caches in order to force a re-read of config files |
97 if project |
97 settings._get_config_data.cache_clear() |
98 else Config(**self.__config) |
98 settings._find_config.cache_clear() |
99 ) |
99 try: |
|
100 self.__isortConfig = ( |
|
101 settings.Config(settings_path=project.getProjectPath(), **self.__config) |
|
102 if project |
|
103 else settings.Config(**self.__config) |
|
104 ) |
|
105 except KeyError: |
|
106 # invalid configuration entry found in some config file; use just the dialog |
|
107 # parameters |
|
108 self.__isortConfig = settings.Config(**self.__config) |
100 |
109 |
101 self.__config["__action__"] = action # needed by the workers |
110 self.__config["__action__"] = action # needed by the workers |
102 |
111 |
103 self.__filesList = filesList[:] |
112 self.__filesList = filesList[:] |
104 |
113 |