File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,9 +95,9 @@ implementation as the built-in :meth:`~str.format` method.
9595 an arbitrary set of positional and keyword arguments.
9696 It is just a wrapper that calls :meth: `vformat `.
9797
98- .. deprecated :: 3.5
99- Passing a format string as keyword argument * format_string * has been
100- deprecated .
98+ .. versionchanged :: 3.7
99+ A format string argument is now :ref: ` positional-only
100+ <positional-only_parameter>` .
101101
102102 .. method :: vformat(format_string, args, kwargs)
103103
Original file line number Diff line number Diff line change @@ -147,3 +147,9 @@ This section lists previously described changes and other bugfixes
147147that may require changes to your code.
148148
149149
150+ Changes in the Python API
151+ -------------------------
152+
153+ * A format string argument for :meth: `string.Formatter.format `
154+ is now :ref: `positional-only <positional-only_parameter >`.
155+ (Contributed by Serhiy Storchaka in :issue: `29193 `.)
Original file line number Diff line number Diff line change @@ -175,14 +175,8 @@ def format(*args, **kwargs):
175175 try :
176176 format_string , * args = args # allow the "format_string" keyword be passed
177177 except ValueError :
178- if 'format_string' in kwargs :
179- format_string = kwargs .pop ('format_string' )
180- import warnings
181- warnings .warn ("Passing 'format_string' as keyword argument is "
182- "deprecated" , DeprecationWarning , stacklevel = 2 )
183- else :
184- raise TypeError ("format() missing 1 required positional "
185- "argument: 'format_string'" ) from None
178+ raise TypeError ("format() missing 1 required positional "
179+ "argument: 'format_string'" ) from None
186180 return self .vformat (format_string , args , kwargs )
187181
188182 def vformat (self , format_string , args , kwargs ):
Original file line number Diff line number Diff line change @@ -48,9 +48,8 @@ def test_format_keyword_arguments(self):
4848 self .assertEqual (fmt .format ("-{format_string}-" , format_string = 'test' ),
4949 '-test-' )
5050 self .assertRaises (KeyError , fmt .format , "-{format_string}-" )
51- with self .assertWarnsRegex (DeprecationWarning , "format_string" ):
52- self .assertEqual (fmt .format (arg = 'test' , format_string = "-{arg}-" ),
53- '-test-' )
51+ with self .assertRaisesRegex (TypeError , "format_string" ):
52+ fmt .format (format_string = "-{arg}-" , arg = 'test' )
5453
5554 def test_auto_numbering (self ):
5655 fmt = string .Formatter ()
Original file line number Diff line number Diff line change @@ -212,6 +212,9 @@ Core and Builtins
212212Library
213213-------
214214
215+ - Issue #29193: A format string argument for string.Formatter.format()
216+ is now positional-only.
217+
215218- Issue #29195: Removed support of deprecated undocumented keyword arguments
216219 in methods of regular expression objects.
217220
You can’t perform that action at this time.
0 commit comments