From 878af85aefc5a2a255395d66a38a2136aeaeb086 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 28 Jan 2024 10:12:42 -0300 Subject: [PATCH] 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. --- setup.cfg | 1 + src/_pytest/_code/code.py | 1 + src/_pytest/_code/source.py | 1 + src/_pytest/_io/pprint.py | 1 + src/_pytest/_py/path.py | 1 + src/_pytest/assertion/__init__.py | 1 + src/_pytest/assertion/util.py | 1 + src/_pytest/cacheprovider.py | 1 + src/_pytest/capture.py | 1 + src/_pytest/compat.py | 1 + src/_pytest/config/__init__.py | 1 + src/_pytest/config/argparsing.py | 1 + src/_pytest/debugging.py | 1 + src/_pytest/doctest.py | 1 + src/_pytest/fixtures.py | 1 + src/_pytest/helpconfig.py | 1 + src/_pytest/hookspec.py | 1 + src/_pytest/junitxml.py | 1 + src/_pytest/legacypath.py | 1 + src/_pytest/logging.py | 1 + src/_pytest/mark/structures.py | 1 + src/_pytest/monkeypatch.py | 1 + src/_pytest/nodes.py | 1 + src/_pytest/pastebin.py | 1 + src/_pytest/pathlib.py | 1 + src/_pytest/pytester.py | 1 + src/_pytest/python.py | 1 + src/_pytest/python_api.py | 1 + src/_pytest/recwarn.py | 1 + src/_pytest/reports.py | 1 + src/_pytest/runner.py | 1 + src/_pytest/skipping.py | 1 + src/_pytest/terminal.py | 1 + src/_pytest/tmpdir.py | 1 + src/_pytest/unittest.py | 1 + src/_pytest/warnings.py | 1 + testing/_py/test_local.py | 1 + testing/acceptance_test.py | 1 + testing/code/test_code.py | 1 + testing/code/test_excinfo.py | 1 + testing/code/test_source.py | 1 + testing/conftest.py | 1 + testing/deprecated_test.py | 1 + .../example_scripts/acceptance/fixture_mock_integration.py | 1 + .../collect/collect_init_tests/tests/__init__.py | 1 + .../collect/collect_init_tests/tests/test_foo.py | 1 + .../collect/package_infinite_recursion/conftest.py | 1 + .../collect/package_infinite_recursion/tests/test_basic.py | 1 + .../collect/package_init_given_as_arg/pkg/__init__.py | 1 + .../collect/package_init_given_as_arg/pkg/test_foo.py | 1 + .../example_scripts/config/collect_pytest_prefix/test_foo.py | 1 + testing/example_scripts/conftest_usageerror/conftest.py | 1 + testing/example_scripts/customdirectory/conftest.py | 1 + testing/example_scripts/customdirectory/tests/test_first.py | 1 + testing/example_scripts/customdirectory/tests/test_second.py | 1 + testing/example_scripts/customdirectory/tests/test_third.py | 1 + testing/example_scripts/dataclasses/test_compare_initvar.py | 1 + .../dataclasses/test_compare_recursive_dataclasses.py | 1 + testing/example_scripts/doctest/main_py/__main__.py | 1 + .../example_scripts/doctest/main_py/test_normal_module.py | 1 + testing/example_scripts/fixtures/custom_item/conftest.py | 1 + testing/example_scripts/fixtures/custom_item/foo/test_foo.py | 1 + .../sub1/conftest.py | 1 + .../sub1/test_in_sub1.py | 1 + .../sub2/conftest.py | 1 + .../sub2/test_in_sub2.py | 1 + .../fill_fixtures/test_detect_recursive_dependency_error.py | 1 + .../test_extend_fixture_conftest_conftest/conftest.py | 1 + .../test_extend_fixture_conftest_conftest/pkg/conftest.py | 1 + .../test_extend_fixture_conftest_conftest/pkg/test_spam.py | 1 + .../test_extend_fixture_conftest_module/conftest.py | 1 + .../test_extend_fixture_conftest_module.py | 1 + .../fill_fixtures/test_extend_fixture_module_class.py | 1 + .../fixtures/fill_fixtures/test_funcarg_basic.py | 1 + .../fixtures/fill_fixtures/test_funcarg_lookup_classlevel.py | 1 + .../fill_fixtures/test_funcarg_lookup_modulelevel.py | 1 + .../fixtures/fill_fixtures/test_funcarg_lookupfails.py | 1 + .../example_scripts/fixtures/test_fixture_named_request.py | 1 + .../example_scripts/fixtures/test_getfixturevalue_dynamic.py | 1 + .../issue88_initial_file_multinodes/conftest.py | 1 + .../issue88_initial_file_multinodes/test_hello.py | 1 + testing/example_scripts/issue_519.py | 1 + .../marks_considered_keywords/test_marks_as_keywords.py | 1 + .../perf_examples/collect_stats/generate_folders.py | 1 + .../perf_examples/collect_stats/template_test.py | 1 + testing/example_scripts/tmpdir/tmp_path_fixture.py | 1 + .../unittest/test_parametrized_fixture_error_message.py | 1 + testing/example_scripts/unittest/test_setup_skip.py | 1 + testing/example_scripts/unittest/test_setup_skip_class.py | 1 + testing/example_scripts/unittest/test_setup_skip_module.py | 1 + testing/example_scripts/unittest/test_unittest_asyncio.py | 1 + testing/example_scripts/unittest/test_unittest_asynctest.py | 1 + .../example_scripts/unittest/test_unittest_plain_async.py | 1 + .../warnings/test_group_warnings_by_message.py | 1 + .../test_group_warnings_by_message_summary/test_1.py | 1 + .../test_group_warnings_by_message_summary/test_2.py | 1 + testing/freeze/tests/test_trivial.py | 1 + testing/io/test_saferepr.py | 1 + testing/io/test_terminalwriter.py | 1 + testing/logging/test_reporting.py | 1 + testing/plugins_integration/bdd_wallet.py | 1 + testing/plugins_integration/pytest_anyio_integration.py | 1 + testing/plugins_integration/pytest_asyncio_integration.py | 1 + testing/plugins_integration/pytest_mock_integration.py | 1 + testing/plugins_integration/pytest_trio_integration.py | 1 + testing/plugins_integration/pytest_twisted_integration.py | 1 + testing/plugins_integration/simple_integration.py | 1 + testing/python/approx.py | 1 + testing/python/collect.py | 1 + testing/python/fixtures.py | 3 ++- testing/python/integration.py | 1 + testing/python/metafunc.py | 1 + testing/python/raises.py | 1 + testing/test_argcomplete.py | 1 + testing/test_assertion.py | 1 + testing/test_assertrewrite.py | 1 + testing/test_cacheprovider.py | 1 + testing/test_capture.py | 1 + testing/test_collection.py | 1 + testing/test_compat.py | 1 + testing/test_config.py | 1 + testing/test_conftest.py | 1 + testing/test_debugging.py | 1 + testing/test_doctest.py | 1 + testing/test_entry_points.py | 1 + testing/test_faulthandler.py | 1 + testing/test_findpaths.py | 1 + testing/test_helpconfig.py | 1 + testing/test_junitxml.py | 1 + testing/test_legacypath.py | 1 + testing/test_link_resolve.py | 1 + testing/test_main.py | 1 + testing/test_mark.py | 1 + testing/test_monkeypatch.py | 1 + testing/test_nodes.py | 1 + testing/test_parseopt.py | 1 + testing/test_pastebin.py | 1 + testing/test_pathlib.py | 1 + testing/test_pluginmanager.py | 1 + testing/test_pytester.py | 1 + testing/test_python_path.py | 1 + testing/test_recwarn.py | 1 + testing/test_reports.py | 1 + testing/test_runner.py | 1 + testing/test_runner_xunit.py | 1 + testing/test_session.py | 1 + testing/test_setuponly.py | 1 + testing/test_skipping.py | 1 + testing/test_stepwise.py | 1 + testing/test_terminal.py | 1 + testing/test_tmpdir.py | 1 + testing/test_unittest.py | 1 + testing/test_warning_types.py | 1 + testing/test_warnings.py | 5 +++-- testing/typing_checks.py | 1 + 155 files changed, 158 insertions(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 9ee64a4e8..eebce8c7c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 0288d7a54..d99b52366 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import ast import dataclasses import inspect diff --git a/src/_pytest/_code/source.py b/src/_pytest/_code/source.py index cc7ac407e..efee1fad3 100644 --- a/src/_pytest/_code/source.py +++ b/src/_pytest/_code/source.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import ast import inspect import textwrap diff --git a/src/_pytest/_io/pprint.py b/src/_pytest/_io/pprint.py index 7559c6778..6ec5d5401 100644 --- a/src/_pytest/_io/pprint.py +++ b/src/_pytest/_io/pprint.py @@ -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). diff --git a/src/_pytest/_py/path.py b/src/_pytest/_py/path.py index 24348525a..04b1695f1 100644 --- a/src/_pytest/_py/path.py +++ b/src/_pytest/_py/path.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """local path implementation.""" from __future__ import annotations diff --git a/src/_pytest/assertion/__init__.py b/src/_pytest/assertion/__init__.py index e1e7a5e66..933656978 100644 --- a/src/_pytest/assertion/__init__.py +++ b/src/_pytest/assertion/__init__.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Support for presenting detailed information in failing assertions.""" import sys from typing import Any diff --git a/src/_pytest/assertion/util.py b/src/_pytest/assertion/util.py index 6f97101a9..d2f67994c 100644 --- a/src/_pytest/assertion/util.py +++ b/src/_pytest/assertion/util.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Utilities for assertion debugging.""" import collections.abc import os diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index 793e796de..ee68cc38c 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -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. diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index ebdcaedce..c89763344 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Per-test stdout/stderr capturing mechanism.""" import abc import collections diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index 1e9c38ca8..ad8558b1f 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Python version compatibility code.""" from __future__ import annotations diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 6c16ad0b2..c0e1e195f 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Command line options, ini-file and conftest.py processing.""" import argparse import collections.abc diff --git a/src/_pytest/config/argparsing.py b/src/_pytest/config/argparsing.py index 39e417605..a31278f32 100644 --- a/src/_pytest/config/argparsing.py +++ b/src/_pytest/config/argparsing.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import argparse import os import sys diff --git a/src/_pytest/debugging.py b/src/_pytest/debugging.py index 57f26d219..aaac3e1b9 100644 --- a/src/_pytest/debugging.py +++ b/src/_pytest/debugging.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Interactive debugging with PDB, the Python Debugger.""" import argparse import functools diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index 4ce32a298..6a5bc7577 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Discover and run doctests in modules and test files.""" import bdb import functools diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 51c573575..d7d8a720b 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import abc import dataclasses import functools diff --git a/src/_pytest/helpconfig.py b/src/_pytest/helpconfig.py index 91ea76997..4f7d35172 100644 --- a/src/_pytest/helpconfig.py +++ b/src/_pytest/helpconfig.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Version info, help messages, tracing configuration.""" import os import sys diff --git a/src/_pytest/hookspec.py b/src/_pytest/hookspec.py index 83c9be3ef..3c27dcf91 100644 --- a/src/_pytest/hookspec.py +++ b/src/_pytest/hookspec.py @@ -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 diff --git a/src/_pytest/junitxml.py b/src/_pytest/junitxml.py index c8032e158..f01afd915 100644 --- a/src/_pytest/junitxml.py +++ b/src/_pytest/junitxml.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Report test results in JUnit-XML format, for use with Jenkins and build integration servers. diff --git a/src/_pytest/legacypath.py b/src/_pytest/legacypath.py index f69315b5f..cb9a36243 100644 --- a/src/_pytest/legacypath.py +++ b/src/_pytest/legacypath.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Add backward compatibility support for the legacy py path type.""" import dataclasses import os diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index d7e498d55..5565a6b3f 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Access and control log capturing.""" import io import logging diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 55ec67700..e3580cf6f 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import collections.abc import dataclasses import inspect diff --git a/src/_pytest/monkeypatch.py b/src/_pytest/monkeypatch.py index 834700b1b..01c74d6eb 100644 --- a/src/_pytest/monkeypatch.py +++ b/src/_pytest/monkeypatch.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Monkeypatching and mocking functionality.""" import os import re diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index 45bbb4b57..2d6ad7b8f 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import abc import os import warnings diff --git a/src/_pytest/pastebin.py b/src/_pytest/pastebin.py index 22c7a6223..484703374 100644 --- a/src/_pytest/pastebin.py +++ b/src/_pytest/pastebin.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Submit failure or test session information to a pastebin service.""" import tempfile from io import StringIO diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index ce5156b06..929d8c88e 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import atexit import contextlib import fnmatch diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index d388758a2..69a24c7c9 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """(Disabled by default) support for testing pytest and pytest plugins. PYTEST_DONT_REWRITE diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 64480c971..5fa32260b 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Python test discovery, setup and run of test functions.""" import abc import dataclasses diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index f914d70e8..c32d75b44 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import math import pprint from collections.abc import Collection diff --git a/src/_pytest/recwarn.py b/src/_pytest/recwarn.py index b3279dd31..57d4bb47c 100644 --- a/src/_pytest/recwarn.py +++ b/src/_pytest/recwarn.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Record warnings during test function execution.""" import re import warnings diff --git a/src/_pytest/reports.py b/src/_pytest/reports.py index 18f1c948a..ddf7f2983 100644 --- a/src/_pytest/reports.py +++ b/src/_pytest/reports.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import dataclasses import os from io import StringIO diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py index 01de43990..44fded69b 100644 --- a/src/_pytest/runner.py +++ b/src/_pytest/runner.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Basic collect and runtest protocol implementations.""" import bdb import dataclasses diff --git a/src/_pytest/skipping.py b/src/_pytest/skipping.py index 0c5c38f5f..617f7bb85 100644 --- a/src/_pytest/skipping.py +++ b/src/_pytest/skipping.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Support for skip/xfail functions and markers.""" import dataclasses import os diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index b91a97221..42b85b56d 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -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. diff --git a/src/_pytest/tmpdir.py b/src/_pytest/tmpdir.py index 21e5366a3..937b1687a 100644 --- a/src/_pytest/tmpdir.py +++ b/src/_pytest/tmpdir.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Support for providing temporary directories to test functions.""" import dataclasses import os diff --git a/src/_pytest/unittest.py b/src/_pytest/unittest.py index 6bf8f4f2f..ce06b7d9b 100644 --- a/src/_pytest/unittest.py +++ b/src/_pytest/unittest.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Discover and run std-library "unittest" style tests.""" import sys import traceback diff --git a/src/_pytest/warnings.py b/src/_pytest/warnings.py index 6ef4fafdc..de4b0830f 100644 --- a/src/_pytest/warnings.py +++ b/src/_pytest/warnings.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import sys import warnings from contextlib import contextmanager diff --git a/testing/_py/test_local.py b/testing/_py/test_local.py index 77a9838cf..ba19aef38 100644 --- a/testing/_py/test_local.py +++ b/testing/_py/test_local.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import contextlib import multiprocessing import os diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index b875b8f66..64e65f313 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import dataclasses import importlib.metadata import os diff --git a/testing/code/test_code.py b/testing/code/test_code.py index 33809528a..a59af4a49 100644 --- a/testing/code/test_code.py +++ b/testing/code/test_code.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import re import sys from types import FrameType diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 22be51d40..a9982b4f3 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from __future__ import annotations import importlib diff --git a/testing/code/test_source.py b/testing/code/test_source.py index 260c80299..9d0565380 100644 --- a/testing/code/test_source.py +++ b/testing/code/test_source.py @@ -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 diff --git a/testing/conftest.py b/testing/conftest.py index bcb05339b..0912285d8 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import dataclasses import re import sys diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py index ebff49ce6..752ccc91b 100644 --- a/testing/deprecated_test.py +++ b/testing/deprecated_test.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest from _pytest import deprecated from _pytest.pytester import Pytester diff --git a/testing/example_scripts/acceptance/fixture_mock_integration.py b/testing/example_scripts/acceptance/fixture_mock_integration.py index 5b00ac90e..d607e959d 100644 --- a/testing/example_scripts/acceptance/fixture_mock_integration.py +++ b/testing/example_scripts/acceptance/fixture_mock_integration.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Reproduces issue #3774""" from unittest import mock diff --git a/testing/example_scripts/collect/collect_init_tests/tests/__init__.py b/testing/example_scripts/collect/collect_init_tests/tests/__init__.py index 9cd366295..58c41942d 100644 --- a/testing/example_scripts/collect/collect_init_tests/tests/__init__.py +++ b/testing/example_scripts/collect/collect_init_tests/tests/__init__.py @@ -1,2 +1,3 @@ +# mypy: allow-untyped-defs def test_init(): pass diff --git a/testing/example_scripts/collect/collect_init_tests/tests/test_foo.py b/testing/example_scripts/collect/collect_init_tests/tests/test_foo.py index 8f2d73cfa..d88c001c2 100644 --- a/testing/example_scripts/collect/collect_init_tests/tests/test_foo.py +++ b/testing/example_scripts/collect/collect_init_tests/tests/test_foo.py @@ -1,2 +1,3 @@ +# mypy: allow-untyped-defs def test_foo(): pass diff --git a/testing/example_scripts/collect/package_infinite_recursion/conftest.py b/testing/example_scripts/collect/package_infinite_recursion/conftest.py index 973ccc0c0..bba5db8b2 100644 --- a/testing/example_scripts/collect/package_infinite_recursion/conftest.py +++ b/testing/example_scripts/collect/package_infinite_recursion/conftest.py @@ -1,2 +1,3 @@ +# mypy: allow-untyped-defs def pytest_ignore_collect(collection_path): return False diff --git a/testing/example_scripts/collect/package_infinite_recursion/tests/test_basic.py b/testing/example_scripts/collect/package_infinite_recursion/tests/test_basic.py index f17482385..2809d0cc6 100644 --- a/testing/example_scripts/collect/package_infinite_recursion/tests/test_basic.py +++ b/testing/example_scripts/collect/package_infinite_recursion/tests/test_basic.py @@ -1,2 +1,3 @@ +# mypy: allow-untyped-defs def test(): pass diff --git a/testing/example_scripts/collect/package_init_given_as_arg/pkg/__init__.py b/testing/example_scripts/collect/package_init_given_as_arg/pkg/__init__.py index 9cd366295..58c41942d 100644 --- a/testing/example_scripts/collect/package_init_given_as_arg/pkg/__init__.py +++ b/testing/example_scripts/collect/package_init_given_as_arg/pkg/__init__.py @@ -1,2 +1,3 @@ +# mypy: allow-untyped-defs def test_init(): pass diff --git a/testing/example_scripts/collect/package_init_given_as_arg/pkg/test_foo.py b/testing/example_scripts/collect/package_init_given_as_arg/pkg/test_foo.py index 8f2d73cfa..d88c001c2 100644 --- a/testing/example_scripts/collect/package_init_given_as_arg/pkg/test_foo.py +++ b/testing/example_scripts/collect/package_init_given_as_arg/pkg/test_foo.py @@ -1,2 +1,3 @@ +# mypy: allow-untyped-defs def test_foo(): pass diff --git a/testing/example_scripts/config/collect_pytest_prefix/test_foo.py b/testing/example_scripts/config/collect_pytest_prefix/test_foo.py index 8f2d73cfa..d88c001c2 100644 --- a/testing/example_scripts/config/collect_pytest_prefix/test_foo.py +++ b/testing/example_scripts/config/collect_pytest_prefix/test_foo.py @@ -1,2 +1,3 @@ +# mypy: allow-untyped-defs def test_foo(): pass diff --git a/testing/example_scripts/conftest_usageerror/conftest.py b/testing/example_scripts/conftest_usageerror/conftest.py index 8973e4252..64bbeefac 100644 --- a/testing/example_scripts/conftest_usageerror/conftest.py +++ b/testing/example_scripts/conftest_usageerror/conftest.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs def pytest_configure(config): import pytest diff --git a/testing/example_scripts/customdirectory/conftest.py b/testing/example_scripts/customdirectory/conftest.py index 5357014d7..fe1c743a6 100644 --- a/testing/example_scripts/customdirectory/conftest.py +++ b/testing/example_scripts/customdirectory/conftest.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # content of conftest.py import json diff --git a/testing/example_scripts/customdirectory/tests/test_first.py b/testing/example_scripts/customdirectory/tests/test_first.py index 0a78de599..890ca3dea 100644 --- a/testing/example_scripts/customdirectory/tests/test_first.py +++ b/testing/example_scripts/customdirectory/tests/test_first.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # content of test_first.py def test_1(): pass diff --git a/testing/example_scripts/customdirectory/tests/test_second.py b/testing/example_scripts/customdirectory/tests/test_second.py index eed724a7d..42108d5da 100644 --- a/testing/example_scripts/customdirectory/tests/test_second.py +++ b/testing/example_scripts/customdirectory/tests/test_second.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # content of test_second.py def test_2(): pass diff --git a/testing/example_scripts/customdirectory/tests/test_third.py b/testing/example_scripts/customdirectory/tests/test_third.py index 61cf59dc1..ede0f3e60 100644 --- a/testing/example_scripts/customdirectory/tests/test_third.py +++ b/testing/example_scripts/customdirectory/tests/test_third.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs # content of test_third.py def test_3(): pass diff --git a/testing/example_scripts/dataclasses/test_compare_initvar.py b/testing/example_scripts/dataclasses/test_compare_initvar.py index d859634dd..d687fc225 100644 --- a/testing/example_scripts/dataclasses/test_compare_initvar.py +++ b/testing/example_scripts/dataclasses/test_compare_initvar.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from dataclasses import dataclass from dataclasses import InitVar diff --git a/testing/example_scripts/dataclasses/test_compare_recursive_dataclasses.py b/testing/example_scripts/dataclasses/test_compare_recursive_dataclasses.py index 0945790f0..801aa0a73 100644 --- a/testing/example_scripts/dataclasses/test_compare_recursive_dataclasses.py +++ b/testing/example_scripts/dataclasses/test_compare_recursive_dataclasses.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from dataclasses import dataclass diff --git a/testing/example_scripts/doctest/main_py/__main__.py b/testing/example_scripts/doctest/main_py/__main__.py index e471d06d6..c8a124f54 100644 --- a/testing/example_scripts/doctest/main_py/__main__.py +++ b/testing/example_scripts/doctest/main_py/__main__.py @@ -1,2 +1,3 @@ +# mypy: allow-untyped-defs def test_this_is_ignored(): assert True diff --git a/testing/example_scripts/doctest/main_py/test_normal_module.py b/testing/example_scripts/doctest/main_py/test_normal_module.py index 700cc9750..26a4d90bc 100644 --- a/testing/example_scripts/doctest/main_py/test_normal_module.py +++ b/testing/example_scripts/doctest/main_py/test_normal_module.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs def test_doc(): """ >>> 10 > 5 diff --git a/testing/example_scripts/fixtures/custom_item/conftest.py b/testing/example_scripts/fixtures/custom_item/conftest.py index a7a5e9db8..fe1ae620a 100644 --- a/testing/example_scripts/fixtures/custom_item/conftest.py +++ b/testing/example_scripts/fixtures/custom_item/conftest.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/example_scripts/fixtures/custom_item/foo/test_foo.py b/testing/example_scripts/fixtures/custom_item/foo/test_foo.py index f17482385..2809d0cc6 100644 --- a/testing/example_scripts/fixtures/custom_item/foo/test_foo.py +++ b/testing/example_scripts/fixtures/custom_item/foo/test_foo.py @@ -1,2 +1,3 @@ +# mypy: allow-untyped-defs def test(): pass diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/conftest.py b/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/conftest.py index be5adbeb6..3a5d3ac33 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/conftest.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/conftest.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/test_in_sub1.py b/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/test_in_sub1.py index df36da136..d0c4bdbdf 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/test_in_sub1.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/test_in_sub1.py @@ -1,2 +1,3 @@ +# mypy: allow-untyped-defs def test_1(arg1): pass diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/conftest.py b/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/conftest.py index 00981c5dc..a1f3b2d58 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/conftest.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/conftest.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/test_in_sub2.py b/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/test_in_sub2.py index 1c34f94ac..45e974478 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/test_in_sub2.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/test_in_sub2.py @@ -1,2 +1,3 @@ +# mypy: allow-untyped-defs def test_2(arg2): pass diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_detect_recursive_dependency_error.py b/testing/example_scripts/fixtures/fill_fixtures/test_detect_recursive_dependency_error.py index d1efcbb33..84e5256f0 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_detect_recursive_dependency_error.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_detect_recursive_dependency_error.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/conftest.py b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/conftest.py index 5dfd2f779..7f1769beb 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/conftest.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/conftest.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/conftest.py b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/conftest.py index 4e22ce5a1..ad26fdd8c 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/conftest.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/conftest.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/test_spam.py b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/test_spam.py index 0d891fbb5..9ee74a471 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/test_spam.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/test_spam.py @@ -1,2 +1,3 @@ +# mypy: allow-untyped-defs def test_spam(spam): assert spam == "spamspam" diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/conftest.py b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/conftest.py index 5dfd2f779..7f1769beb 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/conftest.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/conftest.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/test_extend_fixture_conftest_module.py b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/test_extend_fixture_conftest_module.py index 46d1446f4..fa688f0a8 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/test_extend_fixture_conftest_module.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/test_extend_fixture_conftest_module.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_module_class.py b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_module_class.py index 87a0c8941..f78a57c32 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_module_class.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_module_class.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_basic.py b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_basic.py index 0661cb301..12e0e3e91 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_basic.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_basic.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_classlevel.py b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_classlevel.py index 256b92a17..8b6e8697e 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_classlevel.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_classlevel.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_modulelevel.py b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_modulelevel.py index e15dbd2ca..40587cf2b 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_modulelevel.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_modulelevel.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookupfails.py b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookupfails.py index b77520323..0cc8446d8 100644 --- a/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookupfails.py +++ b/testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookupfails.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/example_scripts/fixtures/test_fixture_named_request.py b/testing/example_scripts/fixtures/test_fixture_named_request.py index 75514bf8b..a2ab7ee33 100644 --- a/testing/example_scripts/fixtures/test_fixture_named_request.py +++ b/testing/example_scripts/fixtures/test_fixture_named_request.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/example_scripts/fixtures/test_getfixturevalue_dynamic.py b/testing/example_scripts/fixtures/test_getfixturevalue_dynamic.py index 055a1220b..0f316f0e4 100644 --- a/testing/example_scripts/fixtures/test_getfixturevalue_dynamic.py +++ b/testing/example_scripts/fixtures/test_getfixturevalue_dynamic.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/example_scripts/issue88_initial_file_multinodes/conftest.py b/testing/example_scripts/issue88_initial_file_multinodes/conftest.py index 0598eb841..bde5c0711 100644 --- a/testing/example_scripts/issue88_initial_file_multinodes/conftest.py +++ b/testing/example_scripts/issue88_initial_file_multinodes/conftest.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/example_scripts/issue88_initial_file_multinodes/test_hello.py b/testing/example_scripts/issue88_initial_file_multinodes/test_hello.py index 56444d147..dd18e1741 100644 --- a/testing/example_scripts/issue88_initial_file_multinodes/test_hello.py +++ b/testing/example_scripts/issue88_initial_file_multinodes/test_hello.py @@ -1,2 +1,3 @@ +# mypy: allow-untyped-defs def test_hello(): pass diff --git a/testing/example_scripts/issue_519.py b/testing/example_scripts/issue_519.py index 73437ef7b..397661644 100644 --- a/testing/example_scripts/issue_519.py +++ b/testing/example_scripts/issue_519.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pprint from typing import List from typing import Tuple diff --git a/testing/example_scripts/marks/marks_considered_keywords/test_marks_as_keywords.py b/testing/example_scripts/marks/marks_considered_keywords/test_marks_as_keywords.py index 35a2c7b76..d95ad0a83 100644 --- a/testing/example_scripts/marks/marks_considered_keywords/test_marks_as_keywords.py +++ b/testing/example_scripts/marks/marks_considered_keywords/test_marks_as_keywords.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/example_scripts/perf_examples/collect_stats/generate_folders.py b/testing/example_scripts/perf_examples/collect_stats/generate_folders.py index ff1eaf7d6..3d8e77e88 100644 --- a/testing/example_scripts/perf_examples/collect_stats/generate_folders.py +++ b/testing/example_scripts/perf_examples/collect_stats/generate_folders.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import argparse import pathlib diff --git a/testing/example_scripts/perf_examples/collect_stats/template_test.py b/testing/example_scripts/perf_examples/collect_stats/template_test.py index 064ade190..f50eb6552 100644 --- a/testing/example_scripts/perf_examples/collect_stats/template_test.py +++ b/testing/example_scripts/perf_examples/collect_stats/template_test.py @@ -1,2 +1,3 @@ +# mypy: allow-untyped-defs def test_x(): pass diff --git a/testing/example_scripts/tmpdir/tmp_path_fixture.py b/testing/example_scripts/tmpdir/tmp_path_fixture.py index 8675eb2fa..4aa35faa0 100644 --- a/testing/example_scripts/tmpdir/tmp_path_fixture.py +++ b/testing/example_scripts/tmpdir/tmp_path_fixture.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/example_scripts/unittest/test_parametrized_fixture_error_message.py b/testing/example_scripts/unittest/test_parametrized_fixture_error_message.py index d421ce927..d66b66df5 100644 --- a/testing/example_scripts/unittest/test_parametrized_fixture_error_message.py +++ b/testing/example_scripts/unittest/test_parametrized_fixture_error_message.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import unittest import pytest diff --git a/testing/example_scripts/unittest/test_setup_skip.py b/testing/example_scripts/unittest/test_setup_skip.py index 93f79bb3b..4681cda03 100644 --- a/testing/example_scripts/unittest/test_setup_skip.py +++ b/testing/example_scripts/unittest/test_setup_skip.py @@ -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 diff --git a/testing/example_scripts/unittest/test_setup_skip_class.py b/testing/example_scripts/unittest/test_setup_skip_class.py index 4f251dcba..eae98287f 100644 --- a/testing/example_scripts/unittest/test_setup_skip_class.py +++ b/testing/example_scripts/unittest/test_setup_skip_class.py @@ -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 diff --git a/testing/example_scripts/unittest/test_setup_skip_module.py b/testing/example_scripts/unittest/test_setup_skip_module.py index 98befbe51..43c24136e 100644 --- a/testing/example_scripts/unittest/test_setup_skip_module.py +++ b/testing/example_scripts/unittest/test_setup_skip_module.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """setUpModule is always called, even if all tests in the module are skipped""" import unittest diff --git a/testing/example_scripts/unittest/test_unittest_asyncio.py b/testing/example_scripts/unittest/test_unittest_asyncio.py index 1cd216860..a82ddaebc 100644 --- a/testing/example_scripts/unittest/test_unittest_asyncio.py +++ b/testing/example_scripts/unittest/test_unittest_asyncio.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import List from unittest import IsolatedAsyncioTestCase diff --git a/testing/example_scripts/unittest/test_unittest_asynctest.py b/testing/example_scripts/unittest/test_unittest_asynctest.py index fb2661706..b3f03e325 100644 --- a/testing/example_scripts/unittest/test_unittest_asynctest.py +++ b/testing/example_scripts/unittest/test_unittest_asynctest.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Issue #7110""" import asyncio from typing import List diff --git a/testing/example_scripts/unittest/test_unittest_plain_async.py b/testing/example_scripts/unittest/test_unittest_plain_async.py index 78dfece68..2a4a66509 100644 --- a/testing/example_scripts/unittest/test_unittest_plain_async.py +++ b/testing/example_scripts/unittest/test_unittest_plain_async.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import unittest diff --git a/testing/example_scripts/warnings/test_group_warnings_by_message.py b/testing/example_scripts/warnings/test_group_warnings_by_message.py index 6985caa44..be64a1ff2 100644 --- a/testing/example_scripts/warnings/test_group_warnings_by_message.py +++ b/testing/example_scripts/warnings/test_group_warnings_by_message.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import warnings import pytest diff --git a/testing/example_scripts/warnings/test_group_warnings_by_message_summary/test_1.py b/testing/example_scripts/warnings/test_group_warnings_by_message_summary/test_1.py index b8c11cb71..95fa795ef 100644 --- a/testing/example_scripts/warnings/test_group_warnings_by_message_summary/test_1.py +++ b/testing/example_scripts/warnings/test_group_warnings_by_message_summary/test_1.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import warnings import pytest diff --git a/testing/example_scripts/warnings/test_group_warnings_by_message_summary/test_2.py b/testing/example_scripts/warnings/test_group_warnings_by_message_summary/test_2.py index 636d04a55..5204fde8a 100644 --- a/testing/example_scripts/warnings/test_group_warnings_by_message_summary/test_2.py +++ b/testing/example_scripts/warnings/test_group_warnings_by_message_summary/test_2.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from test_1 import func diff --git a/testing/freeze/tests/test_trivial.py b/testing/freeze/tests/test_trivial.py index 08a55552a..425f29a64 100644 --- a/testing/freeze/tests/test_trivial.py +++ b/testing/freeze/tests/test_trivial.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs def test_upper(): assert "foo".upper() == "FOO" diff --git a/testing/io/test_saferepr.py b/testing/io/test_saferepr.py index d94faa4f1..4091747d5 100644 --- a/testing/io/test_saferepr.py +++ b/testing/io/test_saferepr.py @@ -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 diff --git a/testing/io/test_terminalwriter.py b/testing/io/test_terminalwriter.py index c7e63c672..a13f9a4bc 100644 --- a/testing/io/test_terminalwriter.py +++ b/testing/io/test_terminalwriter.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import io import os import re diff --git a/testing/logging/test_reporting.py b/testing/logging/test_reporting.py index 5d10688a0..92fd72300 100644 --- a/testing/logging/test_reporting.py +++ b/testing/logging/test_reporting.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import io import os import re diff --git a/testing/plugins_integration/bdd_wallet.py b/testing/plugins_integration/bdd_wallet.py index 35927ea58..2bdb15454 100644 --- a/testing/plugins_integration/bdd_wallet.py +++ b/testing/plugins_integration/bdd_wallet.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from pytest_bdd import given from pytest_bdd import scenario from pytest_bdd import then diff --git a/testing/plugins_integration/pytest_anyio_integration.py b/testing/plugins_integration/pytest_anyio_integration.py index 65c2f5936..383d7a0b5 100644 --- a/testing/plugins_integration/pytest_anyio_integration.py +++ b/testing/plugins_integration/pytest_anyio_integration.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import anyio import pytest diff --git a/testing/plugins_integration/pytest_asyncio_integration.py b/testing/plugins_integration/pytest_asyncio_integration.py index 5d2a3facc..b216c4bee 100644 --- a/testing/plugins_integration/pytest_asyncio_integration.py +++ b/testing/plugins_integration/pytest_asyncio_integration.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import asyncio import pytest diff --git a/testing/plugins_integration/pytest_mock_integration.py b/testing/plugins_integration/pytest_mock_integration.py index 740469d00..5494c4427 100644 --- a/testing/plugins_integration/pytest_mock_integration.py +++ b/testing/plugins_integration/pytest_mock_integration.py @@ -1,2 +1,3 @@ +# mypy: allow-untyped-defs def test_mocker(mocker): mocker.MagicMock() diff --git a/testing/plugins_integration/pytest_trio_integration.py b/testing/plugins_integration/pytest_trio_integration.py index 199f7850b..60f48ec60 100644 --- a/testing/plugins_integration/pytest_trio_integration.py +++ b/testing/plugins_integration/pytest_trio_integration.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import trio import pytest diff --git a/testing/plugins_integration/pytest_twisted_integration.py b/testing/plugins_integration/pytest_twisted_integration.py index 94748d036..0dbf5faeb 100644 --- a/testing/plugins_integration/pytest_twisted_integration.py +++ b/testing/plugins_integration/pytest_twisted_integration.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest_twisted from twisted.internet.task import deferLater diff --git a/testing/plugins_integration/simple_integration.py b/testing/plugins_integration/simple_integration.py index 20b2fc4b5..48089afcc 100644 --- a/testing/plugins_integration/simple_integration.py +++ b/testing/plugins_integration/simple_integration.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest diff --git a/testing/python/approx.py b/testing/python/approx.py index 3b87e58f9..132855b04 100644 --- a/testing/python/approx.py +++ b/testing/python/approx.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import operator from contextlib import contextmanager from decimal import Decimal diff --git a/testing/python/collect.py b/testing/python/collect.py index da11dd34a..683b62812 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import os import sys import textwrap diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index 81aa2bcc7..d232742ea 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import os import sys import textwrap @@ -4403,7 +4404,7 @@ def test_fixture_named_request(pytester: Pytester) -> None: result.stdout.fnmatch_lines( [ "*'request' is a reserved word for fixtures, use another name:", - " *test_fixture_named_request.py:5", + " *test_fixture_named_request.py:6", ] ) diff --git a/testing/python/integration.py b/testing/python/integration.py index 054c14a39..dbe1b1a00 100644 --- a/testing/python/integration.py +++ b/testing/python/integration.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest from _pytest._code import getfslineno from _pytest.fixtures import getfixturemarker diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index 9393c9727..8f41975f3 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import dataclasses import itertools import re diff --git a/testing/python/raises.py b/testing/python/raises.py index 3dcec31eb..47b22f28a 100644 --- a/testing/python/raises.py +++ b/testing/python/raises.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import re import sys diff --git a/testing/test_argcomplete.py b/testing/test_argcomplete.py index 8c10e230b..6813d8f13 100644 --- a/testing/test_argcomplete.py +++ b/testing/test_argcomplete.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import subprocess import sys from pathlib import Path diff --git a/testing/test_assertion.py b/testing/test_assertion.py index e55ec38e1..640890e9a 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import collections import sys import textwrap diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index a4d48b6fe..a4386b3a8 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import ast import errno import glob diff --git a/testing/test_cacheprovider.py b/testing/test_cacheprovider.py index 21c1957cf..73f5687d3 100644 --- a/testing/test_cacheprovider.py +++ b/testing/test_cacheprovider.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import os import shutil from pathlib import Path diff --git a/testing/test_capture.py b/testing/test_capture.py index b6ea81613..c49eeb673 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import contextlib import io import os diff --git a/testing/test_collection.py b/testing/test_collection.py index be65169f7..f1552b6ae 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import os import pprint import shutil diff --git a/testing/test_compat.py b/testing/test_compat.py index 27c6db95b..53d3df14a 100644 --- a/testing/test_compat.py +++ b/testing/test_compat.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import enum import sys from functools import cached_property diff --git a/testing/test_config.py b/testing/test_config.py index 1eb530ace..45bcce4ea 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import dataclasses import importlib.metadata import os diff --git a/testing/test_conftest.py b/testing/test_conftest.py index e74190727..33d2e38dc 100644 --- a/testing/test_conftest.py +++ b/testing/test_conftest.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import os import textwrap from pathlib import Path diff --git a/testing/test_debugging.py b/testing/test_debugging.py index ea3367e57..1cd46ae48 100644 --- a/testing/test_debugging.py +++ b/testing/test_debugging.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import os import sys from typing import List diff --git a/testing/test_doctest.py b/testing/test_doctest.py index f4d3155c4..110e0557c 100644 --- a/testing/test_doctest.py +++ b/testing/test_doctest.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import inspect import sys import textwrap diff --git a/testing/test_entry_points.py b/testing/test_entry_points.py index dfb3d57d2..68e3a8a92 100644 --- a/testing/test_entry_points.py +++ b/testing/test_entry_points.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import importlib.metadata diff --git a/testing/test_faulthandler.py b/testing/test_faulthandler.py index 5b7911f21..22545ea21 100644 --- a/testing/test_faulthandler.py +++ b/testing/test_faulthandler.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import io import sys diff --git a/testing/test_findpaths.py b/testing/test_findpaths.py index 65370a0ba..0759ba551 100644 --- a/testing/test_findpaths.py +++ b/testing/test_findpaths.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import os from pathlib import Path from textwrap import dedent diff --git a/testing/test_helpconfig.py b/testing/test_helpconfig.py index ba89d0c4a..272d4d290 100644 --- a/testing/test_helpconfig.py +++ b/testing/test_helpconfig.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest from _pytest.config import ExitCode from _pytest.pytester import Pytester diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index b0c2d1c6d..88749c0c8 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import os import platform from datetime import datetime diff --git a/testing/test_legacypath.py b/testing/test_legacypath.py index 700499f24..72899b60d 100644 --- a/testing/test_legacypath.py +++ b/testing/test_legacypath.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from pathlib import Path import pytest diff --git a/testing/test_link_resolve.py b/testing/test_link_resolve.py index 1ac3afd09..c9d307f88 100644 --- a/testing/test_link_resolve.py +++ b/testing/test_link_resolve.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import os.path import subprocess import sys diff --git a/testing/test_main.py b/testing/test_main.py index 3c8998c1a..b1abf2c71 100644 --- a/testing/test_main.py +++ b/testing/test_main.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import argparse import os import re diff --git a/testing/test_mark.py b/testing/test_mark.py index 609f73d68..45acf0504 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import os import sys from typing import List diff --git a/testing/test_monkeypatch.py b/testing/test_monkeypatch.py index 8175b5f0f..3a1045d67 100644 --- a/testing/test_monkeypatch.py +++ b/testing/test_monkeypatch.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import os import re import sys diff --git a/testing/test_nodes.py b/testing/test_nodes.py index 1de0f995e..4efb39e03 100644 --- a/testing/test_nodes.py +++ b/testing/test_nodes.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import re import warnings from pathlib import Path diff --git a/testing/test_parseopt.py b/testing/test_parseopt.py index 2a6291984..b2d547931 100644 --- a/testing/test_parseopt.py +++ b/testing/test_parseopt.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import argparse import locale import os diff --git a/testing/test_pastebin.py b/testing/test_pastebin.py index 86b231f8b..277454f9b 100644 --- a/testing/test_pastebin.py +++ b/testing/test_pastebin.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import email.message import io from typing import List diff --git a/testing/test_pathlib.py b/testing/test_pathlib.py index 3e1d2265b..99cd48503 100644 --- a/testing/test_pathlib.py +++ b/testing/test_pathlib.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import errno import os.path import pickle diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index 8bafde338..ea44d8748 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import os import shutil import sys diff --git a/testing/test_pytester.py b/testing/test_pytester.py index 6fc6bd245..e35fb5294 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import os import subprocess import sys diff --git a/testing/test_python_path.py b/testing/test_python_path.py index dfef0f3fe..4054134b4 100644 --- a/testing/test_python_path.py +++ b/testing/test_python_path.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import sys from textwrap import dedent from typing import Generator diff --git a/testing/test_recwarn.py b/testing/test_recwarn.py index 2508e22a2..9d46c1fc8 100644 --- a/testing/test_recwarn.py +++ b/testing/test_recwarn.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import warnings from typing import List from typing import Optional diff --git a/testing/test_reports.py b/testing/test_reports.py index 627ea1ed2..ae2b68cdb 100644 --- a/testing/test_reports.py +++ b/testing/test_reports.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from typing import Sequence from typing import Union diff --git a/testing/test_runner.py b/testing/test_runner.py index 26f5b9a0b..d2007647e 100644 --- a/testing/test_runner.py +++ b/testing/test_runner.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import inspect import os import sys diff --git a/testing/test_runner_xunit.py b/testing/test_runner_xunit.py index e077ac41e..dbdb51d24 100644 --- a/testing/test_runner_xunit.py +++ b/testing/test_runner_xunit.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Test correct setup/teardowns at module, class, and instance level.""" from typing import List diff --git a/testing/test_session.py b/testing/test_session.py index 803bbed54..232e9c834 100644 --- a/testing/test_session.py +++ b/testing/test_session.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import pytest from _pytest.config import ExitCode from _pytest.monkeypatch import MonkeyPatch diff --git a/testing/test_setuponly.py b/testing/test_setuponly.py index fe4bdc514..0f70383a6 100644 --- a/testing/test_setuponly.py +++ b/testing/test_setuponly.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import sys import pytest diff --git a/testing/test_skipping.py b/testing/test_skipping.py index 86940baa6..346dfa44e 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import sys import textwrap diff --git a/testing/test_stepwise.py b/testing/test_stepwise.py index 85e38c7d5..4aa72d024 100644 --- a/testing/test_stepwise.py +++ b/testing/test_stepwise.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs from pathlib import Path import pytest diff --git a/testing/test_terminal.py b/testing/test_terminal.py index b521deea7..283722887 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """Terminal reporting of the full testing process.""" import collections import os diff --git a/testing/test_tmpdir.py b/testing/test_tmpdir.py index 2215e978a..42df66088 100644 --- a/testing/test_tmpdir.py +++ b/testing/test_tmpdir.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import dataclasses import os import stat diff --git a/testing/test_unittest.py b/testing/test_unittest.py index 24f954051..fc967d992 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import gc import sys from typing import List diff --git a/testing/test_warning_types.py b/testing/test_warning_types.py index 5f69439ef..0ea3f2976 100644 --- a/testing/test_warning_types.py +++ b/testing/test_warning_types.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import inspect import pytest diff --git a/testing/test_warnings.py b/testing/test_warnings.py index e7834dc4d..2f0ab9b54 100644 --- a/testing/test_warnings.py +++ b/testing/test_warnings.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs import os import sys import warnings @@ -623,11 +624,11 @@ def test_group_warnings_by_message_summary(pytester: Pytester) -> None: "*== %s ==*" % WARNINGS_SUMMARY_HEADER, "test_1.py: 21 warnings", "test_2.py: 1 warning", - " */test_1.py:7: UserWarning: foo", + " */test_1.py:8: UserWarning: foo", " warnings.warn(UserWarning(msg))", "", "test_1.py: 20 warnings", - " */test_1.py:7: UserWarning: bar", + " */test_1.py:8: UserWarning: bar", " warnings.warn(UserWarning(msg))", "", "-- Docs: *", diff --git a/testing/typing_checks.py b/testing/typing_checks.py index 57f2bae47..a2ceabcbd 100644 --- a/testing/typing_checks.py +++ b/testing/typing_checks.py @@ -1,3 +1,4 @@ +# mypy: allow-untyped-defs """File for checking typing issues. This file is not executed, it is only checked by mypy to ensure that