Skip to content

Commit

Permalink
Only interrupt run_config() for explicitly passed config_file
Browse files Browse the repository at this point in the history
  • Loading branch information
tony authored and jonathanslenders committed Nov 3, 2023
1 parent 48c7b38 commit d25e678
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ptpython/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,23 +630,28 @@ def enable_deprecation_warnings() -> None:
warnings.filterwarnings("default", category=DeprecationWarning, module="__main__")


def run_config(
repl: PythonInput, config_file: str = "~/.config/ptpython/config.py"
) -> None:
DEFAULT_CONFIG_FILE = "~/.config/ptpython/config.py"


def run_config(repl: PythonInput, config_file: str | None = None) -> None:
"""
Execute REPL config file.
:param repl: `PythonInput` instance.
:param config_file: Path of the configuration file.
"""
explicit_config_file = config_file is not None

# Expand tildes.
config_file = os.path.expanduser(config_file)
config_file = os.path.expanduser(
config_file if config_file is not None else DEFAULT_CONFIG_FILE
)

def enter_to_continue() -> None:
input("\nPress ENTER to continue...")

# Check whether this file exists.
if not os.path.exists(config_file):
if not os.path.exists(config_file) and explicit_config_file:
print("Impossible to read %r" % config_file)
enter_to_continue()
return
Expand Down

0 comments on commit d25e678

Please sign in to comment.