10 """ |
10 """ |
11 |
11 |
12 from PyQt6.QtCore import QCoreApplication |
12 from PyQt6.QtCore import QCoreApplication |
13 |
13 |
14 _annotationsMessages = { |
14 _annotationsMessages = { |
15 "A001": QCoreApplication.translate( |
15 "A-001": QCoreApplication.translate( |
16 "AnnotationsChecker", "missing type annotation for function argument '{0}'" |
16 "AnnotationsChecker", "missing type annotation for function argument '{0}'" |
17 ), |
17 ), |
18 "A002": QCoreApplication.translate( |
18 "A-002": QCoreApplication.translate( |
19 "AnnotationsChecker", "missing type annotation for '*{0}'" |
19 "AnnotationsChecker", "missing type annotation for '*{0}'" |
20 ), |
20 ), |
21 "A003": QCoreApplication.translate( |
21 "A-003": QCoreApplication.translate( |
22 "AnnotationsChecker", "missing type annotation for '**{0}'" |
22 "AnnotationsChecker", "missing type annotation for '**{0}'" |
23 ), |
23 ), |
24 "A101": QCoreApplication.translate( |
24 "A-101": QCoreApplication.translate( |
25 "AnnotationsChecker", "missing type annotation for 'self' in method" |
25 "AnnotationsChecker", "missing type annotation for 'self' in method" |
26 ), |
26 ), |
27 "A102": QCoreApplication.translate( |
27 "A-102": QCoreApplication.translate( |
28 "AnnotationsChecker", "missing type annotation for 'cls' in classmethod" |
28 "AnnotationsChecker", "missing type annotation for 'cls' in classmethod" |
29 ), |
29 ), |
30 "A201": QCoreApplication.translate( |
30 "A-201": QCoreApplication.translate( |
31 "AnnotationsChecker", "missing return type annotation for public function" |
31 "AnnotationsChecker", "missing return type annotation for public function" |
32 ), |
32 ), |
33 "A202": QCoreApplication.translate( |
33 "A-202": QCoreApplication.translate( |
34 "AnnotationsChecker", "missing return type annotation for protected function" |
34 "AnnotationsChecker", "missing return type annotation for protected function" |
35 ), |
35 ), |
36 "A203": QCoreApplication.translate( |
36 "A-203": QCoreApplication.translate( |
37 "AnnotationsChecker", "missing return type annotation for private function" |
37 "AnnotationsChecker", "missing return type annotation for private function" |
38 ), |
38 ), |
39 "A204": QCoreApplication.translate( |
39 "A-204": QCoreApplication.translate( |
40 "AnnotationsChecker", "missing return type annotation for special method" |
40 "AnnotationsChecker", "missing return type annotation for special method" |
41 ), |
41 ), |
42 "A205": QCoreApplication.translate( |
42 "A-205": QCoreApplication.translate( |
43 "AnnotationsChecker", "missing return type annotation for staticmethod" |
43 "AnnotationsChecker", "missing return type annotation for staticmethod" |
44 ), |
44 ), |
45 "A206": QCoreApplication.translate( |
45 "A-206": QCoreApplication.translate( |
46 "AnnotationsChecker", "missing return type annotation for classmethod" |
46 "AnnotationsChecker", "missing return type annotation for classmethod" |
47 ), |
47 ), |
48 "A401": QCoreApplication.translate( |
48 "A-401": QCoreApplication.translate( |
49 "AnnotationsChecker", |
49 "AnnotationsChecker", |
50 "Dynamically typed expressions (typing.Any) are disallowed", |
50 "Dynamically typed expressions (typing.Any) are disallowed", |
51 ), |
51 ), |
52 "A402": QCoreApplication.translate( |
52 "A-402": QCoreApplication.translate( |
53 "AnnotationsChecker", "Type comments are disallowed" |
53 "AnnotationsChecker", "Type comments are disallowed" |
54 ), |
54 ), |
55 "A871": QCoreApplication.translate( |
55 "A-871": QCoreApplication.translate( |
56 "AnnotationsChecker", |
56 "AnnotationsChecker", |
57 "missing 'from __future__ import annotations' but imports: {0}", |
57 "missing 'from __future__ import annotations' but imports: {0}", |
58 ), |
58 ), |
59 "A872": QCoreApplication.translate( |
59 "A-872": QCoreApplication.translate( |
60 "AnnotationsChecker", "missing 'from __future__ import annotations'" |
60 "AnnotationsChecker", "missing 'from __future__ import annotations'" |
61 ), |
61 ), |
62 "A873": QCoreApplication.translate( |
62 "A-873": QCoreApplication.translate( |
63 "AnnotationsChecker", |
63 "AnnotationsChecker", |
64 "missing 'from __future__ import annotations' but uses simplified type" |
64 "missing 'from __future__ import annotations' but uses simplified type" |
65 " annotations: {0}", |
65 " annotations: {0}", |
66 ), |
66 ), |
67 "A881": QCoreApplication.translate( |
67 "A-881": QCoreApplication.translate( |
68 "AnnotationsChecker", "type annotation coverage of {0}% is too low" |
68 "AnnotationsChecker", "type annotation coverage of {0}% is too low" |
69 ), |
69 ), |
70 "A891": QCoreApplication.translate( |
70 "A-891": QCoreApplication.translate( |
71 "AnnotationsChecker", "type annotation is too complex ({0} > {1})" |
71 "AnnotationsChecker", "type annotation is too complex ({0} > {1})" |
72 ), |
72 ), |
73 "A892": QCoreApplication.translate( |
73 "A-892": QCoreApplication.translate( |
74 "AnnotationsChecker", "type annotation is too long ({0} > {1})" |
74 "AnnotationsChecker", "type annotation is too long ({0} > {1})" |
75 ), |
75 ), |
76 "A901": QCoreApplication.translate( |
76 "A-901": QCoreApplication.translate( |
77 "AnnotationsChecker", |
77 "AnnotationsChecker", |
78 "'typing.Union' is deprecated, use '|' instead (see PEP 604)", |
78 "'typing.Union' is deprecated, use '|' instead (see PEP 604)", |
79 ), |
79 ), |
80 "A911": QCoreApplication.translate( |
80 "A-911": QCoreApplication.translate( |
81 "AnnotationsChecker", |
81 "AnnotationsChecker", |
82 "'typing.{0}' is deprecated, use '{1}' instead (see PEP 585)", |
82 "'typing.{0}' is deprecated, use '{1}' instead (see PEP 585)", |
83 ), |
83 ), |
84 } |
84 } |
85 |
85 |
86 _annotationsMessagesSampleArgs = { |
86 _annotationsMessagesSampleArgs = { |
87 "A001": ["arg1"], |
87 "A-001": ["arg1"], |
88 "A002": ["args"], |
88 "A-002": ["args"], |
89 "A003": ["kwargs"], |
89 "A-003": ["kwargs"], |
90 "A871": ["Dict, List"], |
90 "A-871": ["Dict, List"], |
91 "A873": ["dict, list"], |
91 "A-873": ["dict, list"], |
92 "A881": [60], |
92 "A-881": [60], |
93 "A891": [5, 3], |
93 "A-891": [5, 3], |
94 "A892": [10, 7], |
94 "A-892": [10, 7], |
95 "A911": ["List", "list"], |
95 "A-911": ["List", "list"], |
96 } |
96 } |