Skip to content

Commit df54994

Browse files
committed
Turn mypy to strict but allow untyped code
Also fix some errors reported by mypy
1 parent 8e5336e commit df54994

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

doc/source/conf.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import os
2626
import subprocess
2727
import sys
28-
from typing import Dict, List
2928

3029
import alabaster
3130

@@ -92,7 +91,7 @@
9291

9392
# List of patterns, relative to source directory, that match files and
9493
# directories to ignore when looking for source files.
95-
exclude_patterns: List[str] = []
94+
exclude_patterns: list[str] = []
9695

9796
# The reST default role (used for this markup: `text`) to use for all
9897
# documents.
@@ -221,7 +220,7 @@
221220

222221
# -- Options for LaTeX output ---------------------------------------------
223222

224-
latex_elements: Dict[str, tuple] = {
223+
latex_elements: dict[str, tuple[str, ...]] = {
225224
# The paper size ('letterpaper' or 'a4paper')
226225
# 'papersize': 'letterpaper',
227226
# The font size ('10pt', '11pt' or '12pt').

mypy.ini

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
[mypy]
22
files = .
3-
# XXX: goal is to turn it on
4-
strict = False
5-
check_untyped_defs = True
6-
show_error_codes = True
3+
strict = true
4+
warn_unused_ignores = true
5+
show_error_codes = true
6+
# XXX: goal is to enable this
7+
disallow_untyped_defs = false
8+
disallow_untyped_calls = false
9+
check_untyped_defs = false
710

811
[mypy-salt.*]
912
ignore_missing_imports = True

testinfra/modules/process.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
1212

13+
from typing import Any
14+
1315
from testinfra.modules.base import InstanceModule
1416

1517

@@ -23,7 +25,7 @@ def int_or_float(value):
2325
return value
2426

2527

26-
class _Process(dict):
28+
class _Process(dict[str, Any]):
2729
def __getattr__(self, key):
2830
try:
2931
return self.__getitem__(key)

testinfra/plugin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import sys
1616
import tempfile
1717
import time
18+
from typing import AnyStr
1819

1920
import pytest
2021

@@ -173,7 +174,7 @@ def report(self):
173174
return ret
174175

175176

176-
class SpooledTemporaryFile(tempfile.SpooledTemporaryFile):
177+
class SpooledTemporaryFile(tempfile.SpooledTemporaryFile[AnyStr]):
177178
def __init__(self, *args, **kwargs):
178179
if "b" in kwargs.get("mode", "b"):
179180
self._out_encoding = kwargs.pop("encoding")

0 commit comments

Comments
 (0)