Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
refactor: use future annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Mar 23, 2022
1 parent 5b017b3 commit 5f3e4d2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions remove_print_statements.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from dataclasses import dataclass
from typing import List, Tuple, Union

import click
import libcst as cst
Expand Down Expand Up @@ -70,7 +71,7 @@ def __str__(self) -> str:
removed = "removed"
failed = "failed to transform"

report: List[str] = []
report: list[str] = []
if self.file_count:
s = "s" if self.file_count > 1 else ""
report.append(
Expand Down Expand Up @@ -137,7 +138,7 @@ def visit_Expr(self, node: cst.Expr) -> None:
@m.call_if_inside(PRINT_STATEMENT)
def leave_Expr(
self, original_node: cst.Expr, updated_node: cst.Expr
) -> Union[cst.Expr, cst.RemovalSentinel]:
) -> cst.Expr | cst.RemovalSentinel:
if self.dry_run:
return updated_node
return cst.RemoveFromParent()
Expand All @@ -159,7 +160,7 @@ def check_file(
verbose: If True, output all the print statements along with their location.
"""
try:
with open(filename, "r") as f:
with open(filename) as f:
code = f.read()
except Exception as exc:
click.secho(f"Could not read file {filename!r}, skipping: {exc}", fg="red")
Expand Down Expand Up @@ -235,8 +236,8 @@ def main(
ctx: click.Context,
dry_run: bool,
verbose: bool,
ignore: Tuple[str, ...],
filenames: Tuple[str, ...],
ignore: tuple[str, ...],
filenames: tuple[str, ...],
) -> None:
"""Remove all the print statements from your Python project.
Expand Down

0 comments on commit 5f3e4d2

Please sign in to comment.