Skip to content

Commit ab62dc8

Browse files
committed
Revert "Update shell_utils.py"
This reverts commit c28feb4.
1 parent c28feb4 commit ab62dc8

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

codeflash/code_utils/shell_utils.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
from __future__ import annotations
2-
31
import os
42
import re
53
from pathlib import Path
6-
from typing import TYPE_CHECKING, Optional
4+
from typing import Optional
75

86
from codeflash.code_utils.compat import LF
9-
from codeflash.either import Failure, Success
10-
11-
if TYPE_CHECKING:
12-
from codeflash.either import Result
7+
from codeflash.either import Failure, Result, Success
138

149
if os.name == "nt": # Windows
1510
SHELL_RC_EXPORT_PATTERN = re.compile(r"^set CODEFLASH_API_KEY=(cf-.*)$", re.MULTILINE)
@@ -22,7 +17,7 @@
2217
def read_api_key_from_shell_config() -> Optional[str]:
2318
try:
2419
shell_rc_path = get_shell_rc_path()
25-
with shell_rc_path.open(encoding="utf8") as shell_rc:
20+
with open(shell_rc_path, encoding="utf8") as shell_rc:
2621
shell_contents = shell_rc.read()
2722
matches = SHELL_RC_EXPORT_PATTERN.findall(shell_contents)
2823
return matches[-1] if matches else None
@@ -45,11 +40,11 @@ def get_api_key_export_line(api_key: str) -> str:
4540
return f"{SHELL_RC_EXPORT_PREFIX}{api_key}"
4641

4742

48-
def save_api_key_to_rc(api_key: str) -> Result[str, str]:
43+
def save_api_key_to_rc(api_key) -> Result[str, str]:
4944
shell_rc_path = get_shell_rc_path()
5045
api_key_line = get_api_key_export_line(api_key)
5146
try:
52-
with shell_rc_path.open("r+", encoding="utf8") as shell_file:
47+
with open(shell_rc_path, "r+", encoding="utf8") as shell_file:
5348
shell_contents = shell_file.read()
5449
if os.name == "nt" and not shell_contents: # on windows we're writing to a batch file
5550
shell_contents = "@echo off"

0 commit comments

Comments
 (0)