Skip to content

Commit 878af85

Browse files
authored
mypy: disallow untyped defs by default (#11862)
Change our mypy configuration to disallow untyped defs by default, which ensures *new* files added to the code base are fully typed. To avoid having to type-annotate everything now, add `# mypy: allow-untyped-defs` to files which are not fully type annotated yet. As we fully type annotate those modules, we can then just remove that directive from the top.
1 parent e7b43b2 commit 878af85

File tree

155 files changed

+158
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+158
-3
lines changed

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ formats = sdist.tgz,bdist_wheel
9494
mypy_path = src
9595
check_untyped_defs = True
9696
disallow_any_generics = True
97+
disallow_untyped_defs = True
9798
ignore_missing_imports = True
9899
show_error_codes = True
99100
strict_equality = True

src/_pytest/_code/code.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import ast
23
import dataclasses
34
import inspect

src/_pytest/_code/source.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
import ast
23
import inspect
34
import textwrap

src/_pytest/_io/pprint.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
# This module was imported from the cpython standard library
23
# (https://github.com/python/cpython/) at commit
34
# c5140945c723ae6c4b7ee81ff720ac8ea4b52cfd (python3.12).

src/_pytest/_py/path.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""local path implementation."""
23
from __future__ import annotations
34

src/_pytest/assertion/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""Support for presenting detailed information in failing assertions."""
23
import sys
34
from typing import Any

src/_pytest/assertion/util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""Utilities for assertion debugging."""
23
import collections.abc
34
import os

src/_pytest/cacheprovider.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""Implementation of the cache provider."""
23
# This plugin was not named "cache" to avoid conflicts with the external
34
# pytest-cache version.

src/_pytest/capture.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""Per-test stdout/stderr capturing mechanism."""
23
import abc
34
import collections

src/_pytest/compat.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: allow-untyped-defs
12
"""Python version compatibility code."""
23
from __future__ import annotations
34

0 commit comments

Comments
 (0)