Skip to content

Commit 8b1484a

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

File tree

7 files changed

+54
-16
lines changed

7 files changed

+54
-16
lines changed

.github/workflows/lint-and-build.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ jobs:
4848
cache-dependency-path: "scripts/requirements*.txt"
4949
- run: scripts/install.ps1
5050
shell: pwsh
51-
- run: (Get-Command pyuic6).Source
52-
shell: pwsh
53-
- name: Analysing the code with add-trailing-comma
51+
- name: Analysing the code with isort
5452
run: isort src/ typings/ --check-only
5553
add-trailing-comma:
5654
runs-on: windows-latest

.vscode/settings.json

Lines changed: 10 additions & 7 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,7 @@
3640
]
3741
},
3842
"files.associations": {
39-
"*.json": "json",
40-
"extensions.json": "jsonc",
41-
"settings.json": "jsonc",
43+
".flake8": "properties",
4244
"*.qrc": "xml",
4345
"*.ui": "xml"
4446
},
@@ -50,11 +52,10 @@
5052
"**/.DS_Store": true,
5153
"**/Thumbs.db": true,
5254
"build": true,
53-
".mypy_cache": true,
55+
"**/.mypy_cache": true,
5456
"**/__pycache__": true,
5557
},
5658
"search.exclude": {
57-
"**/bower_components": true,
5859
"**/*.code-search": true,
5960
"*.lock": true,
6061
},
@@ -70,8 +71,10 @@
7071
120, // Our hard rule
7172
],
7273
},
73-
"python.formatting.provider": "autopep8",
74+
// Important to follow the config in pyrightconfig.json
75+
"python.analysis.useLibraryCodeForTypes": false,
7476
"python.analysis.diagnosticMode": "workspace",
77+
"python.formatting.provider": "autopep8",
7578
"isort.check": true,
7679
"isort.importStrategy": "fromEnvironment",
7780
"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+
; Implicit return types !
6+
disallow_untyped_calls=false
7+
disallow_untyped_defs=false
8+
disallow_incomplete_defs=false
9+
10+
; Of course my stubs are going to be incomplete. Otherwise they'd be on typeshed!
11+
; Mypy becomes really whack with its errors inside these stubs though
12+
mypy_path=typings,src
13+
; exclude doesn't work with strict=true Why?
14+
exclude=.*(typings|gen)/.*
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

pyproject.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ max-branches = 15
105105
# https://github.com/PyCQA/pep8-naming/issues/164
106106
# OR doesn't fit CaptureMethodMeta
107107
valid-classmethod-first-arg = "self"
108-
# https://pylint.pycqa.org/en/latest/user_guide/options.html#naming-styles
109-
module-naming-style = "any"
110108
disable = [
111109
# No need to mention the fixmes
112110
"fixme",
@@ -122,8 +120,6 @@ disable = [
122120
"unused-argument",
123121
# Only reports a single instance. Pyright does a better job anyway
124122
"cyclic-import",
125-
# Doesn't work with local imports
126-
"import-error",
127123
# Similar lines in 2 files, doesn't really work
128124
"R0801",
129125
]

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ 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):
84+
def open_file(file_path: str | bytes | os.PathLike[str] | os.PathLike[bytes]):
8585
os.startfile(file_path) # nosec B606
8686

8787

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)