Skip to content

Commit

Permalink
Remove the deprecated disable-format flag
Browse files Browse the repository at this point in the history
In concert with changes to `--format-regex`, this gets us to
a place where there is only one flag which is canonically correct
for disabling format checks.
  • Loading branch information
sirosen committed Aug 25, 2023
1 parent 32bb260 commit 0280ed5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 32 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Unreleased
default. (:issue:`302`)
- The ``--format-regex disabled`` option has been removed. Users should use
``--disable-formats regex`` if they wish to disable regex format checking.
- The deprecated ``--disable-format`` flag has been removed. Users should use
``--disable-formats "*"`` if they wish to disable all format checking.

0.25.0
------
Expand Down
9 changes: 0 additions & 9 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,6 @@ that any validation for formats be applied.
``check-jsonschema`` supports checking several ``"format"``\s by default. The
following options can be used to control this behavior.

``--disable-format``
~~~~~~~~~~~~~~~~~~~~

.. warning::

This option is deprecated. Use ``--disable-formats "*"`` instead.

Disable all format checks.

``--disable-formats``
~~~~~~~~~~~~~~~~~~~~~

Expand Down
16 changes: 2 additions & 14 deletions src/check_jsonschema/cli/main_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from ..transforms import TRANSFORM_LIBRARY
from .param_types import CommaDelimitedList
from .parse_result import ParseResult, SchemaLoadingMode
from .warnings import deprecation_warning_callback

BUILTIN_SCHEMA_NAMES = [f"vendor.{k}" for k in SCHEMA_CATALOG.keys()] + [
f"custom.{k}" for k in CUSTOM_SCHEMA_NAMES
Expand Down Expand Up @@ -127,17 +126,6 @@ def pretty_helptext_list(values: list[str] | tuple[str, ...]) -> str:
"Defaults to the last slash-delimited part of the URI."
),
)
@click.option(
"--disable-format",
is_flag=True,
help="{deprecated} Disable all format checks in the schema.",
callback=deprecation_warning_callback(
"--disable-format",
is_flag=True,
append_message="Users should now pass '--disable-formats \"*\"' for "
"the same functionality.",
),
)
@click.option(
"--disable-formats",
multiple=True,
Expand Down Expand Up @@ -223,7 +211,6 @@ def main(
check_metaschema: bool,
no_cache: bool,
cache_filename: str | None,
disable_format: bool,
disable_formats: tuple[list[str], ...],
format_regex: str,
default_filetype: str,
Expand All @@ -244,10 +231,11 @@ def main(
normalized_disable_formats: tuple[str, ...] = tuple(
f for sublist in disable_formats for f in sublist
)
if disable_format or "*" in normalized_disable_formats:
if "*" in normalized_disable_formats:
args.disable_all_formats = True
else:
args.disable_formats = normalized_disable_formats

args.format_regex = RegexVariantName(format_regex)
args.disable_cache = no_cache
args.default_filetype = default_filetype
Expand Down
9 changes: 0 additions & 9 deletions tests/unit/test_cli_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,3 @@ def test_disable_all_formats(runner, mock_parse_result, addargs):
+ addargs,
)
assert mock_parse_result.disable_all_formats is True


def test_disable_format_deprecated_flag(runner, mock_parse_result):
# this should be an override, with or without other args
with pytest.warns(UserWarning, match="'--disable-format' is deprecated"):
runner.invoke(
cli_main, ["--schemafile", "schema.json", "foo.json", "--disable-format"]
)
assert mock_parse_result.disable_all_formats is True

0 comments on commit 0280ed5

Please sign in to comment.