(annotate, owner, is_class, stringifier_dict, *, allow_evaluation)
| 851 | |
| 852 | |
| 853 | def _build_closure(annotate, owner, is_class, stringifier_dict, *, allow_evaluation): |
| 854 | if not annotate.__closure__: |
| 855 | return None, None |
| 856 | new_closure = [] |
| 857 | cell_dict = {} |
| 858 | for name, cell in zip(annotate.__code__.co_freevars, annotate.__closure__, strict=True): |
| 859 | cell_dict[name] = cell |
| 860 | new_cell = None |
| 861 | if allow_evaluation: |
| 862 | try: |
| 863 | cell.cell_contents |
| 864 | except ValueError: |
| 865 | pass |
| 866 | else: |
| 867 | new_cell = cell |
| 868 | if new_cell is None: |
| 869 | fwdref = _Stringifier( |
| 870 | name, |
| 871 | cell=cell, |
| 872 | owner=owner, |
| 873 | globals=annotate.__globals__, |
| 874 | is_class=is_class, |
| 875 | stringifier_dict=stringifier_dict, |
| 876 | ) |
| 877 | stringifier_dict.stringifiers.append(fwdref) |
| 878 | new_cell = types.CellType(fwdref) |
| 879 | new_closure.append(new_cell) |
| 880 | return tuple(new_closure), cell_dict |
| 881 | |
| 882 | |
| 883 | def _stringify_single(anno): |
no test coverage detected
searching dependent graphs…