Skip to content

Commit e3f9413

Browse files
committed
SNOW-2306184: remove useless comments
1 parent ef5c431 commit e3f9413

File tree

6 files changed

+3
-39
lines changed

6 files changed

+3
-39
lines changed

src/snowflake/cli/api/cli_global_context.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class _CliGlobalContextManager:
6767
_definition_manager: DefinitionManager | None = None
6868
enhanced_exit_codes: bool = False
6969

70-
# Configuration management
7170
_config_manager: ConfigManager | None = None
7271
config_file_override: Path | None = None
7372
connections_file_override: Path | None = None
@@ -79,7 +78,6 @@ class _CliGlobalContextManager:
7978
"project_env_overrides_args",
8079
]
8180

82-
# Dependencies that invalidate config manager
8381
CONFIG_MANAGER_DEPENDENCIES = ["config_file_override", "connections_file_override"]
8482

8583
def reset(self):
@@ -180,24 +178,20 @@ def _create_config_manager(self) -> ConfigManager:
180178
)
181179
from snowflake.connector.constants import CONFIG_FILE
182180

183-
# Get current connections file path (handles test env changes)
184181
connections_file = get_connections_file()
185182

186-
# Create ConfigSlice for connections.toml (same as singleton CONFIG_MANAGER)
187183
connections_slice = ConfigSlice(
188184
path=connections_file,
189185
options=ConfigSliceOptions(check_permissions=True, only_in_slice=False),
190186
section="connections",
191187
)
192188

193-
# Create manager instance with connections slice
194189
manager = ConfigManager(
195190
name="CONFIG_MANAGER",
196191
file_path=self.config_file_override or CONFIG_FILE,
197192
_slices=[connections_slice],
198193
)
199194

200-
# Add connector's default options (replicating connector's singleton setup)
201195
manager.add_option(
202196
name="connections",
203197
parse_str=tomlkit.parse,
@@ -208,7 +202,6 @@ def _create_config_manager(self) -> ConfigManager:
208202
name="default_connection_name", parse_str=str, default="default"
209203
)
210204

211-
# Add CLI-specific options (current lines 66-70 in config.py)
212205
from snowflake.cli.api.config import CLI_SECTION
213206

