diff --git a/datasette/app.py b/datasette/app.py index 1c8577a9e9..6fec250d64 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -335,7 +335,9 @@ def __init__( ] if config_dir and metadata_files and not metadata: with metadata_files[0].open() as fp: - metadata = fail_if_plugins_in_metadata(parse_metadata(fp.read()), metadata_files[0].name) + metadata = fail_if_plugins_in_metadata( + parse_metadata(fp.read()), metadata_files[0].name + ) if config_dir and config_files and not config: with config_files[0].open() as fp: diff --git a/datasette/cli.py b/datasette/cli.py index e1ea095eae..91f38f698f 100644 --- a/datasette/cli.py +++ b/datasette/cli.py @@ -543,7 +543,7 @@ def serve( metadata_data = None if metadata: - metadata_data = fail_if_plugins_in_metadata(parse_metadata(metadata.read()), metadata.name) + metadata_data = fail_if_plugins_in_metadata(parse_metadata(metadata.read())) config_data = None if config: diff --git a/datasette/utils/__init__.py b/datasette/utils/__init__.py index 1b6d5e96cb..0f449b89a1 100644 --- a/datasette/utils/__init__.py +++ b/datasette/utils/__init__.py @@ -1269,9 +1269,17 @@ def pairs_to_nested_config(pairs: typing.List[typing.Tuple[str, typing.Any]]) -> result = _combine(result, parsed_pair) return result -def fail_if_plugins_in_metadata(metadata:dict, filename=None): - """ If plugin config is inside metadata, raise an Exception """ + +def fail_if_plugins_in_metadata(metadata: dict, filename=None): + """If plugin config is inside metadata, raise an Exception""" if metadata is not None and metadata.get("plugins") is not None: - suggested_extension = ".yaml" if filename is not None and (filename.endswith(".yaml") or filename.endswith(".yml")) else ".json" - raise Exception(f'Datasette no longer accepts plugin configuration in --metadata. Move your "plugins" configuration blocks to a separate file - we suggest calling that datasette.{suggested_extension} - and start Datasette with datasette -c datasette.{suggested_extension}. See https://docs.datasette.io/en/latest/configuration.html for more details.') + suggested_extension = ( + ".yaml" + if filename is not None + and (filename.endswith(".yaml") or filename.endswith(".yml")) + else ".json" + ) + raise Exception( + f'Datasette no longer accepts plugin configuration in --metadata. Move your "plugins" configuration blocks to a separate file - we suggest calling that datasette.{suggested_extension} - and start Datasette with datasette -c datasette.{suggested_extension}. See https://docs.datasette.io/en/latest/configuration.html for more details.' + ) return metadata