diff --git a/code_data/__init__.py b/code_data/__init__.py index c6f46e1..ad10bc4 100644 --- a/code_data/__init__.py +++ b/code_data/__init__.py @@ -1,6 +1,7 @@ """ Transform Python code objects into data, and vice versa. """ + from __future__ import annotations from collections import OrderedDict diff --git a/code_data/_flags_data.py b/code_data/_flags_data.py index d8cee99..7f145e3 100644 --- a/code_data/_flags_data.py +++ b/code_data/_flags_data.py @@ -2,6 +2,7 @@ We represent code flags as a set of literal strings, representing each compiler flag. """ + from __future__ import annotations import dis diff --git a/code_data/_line_mapping.py b/code_data/_line_mapping.py index 1319606..9d86432 100644 --- a/code_data/_line_mapping.py +++ b/code_data/_line_mapping.py @@ -184,9 +184,9 @@ def collapse_items(items: ExpandedItems, is_linetable: bool) -> CollapsedItems: """ collapsed_items = [ CollapsedLineTableItem( - line_offset=None - if is_linetable and i.line_offset == -128 - else i.line_offset, + line_offset=( + None if is_linetable and i.line_offset == -128 else i.line_offset + ), bytecode_offset=i.bytecode_offset, ) for i in items @@ -245,9 +245,11 @@ def expand_bytecode(): while bytecode_offset > MAX_BYTECODE: expanded_items.append( LineTableItem( - line_offset=(-128 if line_offset is None else line_offset) - if is_linetable - else 0, + line_offset=( + (-128 if line_offset is None else line_offset) + if is_linetable + else 0 + ), bytecode_offset=MAX_BYTECODE, ) ) diff --git a/code_data/_test_verify_code.py b/code_data/_test_verify_code.py index 455f47f..fbdcc7f 100644 --- a/code_data/_test_verify_code.py +++ b/code_data/_test_verify_code.py @@ -116,9 +116,11 @@ def code_to_primitives(code: CodeType) -> dict[str, object]: for a in code.co_consts ) if name == "co_consts" - else [(i.opname, i.argval) for i in _get_instructions_bytes(code.co_code)] - if name == "co_code" - else getattr(code, name) + else ( + [(i.opname, i.argval) for i in _get_instructions_bytes(code.co_code)] + if name == "co_code" + else getattr(code, name) + ) ) for name in code_attributes }