scrapy / parsel
Showing 2 of 6 files from the diff.

@@ -32,7 +32,7 @@
Loading
32 32
        if self.attribute is not None:
33 33
            if path.endswith("::*/*"):
34 34
                path = path[:-2]
35 -
            path += "/@%s" % self.attribute
35 +
            path += f"/@{self.attribute}"
36 36
37 37
        return path
38 38
@@ -58,24 +58,19 @@
Loading
58 58
        Dispatch method that transforms XPath to support pseudo-element
59 59
        """
60 60
        if isinstance(pseudo_element, FunctionalPseudoElement):
61 -
            method = "xpath_%s_functional_pseudo_element" % (
62 -
                pseudo_element.name.replace("-", "_")
63 -
            )
61 +
            method = f"xpath_{pseudo_element.name.replace('-', '_')}_functional_pseudo_element"
64 62
            method = _unicode_safe_getattr(self, method, None)
65 63
            if not method:
66 64
                raise ExpressionError(
67 -
                    "The functional pseudo-element ::%s() is unknown"
68 -
                    % pseudo_element.name
65 +
                    f"The functional pseudo-element ::{pseudo_element.name}() is unknown"
69 66
                )
70 67
            xpath = method(xpath, pseudo_element)
71 68
        else:
72 -
            method = "xpath_%s_simple_pseudo_element" % (
73 -
                pseudo_element.replace("-", "_")
74 -
            )
69 +
            method = f"xpath_{pseudo_element.replace('-', '_')}_simple_pseudo_element"
75 70
            method = _unicode_safe_getattr(self, method, None)
76 71
            if not method:
77 72
                raise ExpressionError(
78 -
                    "The pseudo-element ::%s is unknown" % pseudo_element
73 +
                    f"The pseudo-element ::{pseudo_element} is unknown"
79 74
                )
80 75
            xpath = method(xpath)
81 76
        return xpath
@@ -84,8 +79,7 @@
Loading
84 79
        """Support selecting attribute values using ::attr() pseudo-element"""
85 80
        if function.argument_types() not in (["STRING"], ["IDENT"]):
86 81
            raise ExpressionError(
87 -
                "Expected a single string or ident for ::attr(), got %r"
88 -
                % function.arguments
82 +
                f"Expected a single string or ident for ::attr(), got {function.arguments!r}"
89 83
            )
90 84
        return XPathExpr.from_xpath(xpath, attribute=function.arguments[0].value)
91 85

@@ -47,7 +47,7 @@
Loading
47 47
    elif st in _ctgroup:
48 48
        return st
49 49
    else:
50 -
        raise ValueError("Invalid type: %s" % st)
50 +
        raise ValueError(f"Invalid type: {st}")
51 51
52 52
53 53
def create_root_node(text, parser_cls, base_url=None):
@@ -274,7 +274,7 @@
Loading
274 274
275 275
        if text is not None:
276 276
            if not isinstance(text, str):
277 -
                msg = "text argument should be of type str, got %s" % (text.__class__)
277 +
                msg = f"text argument should be of type str, got {text.__class__}"
278 278
                raise TypeError(msg)
279 279
            root = self._get_root(text, base_url)
280 280
        elif root is None:
Files Coverage
parsel 100.00%
Project Totals (5 files) 100.00%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading