summaryrefslogtreecommitdiff
path: root/tests/functional/m/misplaced_format_function.py
blob: 679f5985820adbce0429dae5c2ae9f865759d291 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""Test that format function is used only with string."""

# pylint: disable=invalid-name, pointless-string-statement, line-too-long, no-member, disallowed-name, undefined-variable, missing-docstring, too-few-public-methods
# pylint: disable=consider-using-f-string
print('value: {}').format(123)  # [misplaced-format-function]
print("value: {}").format(123)  # [misplaced-format-function]
print('value: {}'.format(123))
print('{} Come Forth!'.format('Lazarus'))
print('Der Hem ist mein Licht und mein Heil, vor wem sollte ich mich furchten? => {}'.format('Psalm 27, 1'))
print('123')
print()
s = 'value: {}'.format(123)
a = 'value: {}'
a.format(123)

def foo(arg):
    """The World is Yours"""
    return arg.format(123)  # we don't know if arg is str or not, don't raise error.

def goo(arg):
    """The World is Yours"""
    TextWriter.format(arg)

def bar(arg, TextWriter):
    """The World is Yours"""
    TextWriter().format(arg)

def foobar(arg, TextWriter):
    """The World is Yours"""
    TextWriter.format(arg)

def barfoo(arg):
    """The World is Yours"""
    TextWriter().format(arg)

def _display(self, layout):
    """launch layouts display"""
    print(file=self.out)
    TextWriter().format(layout, self.out)


class FakeClass:
    def __init__(self, string):
        self.string = string

    def get_string(self):
        return self.string

    def format_string(self):
        self.string.format()
        self.get_string().format()
        print(self.get_string()).format()  # [misplaced-format-function]
        print(self.get_string().format())

obj = FakeClass('Voila!!!')
obj.get_string().format()
print(obj.get_string().format())
print(obj.get_string()).format()  # [misplaced-format-function]