Skip to content

Commit

Permalink
Remove DeprecatedOption (#5649)
Browse files Browse the repository at this point in the history
  • Loading branch information
alanmcruickshank committed Mar 5, 2024
1 parent c534d50 commit 8029b18
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 247 deletions.
4 changes: 4 additions & 0 deletions docs/source/releasenotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ This release makes a couple of potentially breaking changes:
always now have the level of :code:`notice`. This is only relevant when using
the :code:`github-annotation` or :code:`github-annotation-native` formats.

* The previously deprecated `--disable_progress_bar` on `lint`, `fix` and `format`
has now been removed entirely. Please migrate to `--disable-progress-bar` to
continue using this option.

Upgrading to 2.3
----------------

Expand Down
105 changes: 0 additions & 105 deletions src/sqlfluff/cli/click_deprecated_option.py

This file was deleted.

13 changes: 3 additions & 10 deletions src/sqlfluff/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@

from sqlfluff.cli import EXIT_ERROR, EXIT_FAIL, EXIT_SUCCESS
from sqlfluff.cli.autocomplete import dialect_shell_complete, shell_completion_enabled
from sqlfluff.cli.click_deprecated_option import (
DeprecatedOption,
DeprecatedOptionsCommand,
)
from sqlfluff.cli.formatters import (
OutputStreamFormatter,
format_linting_result_header,
Expand Down Expand Up @@ -336,12 +332,9 @@ def lint_options(f: Callable) -> Callable:
),
)(f)
f = click.option(
"--disable_progress_bar",
"--disable-progress-bar",
is_flag=True,
help="Disables progress bars.",
cls=DeprecatedOption,
deprecated=["--disable_progress_bar"],
)(f)
f = click.option(
"--persist-timing",
Expand Down Expand Up @@ -523,7 +516,7 @@ def dump_file_payload(filename: Optional[str], payload: str) -> None:
click.echo(payload)


@cli.command(cls=DeprecatedOptionsCommand)
@cli.command()
@common_options
@core_options
@lint_options
Expand Down Expand Up @@ -938,7 +931,7 @@ def _paths_fix(
sys.exit(exit_code)


@cli.command(cls=DeprecatedOptionsCommand)
@cli.command()
@common_options
@core_options
@lint_options
Expand Down Expand Up @@ -1060,7 +1053,7 @@ def fix(
)


@cli.command(name="format", cls=DeprecatedOptionsCommand)
@cli.command(name="format")
@common_options
@core_options
@lint_options
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfluff/utils/testing/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ def invoke_assert_code(
# raised by `sys.exit()`)
if raise_exceptions and result.exception:
if not isinstance(result.exception, SystemExit):
raise result.exception
raise result.exception # pragma: no cover
assert ret_code == result.exit_code
return result
69 changes: 0 additions & 69 deletions test/cli/click_deprecated_option_test.py

This file was deleted.

61 changes: 0 additions & 61 deletions test/cli/commands_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1869,29 +1869,6 @@ def test_cli_lint_disabled_progress_bar(
assert "\rparsing: 0it" not in raw_output
assert "\r\rlint by rules:" not in raw_output

def test_cli_lint_disabled_progress_bar_deprecated_option(
self, mock_disable_progress_bar: MagicMock
) -> None:
"""Same as above but checks additionally if deprecation warning is printed."""
result = invoke_assert_code(
args=[
lint,
[
"--disable_progress_bar",
"test/fixtures/linter/passing.sql",
],
],
)
raw_output = repr(result.output)

assert "\rpath test/fixtures/linter/passing.sql:" not in raw_output
assert "\rparsing: 0it" not in raw_output
assert "\r\rlint by rules:" not in raw_output
assert (
"DeprecationWarning: The option '--disable_progress_bar' is deprecated, "
"use '--disable-progress-bar'"
) in raw_output

def test_cli_lint_enabled_progress_bar(
self, mock_disable_progress_bar: MagicMock
) -> None:
Expand Down Expand Up @@ -1973,44 +1950,6 @@ def test_cli_lint_enabled_progress_bar_multiple_files(
assert r"\rrule LT01:" in raw_output
assert r"\rrule CV05:" in raw_output

def test_cli_fix_disabled_progress_bar(
self, mock_disable_progress_bar: MagicMock
) -> None:
"""When progress bar is disabled, nothing should be printed into output."""
result = invoke_assert_code(
args=[
fix,
[
"--disable-progress-bar",
"test/fixtures/linter/passing.sql",
],
],
)
raw_output = repr(result.output)

assert (
"DeprecationWarning: The option '--disable_progress_bar' is deprecated, "
"use '--disable-progress-bar'"
) not in raw_output

def test_cli_fix_disabled_progress_bar_deprecated_option(
self, mock_disable_progress_bar: MagicMock
) -> None:
"""Same as above but checks additionally if deprecation warning is printed."""
invoke_assert_code(
args=[
fix,
[
"--disable_progress_bar",
"test/fixtures/linter/passing.sql",
],
],
assert_output_contains=(
"DeprecationWarning: The option '--disable_progress_bar' is "
"deprecated, use '--disable-progress-bar'"
),
)


multiple_expected_output = """==== finding fixable violations ====
== [test/fixtures/linter/multiple_sql_errors.sql] FAIL
Expand Down
2 changes: 1 addition & 1 deletion test/cli/formatters_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test__cli__helpers__cli_table(tmpdir):
"rule VARCHAR(30)"
");"
),
["--force", "--dialect", "postgres", "--disable_progress_bar", "--nocolor"],
["--force", "--dialect", "postgres", "--disable-progress-bar", "--nocolor"],
(
"CREATE TABLE IF NOT EXISTS vuln.software_name_dictionary("
"id SERIAL PRIMARY KEY"
Expand Down

0 comments on commit 8029b18

Please sign in to comment.