Skip to content

Commit 903360e

Browse files
committed
remove implicit read of .myclirc files in the cwd
This was never documented, and should not have been possible without at least a warning to the user. The functionality could be added back with some form of explicit argument. Requires reformatting of test/myclirc to keep the repository git-clean after running behave. We should probably also fix that so that the behave suite does not write back to myclirc. Preparation for release 2.0.
1 parent ce8c444 commit 903360e

5 files changed

Lines changed: 39 additions & 43 deletions

File tree

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Breaking Changes
88
* Remove support for deprecated environment variable `$MYSQL_UNIX_PORT`.
99
* Remove support for `--ssl/--no-ssl` CLI arguments in favor of `--ssl-mode`.
1010
* Remove support for deprecated SSH jump functionality.
11+
* Remove support for `.myclirc` files in the current working directory.
1112

1213

1314
Internal

mycli/client.py

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

67-
pwd_config_file = os.path.join(os.getcwd(), ".myclirc")
68-
6967
def __init__(
7068
self,
7169
sqlexecute: SQLExecute | None = None,
@@ -100,7 +98,7 @@ def __init__(
10098
self.cnf_files = [defaults_file]
10199

102100
# Load config.
103-
config_files: list[str | IO[str]] = self.system_config_files + [myclirc] + [self.pwd_config_file]
101+
config_files: list[str | IO[str]] = self.system_config_files + [myclirc]
104102

105103
c = self.config = read_config_files(config_files)
106104
# this parallel config exists to

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.
@@ -245,19 +245,19 @@ default_keepalive_ticks = 0
245245
default_ssl_mode = auto
246246

247247
# SSL CA file for connections without --ssl-ca being set
248-
default_ssl_ca =
248+
default_ssl_ca = ""
249249

250250
# SSL CA directory for connections without --ssl-capath being set
251-
default_ssl_capath =
251+
default_ssl_capath = ""
252252

253253
# SSL X509 cert path for connections without --ssl-cert being set
254-
default_ssl_cert =
254+
default_ssl_cert = ""
255255

256256
# SSL X509 key for connections without --ssl-key being set
257-
default_ssl_key =
257+
default_ssl_key = ""
258258

259259
# SSL cipher to use for connections without --ssl-cipher being set
260-
default_ssl_cipher =
260+
default_ssl_cipher = ""
261261

262262
# whether to verify server's "Common Name" in its cert, for connections without
263263
# --ssl-verify-server-cert being set
@@ -309,17 +309,17 @@ emacs_ttimeoutlen = 0.5
309309
# Attributes: (no)blink, bold, dim, hidden, inherit, italic, reverse, strike, underline.
310310
[colors]
311311
# Completion menus
312-
completion-menu.completion.current = 'bg:#ffffff #000000'
313-
completion-menu.completion = 'bg:#008888 #ffffff'
314-
completion-menu.meta.completion.current = 'bg:#44aaaa #000000'
315-
completion-menu.meta.completion = 'bg:#448888 #ffffff'
316-
completion-menu.multi-column-meta = 'bg:#aaffff #000000'
317-
scrollbar.arrow = 'bg:#003333'
318-
scrollbar = 'bg:#00aaaa'
312+
completion-menu.completion.current = "bg:#ffffff #000000"
313+
completion-menu.completion = "bg:#008888 #ffffff"
314+
completion-menu.meta.completion.current = "bg:#44aaaa #000000"
315+
completion-menu.meta.completion = "bg:#448888 #ffffff"
316+
completion-menu.multi-column-meta = "bg:#aaffff #000000"
317+
scrollbar.arrow = "bg:#003333"
318+
scrollbar = "bg:#00aaaa"
319319

320320
# The prompt
321-
prompt = ''
322-
continuation = ''
321+
prompt = ""
322+
continuation = ""
323323

324324
# Colored table output (query results)
325325
output.table-separator = ""
@@ -332,29 +332,29 @@ output.status.warning-count = ""
332332
output.timing = ""
333333

334334
# Selected text (native selection; currently unused)
335-
selected = '#ffffff bg:#6666aa'
335+
selected = "#ffffff bg:#6666aa"
336336

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

341341
# UI elements: bottom toolbar
342-
bottom-toolbar = 'bg:#222222 #aaaaaa'
343-
bottom-toolbar.off = 'bg:#222222 #888888'
344-
bottom-toolbar.on = 'bg:#222222 #ffffff'
345-
bottom-toolbar.transaction.valid = 'bg:#222222 #00ff5f bold'
346-
bottom-toolbar.transaction.failed = 'bg:#222222 #ff005f bold'
342+
bottom-toolbar = "bg:#222222 #aaaaaa"
343+
bottom-toolbar.off = "bg:#222222 #888888"
344+
bottom-toolbar.on = "bg:#222222 #ffffff"
345+
bottom-toolbar.transaction.valid = "bg:#222222 #00ff5f bold"
346+
bottom-toolbar.transaction.failed = "bg:#222222 #ff005f bold"
347347

348348
# UI elements: other toolbars (currently unused)
349-
search-toolbar = 'noinherit bold'
350-
search-toolbar.text = 'nobold'
351-
system-toolbar = 'noinherit bold'
352-
arg-toolbar = 'noinherit bold'
353-
arg-toolbar.text = 'nobold'
349+
search-toolbar = noinherit bold
350+
search-toolbar.text = nobold
351+
system-toolbar = noinherit bold
352+
arg-toolbar = noinherit bold
353+
arg-toolbar.text = nobold
354354

355355
# SQL enhacements: matching brackets
356-
matching-bracket.cursor = '#ff8888 bg:#880000'
357-
matching-bracket.other = '#000000 bg:#aacccc'
356+
matching-bracket.cursor = "#ff8888 bg:#880000"
357+
matching-bracket.other = "#000000 bg:#aacccc"
358358

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

test/pytests/test_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def write_myclirc(tmp_path: Path, content: str) -> str:
2020

2121
def patch_constructor_side_effects(monkeypatch: pytest.MonkeyPatch) -> None:
2222
monkeypatch.setattr(MyCli, 'system_config_files', [])
23-
monkeypatch.setattr(MyCli, 'pwd_config_file', os.devnull)
2423
monkeypatch.setattr(MyCli, 'initialize_logging', lambda self: None)
2524
monkeypatch.setattr(MyCli, 'register_special_commands', lambda self: None)
2625
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
@@ -865,7 +865,6 @@ def stub_terminal_size():
865865

866866
def test_list_dsn(monkeypatch):
867867
monkeypatch.setattr(MyCli, "system_config_files", [])
868-
monkeypatch.setattr(MyCli, "pwd_config_file", os.devnull)
869868
runner = CliRunner()
870869
# keep Windows from locking the file with delete=False
871870
with NamedTemporaryFile(prefix=TEMPFILE_PREFIX, mode="w", delete=False) as myclirc:
@@ -2082,7 +2081,6 @@ def test_execute_arg_supersedes_batch_file(monkeypatch):
20822081
@dbtest
20832082
def test_null_string_config(monkeypatch):
20842083
monkeypatch.setattr(MyCli, 'system_config_files', [])
2085-
monkeypatch.setattr(MyCli, 'pwd_config_file', os.devnull)
20862084
runner = CliRunner()
20872085
# keep Windows from locking the file with delete=False
20882086
with NamedTemporaryFile(mode='w', delete=False) as myclirc:

0 commit comments

Comments
 (0)