GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 0254c9...47ea54 )
by
unknown
01:26
created

test_timed_wraps_right()   A

Complexity

Conditions 4

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
dl 0
loc 9
rs 9.2
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A somefun() 0 3 1
1
import logging
2
3
from unittest import mock
4
5
from server.decorators import with_logger, timed
6
7
8
def test_with_logger():
9
    @with_logger
10
    class testclass():
11
        pass
12
    assert isinstance(testclass()._logger, logging.Logger)
0 ignored issues
show
Bug introduced by
The Instance of testclass does not seem to have a member named _logger.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
Coding Style Best Practice introduced by
It seems like _logger was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
13
14
15
def test_timed_fun():
16
    logger = mock.Mock()
17
18
    @timed(logger=logger, limit=0)
19
    def something():
20
        return "Somevalue"
21
    assert something() == "Somevalue"
22
    logger.info.assert_any_call(mock.ANY)
23
24
25
def test_timed_method():
26
    logger = mock.Mock()
27
28
    class TestClass():
29
        @timed(logger=logger, limit=0)
30
        def something(self):
0 ignored issues
show
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
31
            return "Somevalue"
32
    assert TestClass().something() == "Somevalue"
33
    logger.info.assert_any_call(mock.ANY)
34
35
36
def test_timed_wraps_right():
37
    @timed()
38
    def somefun():
39
        return 'test'
40
41
    @timed
42
    def somefun():
43
        return 'test'
44
    assert somefun.__name__ == 'somefun'
45