Skip to content
Snippets Groups Projects
Commit 0b470dfc authored by Philip Elson's avatar Philip Elson :snake:
Browse files

Add a test which uses a forward reference as a type annotation of an argument

parent 2dc9ce5d
No related branches found
No related tags found
1 merge request!10Add a test which uses a forward reference as a type annotation of an argument
[case testArgumentTypeDeclaration]
import jpype
import typing
if typing.TYPE_CHECKING:
import java.util
def foo(arg: "java.util.Formatter"):
reveal_type(arg) # N: Revealed type is "java.util.Formatter"
......@@ -15,4 +15,3 @@ java = jpype.JPackage("java")
int_list: typing.List[int] = [42]
reveal_type(java.util.ArrayList(int_list)) # N: Revealed type is "java.util.ArrayList[Any]"
......@@ -43,9 +43,20 @@ def setup_mypy_for_data_driven_tests(stub_tmpdir: str):
def test_generate_stubs(stub_tmpdir):
import java.util # noqa
stubgenj.generateJavaStubs([java.util], useStubsSuffix=True, outputDir=stub_tmpdir)
stubgenj.generateJavaStubs(
[java.util],
useStubsSuffix=True, outputDir=stub_tmpdir,
)
@pytest.mark.trylast
class StubTestSuite(mypy.test.testcheck.TypeCheckSuite):
files = ['arraylist.test', 'hashmap.test', 'enummap.test', 'callbacks.test', 'jpype_jpackage.test', 'varargs.test']
files = [
'arraylist.test',
'callbacks.test',
'enummap.test',
'forward_declaration.test',
'hashmap.test',
'jpype_jpackage.test',
'varargs.test',
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment