Coverage for pyfields/tests/issues/_test_py36_pep563.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-11-06 16:35 +0000

1from __future__ import annotations # python 3.10 behaviour see https://www.python.org/dev/peps/pep-0563/ 

2from pyfields import field 

3 

4 

5def test_issue_73(): 

6 class Foo: 

7 bar: Foo = field(check_type=True, nonable=True) 

8 return Foo 

9 

10 

11class A: 

12 bar: B = field(check_type=True, nonable=True) 

13 

14class B: 

15 bar: A = field(check_type=True, nonable=True) 

16 

17 

18def test_issue_73_cross_ref(): 

19 # note: we have to define the classes outside the function for the cross-ref to work 

20 # indeed typing.get_type_hints() will only access the globals of the defining module 

21 return A, B