214207
manager.add_option(

src/snowflake/cli/api/config.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ class Empty:
8282
PLUGIN_ENABLED_KEY = "enabled"
8383
FEATURE_FLAGS_SECTION_PATH = [CLI_SECTION, "features"]
8484

85-
# CLI_SECTION option registration now handled in CLI context manager
86-
8785

8886
@dataclass
8987
class ConnectionConfig:
@@ -150,7 +148,6 @@ def config_init(config_file: Optional[Path]):
150148
from snowflake.cli._app.loggers import create_initial_loggers
151149
from snowflake.cli.api.cli_global_context import get_cli_context_manager
152150

153-
# Set config file override in context instead of direct assignment
154151
if config_file:
155152
get_cli_context_manager().config_file_override = config_file
156153
else:
@@ -199,7 +196,6 @@ def _get_default_logs_config() -> dict:
199196
from snowflake.cli.api.utils.path_utils import path_resolver
200197

201198
config_parent_path = get_config_manager().file_path.parent
202-
# Resolve Windows short paths to prevent issues with temp directory cleanup
203199
resolved_parent_path = path_resolver(str(config_parent_path))
204200

205201
return {

tests/conftest.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,9 @@ def reset_global_context_and_setup_config_and_logging_levels(
114114
cli_context_manager.enable_tracebacks = False
115115
cli_context_manager.connection_cache = connection_cache
116116

117-
# Set config file override in context for test isolation
118117
cli_context_manager.config_file_override = test_snowcli_config
119118

120-
config_init(None) # No need to pass config file, it's in context
119+
config_init(None)
121120
loggers.create_loggers(verbose=False, debug=False)
122121
try:
123122
yield
@@ -238,7 +237,6 @@ def app_zip(temporary_directory) -> Generator:
238237
yield create_temp_file(".zip", temporary_directory, [])
239238

240239

241-
# New fixtures for config manager testing
242240
@pytest.fixture
243241
def config_manager():
244242
"""
@@ -325,7 +323,6 @@ def _create_manager(
325323

326324
yield _create_manager
327325

328-
# Cleanup
329326
for file in created_files:
330327
file.unlink(missing_ok=True)
331328

@@ -519,7 +516,6 @@ def func():
519516
@contextmanager
520517
def _named_temporary_file(suffix=None, prefix=None):
521518
with tempfile.TemporaryDirectory() as tmp_dir:
522-
# Resolve Windows short paths to prevent cleanup issues
523519
from snowflake.cli.api.utils.path_utils import path_resolver
524520

525521
resolved_tmp_dir = path_resolver(tmp_dir)
@@ -531,7 +527,6 @@ def _named_temporary_file(suffix=None, prefix=None):
531527
try:
532528
yield f
533529
finally:
534-
# Ensure all logging handlers are closed before temp directory cleanup
535530
clean_logging_handlers()
536531

537532

tests/spcs/test_services.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ def enable_events_and_metrics_config():
7373
from tests.conftest import clean_logging_handlers
7474

7575
with TemporaryDirectory() as tempdir:
76-
# Resolve Windows short paths to prevent cleanup issues
7776
resolved_tempdir = path_resolver(tempdir)
7877
config_toml = Path(resolved_tempdir) / "config.toml"
7978
config_toml.write_text(
@@ -84,7 +83,6 @@ def enable_events_and_metrics_config():
8483
try:
8584
yield config_toml
8685
finally:
87-
# Ensure all logging handlers are closed before temp directory cleanup
8886
clean_logging_handlers()
8987

9088

tests/test_config.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def test_empty_config_file_is_created_if_not_present():
4040
from tests.conftest import clean_logging_handlers
4141

4242
with TemporaryDirectory() as tmp_dir:
43-
# Resolve Windows short paths to prevent cleanup issues
4443
resolved_tmp_dir = path_resolver(tmp_dir)
4544
config_file = Path(resolved_tmp_dir) / "sub" / "config.toml"
4645
assert config_file.exists() is False
@@ -50,7 +49,6 @@ def test_empty_config_file_is_created_if_not_present():
5049
assert config_file.exists() is True
5150
assert_file_permissions_are_strict(config_file)
5251
finally:
53-
# Ensure all logging handlers are closed before temp directory cleanup
5452
clean_logging_handlers()
5553

5654

@@ -176,19 +174,16 @@ def test_create_default_config_if_not_exists_with_proper_permissions(
176174

177175
mock_get_config_section.return_value = {}
178176
with TemporaryDirectory() as tmp_dir:
179-
# Resolve Windows short paths to prevent cleanup issues
180177
resolved_tmp_dir = path_resolver(tmp_dir)
181178
config_path = Path(f"{resolved_tmp_dir}/snowflake/config.toml")
182179

183180
try:
184-
# Test the config initialization with a specific path
185181
config_init(config_path)
186182

187183
assert config_path.exists()
188184
assert_file_permissions_are_strict(config_path.parent)
189185
assert_file_permissions_are_strict(config_path)
190186
finally:
191-
# Ensure all logging handlers are closed before temp directory cleanup
192187
clean_logging_handlers()
193188

194189

@@ -244,7 +239,6 @@ def test_not_found_default_connection_from_evn_variable(test_root_path):
244239
def test_correct_updates_of_connections_on_setting_default_connection(
245240
test_snowcli_config, snowflake_home
246241
):
247-
# Use isolated context for this test to avoid fixture conflicts
248242
with fork_cli_context() as ctx:
249243
config = test_snowcli_config
250244
connections_toml = snowflake_home / "connections.toml"
@@ -261,12 +255,10 @@ def test_correct_updates_of_connections_on_setting_default_connection(
261255
"""
262256
)
263257

264-
# Set config file override in isolated context
265258
ctx.config_file_override = config
266-
config_init(None) # Use context's config file
259+
config_init(None)
267260
set_config_value(path=["default_connection_name"], value="asdf_b")
268261

269-
# Get config manager from isolated context
270262
config_manager = ctx.config_manager
271263

272264
def assert_correct_connections_loaded():
@@ -316,16 +308,13 @@ def assert_correct_connections_loaded():
316308
config_toml_content.count("dummy_flag = true") == 1
317309
) # other settings are not erased
318310

319-
# reinit config file and recheck loaded connections
320-
config_init(None) # Use context's config file
311+
config_init(None)
321312
assert_correct_connections_loaded()
322313

323314

324315
def test_correct_updates_of_connections_on_setting_default_connection_for_empty_config_file(
325316
config_file, snowflake_home, config_manager
326317
):
327-
# CONFIG_MANAGER is now accessed through the config_manager fixture
328-
329318
with config_file() as config:
330319
connections_toml = snowflake_home / "connections.toml"
331320
connections_toml.write_text(
@@ -390,16 +379,13 @@ def assert_correct_connections_loaded():
390379
config_toml_content.count("dummy_flag = true") == 0
391380
) # other settings are not erased
392381

393-
# reinit config file and recheck loaded connections
394382
config_init(config)
395383
assert_correct_connections_loaded()
396384

397385

398386
def test_connections_toml_override_config_toml(
399387
test_snowcli_config, snowflake_home, config_manager
400388
):
401-
# CONFIG_MANAGER is now accessed through the config_manager fixture
402-
403389
connections_toml = snowflake_home / "connections.toml"
404390
connections_toml.write_text(
405391
"""[default]
@@ -520,7 +506,6 @@ def test_too_wide_permissions_on_custom_config_file_causes_warning_windows(permi
520506
from tests.conftest import clean_logging_handlers
521507

522508
with TemporaryDirectory() as tmp_dir:
523-
# Resolve Windows short paths to prevent cleanup issues
524509
resolved_tmp_dir = path_resolver(tmp_dir)
525510
config_path = Path(resolved_tmp_dir) / "config.toml"
526511
config_path.touch()
@@ -538,7 +523,6 @@ def test_too_wide_permissions_on_custom_config_file_causes_warning_windows(permi
538523
):
539524
config_init(config_file=config_path)
540525
finally:
541-
# Ensure all logging handlers are closed before temp directory cleanup
542526
clean_logging_handlers()
543527

544528

tests_common/conftest.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,12 @@ def temporary_directory():
4141
initial_dir = os.getcwd()
4242

4343
with tempfile.TemporaryDirectory() as tmp_dir:
44-
# Resolve Windows short paths to prevent cleanup issues
4544
resolved_tmp_dir = path_resolver(tmp_dir)
4645
try:
4746
os.chdir(resolved_tmp_dir)
4847
yield resolved_tmp_dir
4948
finally:
5049
os.chdir(initial_dir)
51-
# Ensure all logging handlers are closed before temp directory cleanup
5250
clean_logging_handlers()
5351

5452

0 commit comments

Comments
 (0)