Skip to content

Commit b12908f

Browse files
Fix Formatting Errors
1 parent d26e773 commit b12908f

File tree

1 file changed

+22
-32
lines changed

1 file changed

+22
-32
lines changed

pandas/_config/config.py

+22-32
Original file line numberDiff line numberDiff line change
@@ -203,22 +203,19 @@ def set_option(*args) -> None:
203203
Parameters
204204
----------
205205
*args : str | object | dict
206-
Options can be provided in one of two forms:
207-
208-
1. As pairs of arguments, where each pair is interpreted as (pattern, value):
209-
- pattern: str
210-
Regexp which should match a single option.
211-
- value: object
212-
New value of option.
213-
214-
2. As a single dictionary, where each key is a pattern and the corresponding
215-
value is the new option value.
206+
Arguments provided in pairs, which will be interpreted as (pattern, value)
207+
pairs and in a single dictionary, where each key is a pattern and the
208+
corresponding value is the new option value.
209+
pattern: str
210+
Regexp which should match a single option
211+
value: object
212+
New value of option
216213
217214
.. warning::
218215
219216
Partial pattern matches are supported for convenience, but unless you
220-
use the full option name (e.g. ``x.y.z.option_name``), your code may break
221-
in future versions if new options with similar names are introduced.
217+
use the full option name (e.g. x.y.z.option_name), your code may break in
218+
future versions if new options with similar names are introduced.
222219
223220
Returns
224221
-------
@@ -227,19 +224,17 @@ def set_option(*args) -> None:
227224
228225
Raises
229226
------
230-
ValueError
231-
If an odd number of non-keyword arguments is provided.
232-
TypeError
233-
If keyword arguments are provided.
234-
OptionError
235-
If no such option exists.
227+
ValueError if odd numbers of non-keyword arguments are provided
228+
TypeError if keyword arguments are provided
229+
OptionError if no such option exists
236230
237231
See Also
238232
--------
239233
get_option : Retrieve the value of the specified option.
240234
reset_option : Reset one or more options to their default value.
241235
describe_option : Print the description for one or more registered options.
242-
option_context : Context manager to temporarily set options in a `with` statement.
236+
option_context : Context manager to temporarily set options in a ``with``
237+
statement.
243238
244239
Notes
245240
-----
@@ -248,32 +243,28 @@ def set_option(*args) -> None:
248243
249244
Examples
250245
--------
251-
Setting options using pairs:
252-
253246
>>> pd.set_option("display.max_columns", 4)
247+
>>> # another way of passing options
248+
>>> # pd.set_option({"display.max_columns": 4, "display.width": 80})
254249
>>> df = pd.DataFrame([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
255250
>>> df
256-
0 1 ... 3 4
257-
0 1 2 ... 4 5
258-
1 6 7 ... 9 10
251+
0 1 ... 3 4
252+
0 1 2 ... 4 5
253+
1 6 7 ... 9 10
259254
[2 rows x 5 columns]
260255
>>> pd.reset_option("display.max_columns")
261-
262-
Setting options using a dictionary:
263-
264-
>>> pd.set_option({"display.max_columns": 4, "display.width": 80})
265256
"""
266257
nargs = len(args)
267-
pairs = []
258+
pairs: list[tuple[Any, Any]] = []
268259

269260
if nargs == 1 and isinstance(args[0], dict):
270-
pairs = args[0].items()
261+
pairs = list(args[0].items())
271262
else:
272263
if not nargs or nargs % 2 != 0:
273264
raise ValueError(
274265
"Must provide an even number of non-keyword arguments or a dictionary"
275266
)
276-
pairs = zip(args[::2], args[1::2])
267+
pairs = list(zip(args[::2], args[1::2]))
277268

278269
for k, v in pairs:
279270
key = _get_single_key(k)
@@ -285,7 +276,6 @@ def set_option(*args) -> None:
285276
if opt.cb:
286277
opt.cb(key)
287278

288-
289279
### Second Approach Supports both *args[pd.set_option(options)]
290280
### and **kwargs[pd.set_option(**options)] where options=dict
291281

0 commit comments

Comments
 (0)