Skip to content

Commit

Permalink
Turn mypy to strict but allow untyped code
Browse files Browse the repository at this point in the history
Also fix some errors reported by mypy
  • Loading branch information
philpep committed Jul 21, 2023
1 parent 8e5336e commit df54994
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
5 changes: 2 additions & 3 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import os
import subprocess
import sys
from typing import Dict, List

import alabaster

Expand Down Expand Up @@ -92,7 +91,7 @@

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns: List[str] = []
exclude_patterns: list[str] = []

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

# -- Options for LaTeX output ---------------------------------------------

latex_elements: Dict[str, tuple] = {
latex_elements: dict[str, tuple[str, ...]] = {
# The paper size ('letterpaper' or 'a4paper')
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
Expand Down
11 changes: 7 additions & 4 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[mypy]
files = .
# XXX: goal is to turn it on
strict = False
check_untyped_defs = True
show_error_codes = True
strict = true
warn_unused_ignores = true
show_error_codes = true
# XXX: goal is to enable this
disallow_untyped_defs = false
disallow_untyped_calls = false
check_untyped_defs = false

[mypy-salt.*]
ignore_missing_imports = True
Expand Down
4 changes: 3 additions & 1 deletion testinfra/modules/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Any

from testinfra.modules.base import InstanceModule


Expand All @@ -23,7 +25,7 @@ def int_or_float(value):
return value


class _Process(dict):
class _Process(dict[str, Any]):
def __getattr__(self, key):
try:
return self.__getitem__(key)
Expand Down
3 changes: 2 additions & 1 deletion testinfra/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import sys
import tempfile
import time
from typing import AnyStr

import pytest

Expand Down Expand Up @@ -173,7 +174,7 @@ def report(self):
return ret


class SpooledTemporaryFile(tempfile.SpooledTemporaryFile):
class SpooledTemporaryFile(tempfile.SpooledTemporaryFile[AnyStr]):
def __init__(self, *args, **kwargs):
if "b" in kwargs.get("mode", "b"):
self._out_encoding = kwargs.pop("encoding")
Expand Down

0 comments on commit df54994

Please sign in to comment.