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.

PyreStrictTest.path_can_safely_be_skipped()   A
last analyzed

Complexity

Conditions 4

Size

Total Lines 21
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 21
rs 9.95
c 0
b 0
f 0
cc 4
nop 1
1
# pyre-strict
2
3
"""
4
We use Pyre Check to prevent type errors. However, for Pyre Check to fail if
5
type declarations aren't "perfect", all files need to start with a "pyre-strict"
6
comment. This test checks that all Python files start with such a comment.
7
"""
8
9
import unittest
10
import os
11
12
13
class PyreStrictTest(unittest.TestCase):
14
    """
15
    Check that all relevant Python files have Pyre set to strict mode.
16
    """
17
18
    def test_strict_all_python_files(self) -> None:
19
        """
20
        Check that all relevant Python files have Pyre set to strict mode.
21
        """
22
        for directory, _directories, files in os.walk('.'):
23
            for file in files:
24
                path = os.path.join(directory, file)
25
26
                if self.path_can_safely_be_skipped(path):
27
                    continue
28
29
                with open(path) as current_file:
30
                    first_line: str = current_file.readline()
31
32
                    self.assertEqual(
33
                        first_line,
34
                        '# pyre-strict\n',
35
                        path + ' is not set to Pyre strict mode.',
36
                    )
37
38
    @staticmethod
39
    def path_can_safely_be_skipped(path: str) -> bool:
40
        """
41
        Make sure that we only check Python files that are in the present
42
        codebase.
43
44
        :param path:
45
        :return:
46
        """
47
        if not path.endswith('.py'):
48
            return True
49
50
        if './lib/' in path:
51
            # Prevent false positive in Scrutinizer.
52
            return True
53
54
        if './bin/activate_this.py' in path:
55
            # Prevent false positive in Scrutinizer.
56
            return True
57
58
        return False
59