Passed
Pull Request — main (#297)
by
unknown
01:50
created

pincer.utils.conversion.construct_client_dict()   A

Complexity

Conditions 1

Size

Total Lines 16
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 16
rs 10
c 0
b 0
f 0
cc 1
nop 2
1
# Copyright Pincer 2021-Present
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
# Full MIT License can be found in `LICENSE` at the project root.
3
4
from __future__ import annotations
5
6
from typing import TYPE_CHECKING
7
8
if TYPE_CHECKING:
9
    from ..client import Client
10
    from typing import Any, Callable, Dict, List, Optional, Set, Union, Tuple
11
12
13
def remove_none(
0 ignored issues
show
Unused Code introduced by
Either all return statements in a function should return an expression, or none of them should.
Loading history...
14
    obj: Union[List, Dict, Set, Tuple]
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
15
) -> Union[List, Dict, Set, Tuple]:
16
    """
17
    Removes all ``None`` values from a list, dict or set.
18
19
    Parameters
20
    ----------
21
    obj : Union[List, Dict, Set, Tuple]
22
        The list, dict, set or tuple to remove ``None`` values from.
23
24
    Returns
25
    -------
26
    Union[List, Dict, Set, Tuple]
27
        The list, dict, set or tuple, without ``None`` values.
28
    """
29
    if isinstance(obj, list):
0 ignored issues
show
unused-code introduced by
Unnecessary "elif" after "return"
Loading history...
30
        return [i for i in obj if i is not None]
31
    elif isinstance(obj, tuple):
32
        return tuple(i for i in obj if i is not None)
33
    elif isinstance(obj, set):
34
        return obj - {None}
35
    elif isinstance(obj, dict):
36
        return {k: v for k, v in obj.items() if None not in (k, v)}
37