Tue, 18 Oct 2022 16:06:21 +0200
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
9214 | 1 | # -*- coding: utf-8 -*- |
2 | ||
3 | # Copyright (c) 2022 Detlev Offenbach <detlev@die-offenbachs.de> | |
4 | # | |
5 | ||
6 | """ | |
7 | Module implementing a dialog to enter the parameters for a Black formatting run. | |
8 | """ | |
9 | ||
10 | import contextlib | |
11 | import copy | |
12 | import pathlib | |
13 | ||
14 | import black | |
15 | import tomlkit | |
16 | ||
17 | from PyQt6.QtCore import pyqtSlot, Qt | |
18 | from PyQt6.QtGui import QFontMetricsF, QGuiApplication | |
19 | from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QListWidgetItem | |
20 | ||
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9343
diff
changeset
|
21 | from eric7.EricWidgets import EricMessageBox |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9343
diff
changeset
|
22 | from eric7.EricWidgets.EricApplication import ericApp |
9214 | 23 | |
24 | from .Ui_BlackConfigurationDialog import Ui_BlackConfigurationDialog | |
25 | ||
26 | from . import BlackUtilities | |
27 | ||
28 | ||
29 | class BlackConfigurationDialog(QDialog, Ui_BlackConfigurationDialog): | |
30 | """ | |
31 | Class implementing a dialog to enter the parameters for a Black formatting run. | |
32 | """ | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
33 | |
9337
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
34 | def __init__(self, withProject=True, onlyProject=False, parent=None): |
9214 | 35 | """ |
36 | Constructor | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
37 | |
9214 | 38 | @param withProject flag indicating to look for project configurations |
39 | (defaults to True) | |
9337
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
40 | @type bool (optional) |
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
41 | @param onlyProject flag indicating to only look for project configurations |
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
42 | (defaults to False) |
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
43 | @type bool (optional) |
9214 | 44 | @param parent reference to the parent widget (defaults to None) |
45 | @type QWidget (optional) | |
46 | """ | |
47 | super().__init__(parent) | |
48 | self.setupUi(self) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
49 | |
9337
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
50 | self.__project = ( |
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
51 | ericApp().getObject("Project") if (withProject or onlyProject) else None |
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
52 | ) |
9342
07a037ce923a
Optimized the 'Black' configuration dialog a little bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9341
diff
changeset
|
53 | self.__onlyProject = onlyProject |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
54 | |
9214 | 55 | indentTabWidth = ( |
56 | QFontMetricsF(self.excludeEdit.font()).horizontalAdvance(" ") * 2 | |
57 | ) | |
58 | self.excludeEdit.document().setIndentWidth(indentTabWidth) | |
59 | self.excludeEdit.setTabStopDistance(indentTabWidth) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
60 | |
9214 | 61 | self.__pyprojectData = {} |
62 | self.__projectData = {} | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
63 | |
9214 | 64 | self.__tomlButton = self.buttonBox.addButton( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
65 | self.tr("Generate TOML"), QDialogButtonBox.ButtonRole.ActionRole |
9214 | 66 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
67 | self.__tomlButton.setToolTip( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
68 | self.tr("Place a code snippet for 'pyproject.toml' into the clipboard.") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
69 | ) |
9214 | 70 | self.__tomlButton.clicked.connect(self.__createTomlSnippet) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
71 | |
9214 | 72 | # setup the source combobox |
73 | self.sourceComboBox.addItem("", "") | |
74 | if self.__project: | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
75 | pyprojectPath = ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
76 | pathlib.Path(self.__project.getProjectPath()) / "pyproject.toml" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
77 | ) |
9214 | 78 | if pyprojectPath.exists(): |
79 | with contextlib.suppress(tomlkit.exceptions.ParseError, OSError): | |
80 | with pyprojectPath.open("r", encoding="utf-8") as f: | |
81 | data = tomlkit.load(f) | |
82 | config = data.get("tool", {}).get("black", {}) | |
83 | if config: | |
84 | self.__pyprojectData = { | |
9222
e384c0e986be
Fixed a bug in the Black configuration dialog causing 'pyproject.toml' values being handled incorrectly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
85 | k.replace("--", ""): v for k, v in config.items() |
9214 | 86 | } |
87 | self.sourceComboBox.addItem("pyproject.toml", "pyproject") | |
88 | if self.__project.getData("OTHERTOOLSPARMS", "Black") is not None: | |
89 | self.__projectData = copy.deepcopy( | |
90 | self.__project.getData("OTHERTOOLSPARMS", "Black") | |
91 | ) | |
92 | self.sourceComboBox.addItem(self.tr("Project File"), "project") | |
9342
07a037ce923a
Optimized the 'Black' configuration dialog a little bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9341
diff
changeset
|
93 | elif onlyProject: |
07a037ce923a
Optimized the 'Black' configuration dialog a little bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9341
diff
changeset
|
94 | self.sourceComboBox.addItem(self.tr("Project File"), "project") |
9337
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
95 | if not onlyProject: |
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
96 | self.sourceComboBox.addItem(self.tr("Defaults"), "default") |
073b872fce59
Code Formatting
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9222
diff
changeset
|
97 | self.sourceComboBox.addItem(self.tr("Configuration Below"), "dialog") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
98 | |
9214 | 99 | self.__populateTargetVersionsList() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
100 | |
9214 | 101 | if self.__projectData: |
102 | source = self.__projectData.get("source", "") | |
103 | self.sourceComboBox.setCurrentIndex(self.sourceComboBox.findData(source)) | |
9342
07a037ce923a
Optimized the 'Black' configuration dialog a little bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9341
diff
changeset
|
104 | elif onlyProject: |
07a037ce923a
Optimized the 'Black' configuration dialog a little bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9341
diff
changeset
|
105 | self.sourceComboBox.setCurrentIndex(self.sourceComboBox.findData("project")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
106 | |
9214 | 107 | def __populateTargetVersionsList(self): |
108 | """ | |
109 | Private method to populate the target versions list widget with checkable | |
110 | Python version entries. | |
111 | """ | |
112 | targets = [ | |
113 | (int(t[2]), int(t[3:]), t) | |
114 | for t in dir(black.TargetVersion) | |
115 | if t.startswith("PY") | |
116 | ] | |
9341
3dc887a49403
Improved the display of the 'Target Versions' list of the 'Black' configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9337
diff
changeset
|
117 | for target in sorted(targets, reverse=True): |
9214 | 118 | itm = QListWidgetItem( |
119 | "Python {0}.{1}".format(target[0], target[1]), self.targetVersionsList | |
120 | ) | |
121 | itm.setData(Qt.ItemDataRole.UserRole, target[2]) | |
122 | itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable) | |
123 | itm.setCheckState(Qt.CheckState.Unchecked) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
124 | |
9214 | 125 | def __loadConfiguration(self, configurationDict): |
126 | """ | |
127 | Private method to load the configuration section with data of the given | |
128 | dictionary. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
129 | |
9214 | 130 | @param configurationDict reference to the data to be loaded |
131 | @type dict | |
132 | """ | |
133 | confDict = copy.deepcopy(BlackUtilities.getDefaultConfiguration()) | |
134 | confDict.update(configurationDict) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
135 | |
9214 | 136 | self.lineLengthSpinBox.setValue(int(confDict["line-length"])) |
137 | self.skipStringNormalCheckBox.setChecked(confDict["skip-string-normalization"]) | |
138 | self.skipMagicCommaCheckBox.setChecked(confDict["skip-magic-trailing-comma"]) | |
139 | self.excludeEdit.setPlainText(confDict["extend-exclude"]) | |
140 | for row in range(self.targetVersionsList.count()): | |
141 | itm = self.targetVersionsList.item(row) | |
142 | itm.setCheckState( | |
143 | Qt.CheckState.Checked | |
144 | if itm.data(Qt.ItemDataRole.UserRole).lower() | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
145 | in confDict["target-version"] |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
146 | else Qt.CheckState.Unchecked |
9214 | 147 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
148 | |
9214 | 149 | @pyqtSlot(str) |
150 | def on_sourceComboBox_currentTextChanged(self, selection): | |
151 | """ | |
152 | Private slot to handle the selection of a configuration source. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
153 | |
9214 | 154 | @param selection text of the currently selected item |
155 | @type str | |
156 | """ | |
157 | self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( | |
9342
07a037ce923a
Optimized the 'Black' configuration dialog a little bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9341
diff
changeset
|
158 | bool(selection) or self.__onlyProject |
9214 | 159 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
160 | |
9214 | 161 | source = self.sourceComboBox.currentData() |
162 | if source == "pyproject": | |
163 | self.__loadConfiguration(self.__pyprojectData) | |
164 | elif source == "project": | |
165 | self.__loadConfiguration(self.__projectData) | |
166 | elif source == "default": | |
167 | self.__loadConfiguration(BlackUtilities.getDefaultConfiguration()) | |
168 | elif source == "dialog": | |
169 | # just leave the current entries | |
170 | pass | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
171 | |
9214 | 172 | @pyqtSlot() |
173 | def on_excludeEdit_textChanged(self): | |
174 | """ | |
175 | Private slot to enable the validate button depending on the exclude text. | |
176 | """ | |
177 | self.validateButton.setEnabled(bool(self.excludeEdit.toPlainText())) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
178 | |
9214 | 179 | @pyqtSlot() |
180 | def on_validateButton_clicked(self): | |
181 | """ | |
182 | Private slot to validate the entered exclusion regular expression. | |
183 | """ | |
184 | regexp = self.excludeEdit.toPlainText() | |
185 | valid, error = BlackUtilities.validateRegExp(regexp) | |
186 | if valid: | |
187 | EricMessageBox.information( | |
188 | self, | |
189 | self.tr("Validation"), | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
190 | self.tr("""The exclusion expression is valid."""), |
9214 | 191 | ) |
192 | else: | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
193 | EricMessageBox.critical(self, self.tr("Validation Error"), error) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
194 | |
9214 | 195 | def __getTargetList(self): |
196 | """ | |
197 | Private method to get the list of checked target versions. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
198 | |
9214 | 199 | @return list of target versions |
200 | @rtype list of str | |
201 | """ | |
202 | targets = [] | |
203 | for row in range(self.targetVersionsList.count()): | |
204 | itm = self.targetVersionsList.item(row) | |
205 | if itm.checkState() == Qt.CheckState.Checked: | |
206 | targets.append(itm.data(Qt.ItemDataRole.UserRole).lower()) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
207 | |
9214 | 208 | return targets |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
209 | |
9214 | 210 | @pyqtSlot() |
211 | def __createTomlSnippet(self): | |
212 | """ | |
213 | Private slot to generate a TOML snippet of the current configuration. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
214 | |
9214 | 215 | Note: Only non-default values are included in this snippet. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
216 | |
9214 | 217 | The code snippet is copied to the clipboard and may be placed inside the |
218 | 'pyproject.toml' file. | |
219 | """ | |
220 | doc = tomlkit.document() | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
221 | |
9214 | 222 | black = tomlkit.table() |
223 | targetList = self.__getTargetList() | |
224 | if targetList: | |
225 | black["target-version"] = targetList | |
226 | black["line-length"] = self.lineLengthSpinBox.value() | |
227 | if self.skipStringNormalCheckBox.isChecked(): | |
228 | black["skip-string-normalization"] = True | |
229 | if self.skipMagicCommaCheckBox.isChecked(): | |
230 | black["skip-magic-trailing-comma"] = True | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
231 | |
9214 | 232 | excludeRegexp = self.excludeEdit.toPlainText() |
233 | if excludeRegexp and BlackUtilities.validateRegExp(excludeRegexp)[0]: | |
234 | black["extend-exclude"] = tomlkit.string( | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
235 | "\n{0}\n".format(excludeRegexp.strip()), literal=True, multiline=True |
9214 | 236 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
237 | |
9214 | 238 | doc["tool"] = tomlkit.table(is_super_table=True) |
239 | doc["tool"]["black"] = black | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
240 | |
9214 | 241 | QGuiApplication.clipboard().setText(tomlkit.dumps(doc)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
242 | |
9214 | 243 | EricMessageBox.information( |
244 | self, | |
9216
e89083501ce3
Updated translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9214
diff
changeset
|
245 | self.tr("Create TOML snippet"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
246 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
247 | """The 'pyproject.toml' snippet was copied to the clipboard""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
248 | """ successfully.""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
249 | ), |
9214 | 250 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
251 | |
9343
7180fb8677e5
Corrected another oversight in the 'Black' configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9342
diff
changeset
|
252 | def getConfiguration(self, saveToProject=False): |
9214 | 253 | """ |
254 | Public method to get the current configuration parameters. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
255 | |
9343
7180fb8677e5
Corrected another oversight in the 'Black' configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9342
diff
changeset
|
256 | @param saveToProject flag indicating to save the configuration data in the |
7180fb8677e5
Corrected another oversight in the 'Black' configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9342
diff
changeset
|
257 | project file (defaults to False) |
7180fb8677e5
Corrected another oversight in the 'Black' configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9342
diff
changeset
|
258 | @type bool (optional) |
9214 | 259 | @return dictionary containing the configuration parameters |
260 | @rtype dict | |
261 | """ | |
262 | configuration = BlackUtilities.getDefaultConfiguration() | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
263 | |
9214 | 264 | configuration["source"] = self.sourceComboBox.currentData() |
265 | configuration["target-version"] = self.__getTargetList() | |
266 | configuration["line-length"] = self.lineLengthSpinBox.value() | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
267 | configuration[ |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
268 | "skip-string-normalization" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
269 | ] = self.skipStringNormalCheckBox.isChecked() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
270 | configuration[ |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
271 | "skip-magic-trailing-comma" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
272 | ] = self.skipMagicCommaCheckBox.isChecked() |
9214 | 273 | configuration["extend-exclude"] = self.excludeEdit.toPlainText().strip() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
274 | |
9343
7180fb8677e5
Corrected another oversight in the 'Black' configuration dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9342
diff
changeset
|
275 | if saveToProject and self.__project: |
9214 | 276 | self.__project.setData("OTHERTOOLSPARMS", "Black", configuration) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9216
diff
changeset
|
277 | |
9214 | 278 | return configuration |