Skip to content

Commit

Permalink
Satisfy mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
eskildsf committed Dec 23, 2024
1 parent d09e75e commit fff005a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion reloading/reloading.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def get_diff_text(ast_before: ast.Module, ast_after: ast.Module):
Calculate difference between two versions of reloaded code.
"""
# Unparse was introduced in Python 3.9.
if sys.version_info.major >= 3 and sys.version_info.minor >= 9:
if all([sys.version_info.major >= 3,
sys.version_info.minor >= 9,
hasattr(ast, "unparse")]):
code_before = ast.unparse(ast_before)
code_after = ast.unparse(ast_after)
diff = difflib.unified_diff(code_before.splitlines(),
Expand Down

0 comments on commit fff005a

Please sign in to comment.