Skip to content

Commit 0aeb6ca

Browse files
authored
Merge pull request #1954 from dbcli/RW/no-cwd-myclirc
Remove implicit read of `.myclirc` files in the current working directory
2 parents 19ee47b + 315b36e commit 0aeb6ca

5 files changed

Lines changed: 39 additions & 44 deletions

File tree

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Breaking Changes
99
* Remove support for `--ssl/--no-ssl` CLI arguments in favor of `--ssl-mode`.
1010
* Remove support for deprecated SSH jump functionality.
1111
* Remove support for `my.cnf` vendor MySQL option files.
12+
* Remove support for `.myclirc` files in the current working directory.
1213

1314

1415
Documentation

mycli/client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ class MyCli(AppStateMixin, OutputMixin, ClientCommandsMixin, ClientConnectionMix
6161
os.path.join(os.path.expanduser(xdg_config_home), "mycli", "myclirc"),
6262
]
6363

64-
pwd_config_file = os.path.join(os.getcwd(), ".myclirc")
65-
6664
def __init__(
6765
self,
6866
sqlexecute: SQLExecute | None = None,
@@ -87,7 +85,7 @@ def __init__(
8785
self.checkpoint: IO | None = None
8886

8987
# Load config.
90-
config_files: list[str | IO[str]] = self.system_config_files + [myclirc] + [self.pwd_config_file]
88+
config_files: list[str | IO[str]] = self.system_config_files + [myclirc]
9189

9290
c = self.config = read_config_files(config_files)
9391
# only needed in --checkup mode. todo: only load when needed

test/myclirc

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ prefetch_schemas_mode = always
2222

2323
# Comma-separated list of schemas to prefetch when
2424
# prefetch_schemas_mode = listed. Ignored in other modes.
25-
prefetch_schemas_list =
25+
prefetch_schemas_list = ""
2626

2727
# Expand whole DSN alias values in the form ${VAR} from the environment.
2828
expand_dsn_alias_env_vars = False
@@ -57,7 +57,7 @@ log_level = DEBUG
5757
# line below.
5858
# audit_log = ~/.mycli-audit.log
5959

60-
# Timing of sql statements and table rendering.
60+
# Timing of SQL statements and table rendering, or LLM commands.
6161
timing = True
6262

6363
# Show the full SQL when running a favorite query. Set to False to hide.
@@ -143,7 +143,7 @@ wider_completion_menu = False
143143
# ANSI color example: prompt = '\x1b[31mroot\x1b[0m@localhost:\d> '
144144
# * \<html> - a leading sequence indicating that the rest of the prompt be styled like HTML.
145145
# See https://python-prompt-toolkit.readthedocs.io/en/stable/pages/printing_text.html#html .
146-
# Characters such as "&" or literal "<" and ">" must be HTML-escaped in this mode
146+
# Characters such as "&" or literal "<" and ">" must be HTML-escaped in this mode.
147147
# HTML styles cannot be combined with ANSI sequences. HTML mode takes precedence.
148148
# HTML color example: prompt = '\<html><red><u>root</u></red>@localhost:\d&gt; '
149149
#
@@ -160,29 +160,29 @@ prompt_continuation = ->
160160
# lines can be added with \n. If \B is not included, the customized toolbar
161161
# can be a single line. An empty value is the same as the default "\B". The
162162
# special literal value "None" will suppress the toolbar from appearing.
163-
toolbar = ''
163+
toolbar = ""
164164

165165
# Use the same prompt format strings to construct a terminal tab title.
166166
# The original XTerm docs call this title the "window title", but it now
167167
# probably refers to a terminal tab. This title is only updated as frequently
168168
# as the database is changed.
169-
terminal_tab_title = ''
169+
terminal_tab_title = ""
170170

171171
# Use the same prompt format strings to construct a terminal window title.
172172
# The original XTerm docs call this title the "icon title", but it now
173173
# probably refers to a terminal window which contains tabs. This title is
174174
# only updated as frequently as the database is changed.
175-
terminal_window_title = ''
175+
terminal_window_title = ""
176176

177177
# Use the same prompt format strings to construct a window title in a terminal
178178
# multiplexer. Currently only tmux is supported. This title is only updated
179179
# as frequently as the database is changed.
180-
multiplex_window_title = ''
180+
multiplex_window_title = ""
181181

182182
# Use the same prompt format strings to construct a pane title in a terminal
183183
# multiplexer. Currently only tmux is supported. This title is only updated
184184
# as frequently as the database is changed.
185-
multiplex_pane_title = ''
185+
multiplex_pane_title = ""
186186

187187
# Skip intro info on startup and outro info on exit, and generally reduce
188188
# feedback. This is equivalent to giving --quiet at the command line.
@@ -242,19 +242,19 @@ default_keepalive_ticks = 0
242242
default_ssl_mode = auto
243243

244244
# SSL CA file for connections without --ssl-ca being set
245-
default_ssl_ca =
245+
default_ssl_ca = ""
246246

247247
# SSL CA directory for connections without --ssl-capath being set
248-
default_ssl_capath =
248+
default_ssl_capath = ""
249249

250250
# SSL X509 cert path for connections without --ssl-cert being set
251-
default_ssl_cert =
251+
default_ssl_cert = ""
252252

253253
# SSL X509 key for connections without --ssl-key being set
254-
default_ssl_key =
254+
default_ssl_key = ""
255255

256256
# SSL cipher to use for connections without --ssl-cipher being set
257-
default_ssl_cipher =
257+
default_ssl_cipher = ""
258258

259259
# whether to verify server's "Common Name" in its cert, for connections without
260260
# --ssl-verify-server-cert being set
@@ -306,17 +306,17 @@ emacs_ttimeoutlen = 0.5
306306
# Attributes: (no)blink, bold, dim, hidden, inherit, italic, reverse, strike, underline.
307307
[colors]
308308
# Completion menus
309-
completion-menu.completion.current = 'bg:#ffffff #000000'
310-
completion-menu.completion = 'bg:#008888 #ffffff'
311-
completion-menu.meta.completion.current = 'bg:#44aaaa #000000'
312-
completion-menu.meta.completion = 'bg:#448888 #ffffff'
313-
completion-menu.multi-column-meta = 'bg:#aaffff #000000'
314-
scrollbar.arrow = 'bg:#003333'
315-
scrollbar = 'bg:#00aaaa'
309+
completion-menu.completion.current = "bg:#ffffff #000000"
310+
completion-menu.completion = "bg:#008888 #ffffff"
311+
completion-menu.meta.completion.current = "bg:#44aaaa #000000"
312+
completion-menu.meta.completion = "bg:#448888 #ffffff"
313+
completion-menu.multi-column-meta = "bg:#aaffff #000000"
314+
scrollbar.arrow = "bg:#003333"
315+
scrollbar = "bg:#00aaaa"
316316

317317
# The prompt
318-
prompt = ''
319-
continuation = ''
318+
prompt = ""
319+
continuation = ""
320320

321321
# Colored table output (query results)
322322
output.table-separator = ""
@@ -329,29 +329,29 @@ output.status.warning-count = ""
329329
output.timing = ""
330330

331331
# Selected text (native selection; currently unused)
332-
selected = '#ffffff bg:#6666aa'
332+
selected = "#ffffff bg:#6666aa"
333333

334334
# Search matches (for reverse i-search, not fuzzy search)
335-
search = '#ffffff bg:#4444aa'
336-
search.current = '#ffffff bg:#44aa44'
335+
search = "#ffffff bg:#4444aa"
336+
search.current = "#ffffff bg:#44aa44"
337337

338338
# UI elements: bottom toolbar
339-
bottom-toolbar = 'bg:#222222 #aaaaaa'
340-
bottom-toolbar.off = 'bg:#222222 #888888'
341-
bottom-toolbar.on = 'bg:#222222 #ffffff'
342-
bottom-toolbar.transaction.valid = 'bg:#222222 #00ff5f bold'
343-
bottom-toolbar.transaction.failed = 'bg:#222222 #ff005f bold'
339+
bottom-toolbar = "bg:#222222 #aaaaaa"
340+
bottom-toolbar.off = "bg:#222222 #888888"
341+
bottom-toolbar.on = "bg:#222222 #ffffff"
342+
bottom-toolbar.transaction.valid = "bg:#222222 #00ff5f bold"
343+
bottom-toolbar.transaction.failed = "bg:#222222 #ff005f bold"
344344

345345
# UI elements: other toolbars (currently unused)
346-
search-toolbar = 'noinherit bold'
347-
search-toolbar.text = 'nobold'
348-
system-toolbar = 'noinherit bold'
349-
arg-toolbar = 'noinherit bold'
350-
arg-toolbar.text = 'nobold'
346+
search-toolbar = noinherit bold
347+
search-toolbar.text = nobold
348+
system-toolbar = noinherit bold
349+
arg-toolbar = noinherit bold
350+
arg-toolbar.text = nobold
351351

352352
# SQL enhacements: matching brackets
353-
matching-bracket.cursor = '#ff8888 bg:#880000'
354-
matching-bracket.other = '#000000 bg:#aacccc'
353+
matching-bracket.cursor = "#ff8888 bg:#880000"
354+
matching-bracket.other = "#000000 bg:#aacccc"
355355

356356
# SQL syntax highlighting overrides: normally defined by main.syntax_style
357357
# sql.comment = 'italic #408080'

test/pytests/test_client.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
from io import TextIOWrapper
4-
import os
54
from pathlib import Path
65
from types import SimpleNamespace
76
from typing import Any
@@ -20,7 +19,6 @@ def write_myclirc(tmp_path: Path, content: str) -> str:
2019

2120
def patch_constructor_side_effects(monkeypatch: pytest.MonkeyPatch) -> None:
2221
monkeypatch.setattr(MyCli, 'system_config_files', [])
23-
monkeypatch.setattr(MyCli, 'pwd_config_file', os.devnull)
2422
monkeypatch.setattr(MyCli, 'initialize_logging', lambda self: None)
2523
monkeypatch.setattr(MyCli, 'register_special_commands', lambda self: None)
2624
monkeypatch.setattr(client_module, 'get_mylogin_cnf_path', lambda: None)

test/pytests/test_main.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,6 @@ def stub_terminal_size():
861861

862862
def test_list_dsn(monkeypatch):
863863
monkeypatch.setattr(MyCli, "system_config_files", [])
864-
monkeypatch.setattr(MyCli, "pwd_config_file", os.devnull)
865864
runner = CliRunner()
866865
# keep Windows from locking the file with delete=False
867866
with NamedTemporaryFile(prefix=TEMPFILE_PREFIX, mode="w", delete=False) as myclirc:
@@ -2064,7 +2063,6 @@ def test_execute_arg_supersedes_batch_file(monkeypatch):
20642063
@dbtest
20652064
def test_null_string_config(monkeypatch):
20662065
monkeypatch.setattr(MyCli, 'system_config_files', [])
2067-
monkeypatch.setattr(MyCli, 'pwd_config_file', os.devnull)
20682066
runner = CliRunner()
20692067
# keep Windows from locking the file with delete=False
20702068
with NamedTemporaryFile(mode='w', delete=False) as myclirc:

0 commit comments

Comments
 (0)