Skip to content

Commit 91c7d0c

Browse files
committed
Removed deprecated support for positional args on Extension class.
1 parent caa0c1e commit 91c7d0c

18 files changed

+49
-77
lines changed

markdown/extensions/__init__.py

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,8 @@ class Extension(object):
2020
# if a default is not set here.
2121
config = {}
2222

23-
def __init__(self, *args, **kwargs):
23+
def __init__(self, **kwargs):
2424
""" Initiate Extension and set up configs. """
25-
26-
# check for configs arg for backward compat.
27-
# (there only ever used to be one so we use arg[0])
28-
if len(args):
29-
if args[0] is not None:
30-
self.setConfigs(args[0])
31-
warnings.warn('Extension classes accepting positional args is '
32-
'pending Deprecation. Each setting should be '
33-
'passed into the Class as a keyword. Positional '
34-
'args are deprecated and will raise '
35-
'an error in version 2.7. See the Release Notes for '
36-
'Python-Markdown version 2.6 for more info.',
37-
DeprecationWarning)
38-
# check for configs kwarg for backward compat.
39-
if 'configs' in kwargs.keys():
40-
if kwargs['configs'] is not None:
41-
self.setConfigs(kwargs.pop('configs', {}))
42-
warnings.warn('Extension classes accepting a dict on the single '
43-
'keyword "config" is pending Deprecation. Each '
44-
'setting should be passed into the Class as a '
45-
'keyword directly. The "config" keyword is '
46-
'deprecated and raise an error in '
47-
'version 2.7. See the Release Notes for '
48-
'Python-Markdown version 2.6 for more info.',
49-
DeprecationWarning)
50-
# finally, use kwargs
5125
self.setConfigs(kwargs)
5226

5327
def getConfig(self, key, default=''):

markdown/extensions/abbr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,5 @@ def handleMatch(self, m):
8787
return abbr
8888

8989

90-
def makeExtension(*args, **kwargs):
91-
return AbbrExtension(*args, **kwargs)
90+
def makeExtension(**kwargs):
91+
return AbbrExtension(**kwargs)

markdown/extensions/admonition.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,5 @@ def get_class_and_title(self, match):
9292
return klass, title
9393

9494

95-
def makeExtension(*args, **kwargs):
96-
return AdmonitionExtension(*args, **kwargs)
95+
def makeExtension(**kwargs):
96+
return AdmonitionExtension(**kwargs)

markdown/extensions/attr_list.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,5 +173,5 @@ def extendMarkdown(self, md, md_globals):
173173
)
174174

175175

176-
def makeExtension(*args, **kwargs):
177-
return AttrListExtension(*args, **kwargs)
176+
def makeExtension(**kwargs):
177+
return AttrListExtension(**kwargs)

markdown/extensions/codehilite.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def run(self, root):
227227
class CodeHiliteExtension(Extension):
228228
""" Add source code hilighting to markdown codeblocks. """
229229

230-
def __init__(self, *args, **kwargs):
230+
def __init__(self, **kwargs):
231231
# define default configs
232232
self.config = {
233233
'linenums': [None,
@@ -249,7 +249,7 @@ def __init__(self, *args, **kwargs):
249249
'Default: True']
250250
}
251251

252-
super(CodeHiliteExtension, self).__init__(*args, **kwargs)
252+
super(CodeHiliteExtension, self).__init__(**kwargs)
253253

254254
def extendMarkdown(self, md, md_globals):
255255
""" Add HilitePostprocessor to Markdown instance. """
@@ -260,5 +260,5 @@ def extendMarkdown(self, md, md_globals):
260260
md.registerExtension(self)
261261

262262

263-
def makeExtension(*args, **kwargs):
264-
return CodeHiliteExtension(*args, **kwargs)
263+
def makeExtension(**kwargs):
264+
return CodeHiliteExtension(**kwargs)

markdown/extensions/def_list.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,5 @@ def extendMarkdown(self, md, md_globals):
111111
'>ulist')
112112

113113

114-
def makeExtension(*args, **kwargs):
115-
return DefListExtension(*args, **kwargs)
114+
def makeExtension(**kwargs):
115+
return DefListExtension(**kwargs)

markdown/extensions/extra.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@
5050
class ExtraExtension(Extension):
5151
""" Add various extensions to Markdown class."""
5252

53-
def __init__(self, *args, **kwargs):
54-
""" config is a dumb holder which gets passed to actual ext later. """
55-
self.config = kwargs.pop('configs', {})
56-
self.config.update(kwargs)
53+
def __init__(self, **kwargs):
54+
self.config = kwargs
5755

5856
def extendMarkdown(self, md, md_globals):
5957
""" Register extension instances. """
@@ -68,8 +66,8 @@ def extendMarkdown(self, md, md_globals):
6866
r'^(p|h[1-6]|li|dd|dt|td|th|legend|address)$', re.IGNORECASE)
6967

7068

71-
def makeExtension(*args, **kwargs):
72-
return ExtraExtension(*args, **kwargs)
69+
def makeExtension(**kwargs):
70+
return ExtraExtension(**kwargs)
7371

7472

7573
class MarkdownInHtmlProcessor(BlockProcessor):

markdown/extensions/fenced_code.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,5 @@ def _escape(self, txt):
108108
return txt
109109

110110

111-
def makeExtension(*args, **kwargs):
112-
return FencedCodeExtension(*args, **kwargs)
111+
def makeExtension(**kwargs):
112+
return FencedCodeExtension(**kwargs)

markdown/extensions/footnotes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
class FootnoteExtension(Extension):
3434
""" Footnote Extension. """
3535

36-
def __init__(self, *args, **kwargs):
36+
def __init__(self, **kwargs):
3737
""" Setup configs. """
3838

3939
self.config = {
@@ -49,7 +49,7 @@ def __init__(self, *args, **kwargs):
4949
"The text string that links from the footnote "
5050
"to the reader's place."]
5151
}
52-
super(FootnoteExtension, self).__init__(*args, **kwargs)
52+
super(FootnoteExtension, self).__init__(**kwargs)
5353

5454
# In multiple invocations, emit links that don't get tangled.
5555
self.unique_prefix = 0
@@ -314,6 +314,6 @@ def run(self, text):
314314
return text.replace(NBSP_PLACEHOLDER, " ")
315315

316316

317-
def makeExtension(*args, **kwargs):
317+
def makeExtension(**kwargs):
318318
""" Return an instance of the FootnoteExtension """
319-
return FootnoteExtension(*args, **kwargs)
319+
return FootnoteExtension(**kwargs)

markdown/extensions/headerid.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def _get_meta(self):
6161

6262

6363
class HeaderIdExtension(Extension):
64-
def __init__(self, *args, **kwargs):
64+
def __init__(self, **kwargs):
6565
# set defaults
6666
self.config = {
6767
'level': ['1', 'Base level for headers.'],
@@ -70,7 +70,7 @@ def __init__(self, *args, **kwargs):
7070
'slugify': [slugify, 'Callable to generate anchors']
7171
}
7272

73-
super(HeaderIdExtension, self).__init__(*args, **kwargs)
73+
super(HeaderIdExtension, self).__init__(**kwargs)
7474

7575
warnings.warn(
7676
'The HeaderId Extension is pending deprecation. Use the TOC Extension instead.',
@@ -93,5 +93,5 @@ def reset(self):
9393
self.processor.IDs = set()
9494

9595

96-
def makeExtension(*args, **kwargs):
97-
return HeaderIdExtension(*args, **kwargs)
96+
def makeExtension(**kwargs):
97+
return HeaderIdExtension(**kwargs)

0 commit comments

Comments
 (0)