Skip to content

Commit 8bb82bd

Browse files
committed
Add mypy config for optional support.
1 parent b90ec1f commit 8bb82bd

File tree

5 files changed

+54
-8
lines changed

5 files changed

+54
-8
lines changed

.vscode/settings.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
72
99
]
1010
},
11+
"files.insertFinalNewline": true,
12+
"files.trimFinalNewlines": true,
13+
"files.trimTrailingWhitespace": true,
14+
"editor.comments.insertSpace": true,
15+
"editor.insertSpaces": true,
1116
"editor.detectIndentation": false,
1217
"editor.tabSize": 2,
1318
"editor.formatOnSave": true,
@@ -17,7 +22,6 @@
1722
"source.fixAll.convertImportFormat": true,
1823
"source.organizeImports": true,
1924
},
20-
"files.insertFinalNewline": true,
2125
"trailing-spaces.includeEmptyLines": true,
2226
"trailing-spaces.trimOnSave": true,
2327
"trailing-spaces.syntaxIgnore": [
@@ -36,9 +40,8 @@
3640
]
3741
},
3842
"files.associations": {
39-
"*.json": "json",
40-
"extensions.json": "jsonc",
41-
"settings.json": "jsonc",
43+
"pyrightconfig*.json": "jsonc",
44+
".flake8": "properties",
4245
"*.qrc": "xml",
4346
"*.ui": "xml"
4447
},
@@ -70,8 +73,10 @@
7073
120, // Our hard rule
7174
],
7275
},
73-
"python.formatting.provider": "autopep8",
76+
// Important to follow the config in pyrightconfig.json
77+
"python.analysis.useLibraryCodeForTypes": false,
7478
"python.analysis.diagnosticMode": "workspace",
79+
"python.formatting.provider": "autopep8",
7580
"isort.check": true,
7681
"isort.importStrategy": "fromEnvironment",
7782
"python.linting.enabled": true,

mypy.ini

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
; We don't run mypy in the CI. This is just to help anyone who would like to use it manually.
2+
; Namely, the mypy_primer tool.
3+
[mypy]
4+
strict=true
5+
; exclude doesn't work with strict=true Why?
6+
exclude=.*(typings|gen)/.*
7+
; Implicit return types !
8+
disallow_untyped_calls=false
9+
disallow_untyped_defs=false
10+
disallow_incomplete_defs=false
11+
12+
; Of course my stubs are going to be incomplete. Otherwise they'd be on typeshed!
13+
; Mypy becomes really whack with its errors inside these stubs though
14+
mypy_path=typings
15+
16+
[mypy-gen.*,cv2.*,]
17+
; strict=false ; Doesn't work in overrides
18+
follow_imports=skip
19+
implicit_reexport=true
20+
strict_optional=false
21+
disable_error_code=attr-defined, misc, name-defined

scripts/requirements-dev.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ flake8-bugbear
1414
flake8-class-attributes-order
1515
flake8-comprehensions>=3.8 # flake8 5 support
1616
flake8-datetimez
17-
flake8-pyi>=22.11.0 # flak8 6 support
17+
flake8-pyi>=22.11.0 # flake8 6 support
1818
flake8-quotes
1919
flake8-simplify
2020
pep8-naming
@@ -31,6 +31,11 @@ qt6-applications
3131
# Types
3232
types-d3dshot
3333
types-keyboard
34+
types-Pillow
35+
types-psutil
36+
types-PyAutoGUI
3437
types-pyinstaller
3538
types-pywin32
39+
types-requests
40+
types-toml
3641
typing-extensions

src/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ def get_window_bounds(hwnd: int) -> tuple[int, int, int, int]:
8181
return window_left_bounds, window_top_bounds, window_width, window_height
8282

8383

84-
def open_file(file_path: str):
85-
os.startfile(file_path) # nosec B606
84+
def open_file(file_path: str | bytes | os.PathLike[str] | os.PathLike[bytes]):
85+
os.startfile(file_path)
8686

8787

8888
def get_or_create_eventloop():

typings/cv2/gapi/streaming.pyi

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from cv2.cv2 import GMat, GOpaqueT, gapi_streaming_queue_capacity
2+
3+
SYNC_POLICY_DONT_SYNC: int
4+
SYNC_POLICY_DROP: int
5+
sync_policy_dont_sync: int
6+
sync_policy_drop: int
7+
8+
queue_capacity = gapi_streaming_queue_capacity
9+
10+
11+
def desync(g: GMat) -> GMat: ...
12+
def seqNo(arg1: GMat) -> GOpaqueT: ...
13+
def seq_id(arg1: GMat) -> GOpaqueT: ...
14+
def size(src: GMat) -> GOpaqueT: ...
15+
def timestamp(arg1: GMat) -> GOpaqueT: ...

0 commit comments

Comments
 (0)