Fix a lot of test related typing issues

This commit is contained in:
Dave Halter
2026-02-10 19:38:55 +01:00
parent 6903bc25d5
commit 8cbb817b12
20 changed files with 47 additions and 40 deletions
+2 -2
View File
@@ -11,14 +11,14 @@ import jedi
from ..helpers import test_dir
try:
import numpydoc # NOQA
import numpydoc # type: ignore[import-not-found] # NOQA
except ImportError:
numpydoc_unavailable = True
else:
numpydoc_unavailable = False
try:
import numpy # NOQA
import numpy # type: ignore[import-not-found] # NOQA
except ImportError:
numpy_unavailable = True
else:
@@ -222,7 +222,7 @@ def test_goto_stubs_on_itself(Script, code, type_):
def test_module_exists_only_as_stub(Script):
try:
import redis # noqa: F401
import redis # type: ignore[import-untyped] # noqa: F401
except ImportError:
pass
else:
+2 -2
View File
@@ -30,13 +30,13 @@ def test_find_module_basic():
def test_find_module_package():
file_io, is_package = _find_module('json')
assert file_io.path.parts[-2:] == ('json', '__init__.py')
assert file_io.path.parts[-2:] == ('json', '__init__.py') # type: ignore[union-attr]
assert is_package is True
def test_find_module_not_package():
file_io, is_package = _find_module('io')
assert file_io.path.name == 'io.py'
assert file_io.path.name == 'io.py' # type: ignore[union-attr]
assert is_package is False
+4 -4
View File
@@ -56,10 +56,10 @@ def test_generics_methods(code, expected, class_findable):
class Reader(Generic[T]):
@classmethod
def read(cls) -> T:
return cls()
return cls() # type: ignore[return-value]
def method(self) -> T:
return 1
return 1 # type: ignore[return-value]
class Foo(Reader[str]):
def transform(self) -> int:
@@ -94,7 +94,7 @@ def test_signature():
pass
from inspect import Signature, Parameter
some_signature.__signature__ = Signature([
some_signature.__signature__ = Signature([ # type: ignore[attr-defined]
Parameter('bar', kind=Parameter.KEYWORD_ONLY, default=1)
])
@@ -105,7 +105,7 @@ def test_signature():
def test_compiled_signature_annotation_string():
import typing
def func(x: typing.Type, y: typing.Union[typing.Type, int]):
def func(x: typing.Type, y: typing.Union[typing.Type, int]): # type: ignore[type-arg]
pass
func.__name__ = 'not_func'
+2 -1
View File
@@ -2,6 +2,7 @@ from textwrap import dedent
from operator import eq, ge, lt
import re
import os
from typing import Any
import pytest
@@ -448,7 +449,7 @@ def test_dataclass_signature(
assert price.name == price_type_infer
dataclass_transform_cases = [
dataclass_transform_cases: list[Any] = [
# Attributes on the decorated class and its base classes
# are not considered to be fields.
# 1/ Declare dataclass transformer