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.
This commit is contained in:
parent
e7b43b2121
commit
878af85aef
|
@ -94,6 +94,7 @@ formats = sdist.tgz,bdist_wheel
|
|||
mypy_path = src
|
||||
check_untyped_defs = True
|
||||
disallow_any_generics = True
|
||||
disallow_untyped_defs = True
|
||||
ignore_missing_imports = True
|
||||
show_error_codes = True
|
||||
strict_equality = True
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import ast
|
||||
import dataclasses
|
||||
import inspect
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import ast
|
||||
import inspect
|
||||
import textwrap
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
# This module was imported from the cpython standard library
|
||||
# (https://github.com/python/cpython/) at commit
|
||||
# c5140945c723ae6c4b7ee81ff720ac8ea4b52cfd (python3.12).
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""local path implementation."""
|
||||
from __future__ import annotations
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Support for presenting detailed information in failing assertions."""
|
||||
import sys
|
||||
from typing import Any
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Utilities for assertion debugging."""
|
||||
import collections.abc
|
||||
import os
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Implementation of the cache provider."""
|
||||
# This plugin was not named "cache" to avoid conflicts with the external
|
||||
# pytest-cache version.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Per-test stdout/stderr capturing mechanism."""
|
||||
import abc
|
||||
import collections
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Python version compatibility code."""
|
||||
from __future__ import annotations
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Command line options, ini-file and conftest.py processing."""
|
||||
import argparse
|
||||
import collections.abc
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Interactive debugging with PDB, the Python Debugger."""
|
||||
import argparse
|
||||
import functools
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Discover and run doctests in modules and test files."""
|
||||
import bdb
|
||||
import functools
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import abc
|
||||
import dataclasses
|
||||
import functools
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Version info, help messages, tracing configuration."""
|
||||
import os
|
||||
import sys
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Hook specifications for pytest plugins which are invoked by pytest itself
|
||||
and by builtin plugins."""
|
||||
from pathlib import Path
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Report test results in JUnit-XML format, for use with Jenkins and build
|
||||
integration servers.
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Add backward compatibility support for the legacy py path type."""
|
||||
import dataclasses
|
||||
import os
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Access and control log capturing."""
|
||||
import io
|
||||
import logging
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import collections.abc
|
||||
import dataclasses
|
||||
import inspect
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Monkeypatching and mocking functionality."""
|
||||
import os
|
||||
import re
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import abc
|
||||
import os
|
||||
import warnings
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Submit failure or test session information to a pastebin service."""
|
||||
import tempfile
|
||||
from io import StringIO
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import atexit
|
||||
import contextlib
|
||||
import fnmatch
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""(Disabled by default) support for testing pytest and pytest plugins.
|
||||
|
||||
PYTEST_DONT_REWRITE
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Python test discovery, setup and run of test functions."""
|
||||
import abc
|
||||
import dataclasses
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import math
|
||||
import pprint
|
||||
from collections.abc import Collection
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Record warnings during test function execution."""
|
||||
import re
|
||||
import warnings
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import dataclasses
|
||||
import os
|
||||
from io import StringIO
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Basic collect and runtest protocol implementations."""
|
||||
import bdb
|
||||
import dataclasses
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Support for skip/xfail functions and markers."""
|
||||
import dataclasses
|
||||
import os
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Terminal reporting of the full testing process.
|
||||
|
||||
This is a good source for looking at the various reporting hooks.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Support for providing temporary directories to test functions."""
|
||||
import dataclasses
|
||||
import os
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Discover and run std-library "unittest" style tests."""
|
||||
import sys
|
||||
import traceback
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import sys
|
||||
import warnings
|
||||
from contextlib import contextmanager
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import contextlib
|
||||
import multiprocessing
|
||||
import os
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import dataclasses
|
||||
import importlib.metadata
|
||||
import os
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import re
|
||||
import sys
|
||||
from types import FrameType
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
# flake8: noqa
|
||||
# disable flake check on this file because some constructs are strange
|
||||
# or redundant on purpose and can't be disable on a line-by-line basis
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import dataclasses
|
||||
import re
|
||||
import sys
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
from _pytest import deprecated
|
||||
from _pytest.pytester import Pytester
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Reproduces issue #3774"""
|
||||
from unittest import mock
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# mypy: allow-untyped-defs
|
||||
def test_init():
|
||||
pass
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# mypy: allow-untyped-defs
|
||||
def test_foo():
|
||||
pass
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# mypy: allow-untyped-defs
|
||||
def pytest_ignore_collect(collection_path):
|
||||
return False
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# mypy: allow-untyped-defs
|
||||
def test():
|
||||
pass
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# mypy: allow-untyped-defs
|
||||
def test_init():
|
||||
pass
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# mypy: allow-untyped-defs
|
||||
def test_foo():
|
||||
pass
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# mypy: allow-untyped-defs
|
||||
def test_foo():
|
||||
pass
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
def pytest_configure(config):
|
||||
import pytest
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
# content of conftest.py
|
||||
import json
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
# content of test_first.py
|
||||
def test_1():
|
||||
pass
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
# content of test_second.py
|
||||
def test_2():
|
||||
pass
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
# content of test_third.py
|
||||
def test_3():
|
||||
pass
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import InitVar
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# mypy: allow-untyped-defs
|
||||
def test_this_is_ignored():
|
||||
assert True
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
def test_doc():
|
||||
"""
|
||||
>>> 10 > 5
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# mypy: allow-untyped-defs
|
||||
def test():
|
||||
pass
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# mypy: allow-untyped-defs
|
||||
def test_1(arg1):
|
||||
pass
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# mypy: allow-untyped-defs
|
||||
def test_2(arg2):
|
||||
pass
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# mypy: allow-untyped-defs
|
||||
def test_spam(spam):
|
||||
assert spam == "spamspam"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# mypy: allow-untyped-defs
|
||||
def test_hello():
|
||||
pass
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pprint
|
||||
from typing import List
|
||||
from typing import Tuple
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import argparse
|
||||
import pathlib
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# mypy: allow-untyped-defs
|
||||
def test_x():
|
||||
pass
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import unittest
|
||||
|
||||
import pytest
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Skipping an entire subclass with unittest.skip() should *not* call setUp from a base class."""
|
||||
import unittest
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Skipping an entire subclass with unittest.skip() should *not* call setUpClass from a base class."""
|
||||
import unittest
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""setUpModule is always called, even if all tests in the module are skipped"""
|
||||
import unittest
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
from typing import List
|
||||
from unittest import IsolatedAsyncioTestCase
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
"""Issue #7110"""
|
||||
import asyncio
|
||||
from typing import List
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import unittest
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import warnings
|
||||
|
||||
import pytest
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import warnings
|
||||
|
||||
import pytest
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
from test_1 import func
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
def test_upper():
|
||||
assert "foo".upper() == "FOO"
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import pytest
|
||||
from _pytest._io.saferepr import DEFAULT_REPR_MAX_SIZE
|
||||
from _pytest._io.saferepr import saferepr
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import io
|
||||
import os
|
||||
import re
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# mypy: allow-untyped-defs
|
||||
import io
|
||||
import os
|
||||
import re
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue