pyclean.compat   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 8
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A ExtendAction.__call__() 0 5 2
1
# SPDX-FileCopyrightText: 2019 Peter Bittner <[email protected]>
2
#
3
# SPDX-License-Identifier: GPL-3.0-or-later
4
5
"""
6
Cross-Python version compatibility.
7
"""
8
9
from argparse import _AppendAction as AppendAction
10
11
12
class ExtendAction(AppendAction):  # pragma: no-cover-gt-py37
13
    """
14
    Argparse "extend" action for Python < 3.8.
15
    A simplified backport from the Python standard library.
16
    """
17
18
    def __call__(self, parser, namespace, values, option_string=None):  # noqa: ARG002
19
        items = getattr(namespace, self.dest, None)
20
        items = [] if items is None else items[:]
21
        items.extend(values)
22
        setattr(namespace, self.dest, items)
23