mirror of
https://github.com/simonw/datasette.git
synced 2026-09-29 13:24:07 +02:00
Upgrade to ruff>=0.16.0 (#2857)
* ruff>=0.16.0 See https://astral.sh/blog/ruff-v0.16.0 * uv run ruff check . --fix --unsafe-fixes * Ruff fixes by Claude Code Opus 5
This commit is contained in:
parent
481df7ff6d
commit
e889403d3b
133 changed files with 1647 additions and 1569 deletions
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Datasette documentation build configuration file, created by
|
||||
# sphinx-quickstart on Thu Nov 16 06:50:13 2017.
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ def table_extras(cog):
|
|||
cog.out("\n")
|
||||
for scope, heading, intro, classes in classes_by_scope:
|
||||
cog.out("{}\n{}\n\n".format(heading, "~" * len(heading)))
|
||||
cog.out("{}\n\n".format(intro))
|
||||
cog.out(f"{intro}\n\n")
|
||||
for cls in classes:
|
||||
examples = _examples_for_scope(cls, scope)
|
||||
description = cls.description or ""
|
||||
|
|
@ -58,16 +58,16 @@ def table_extras(cog):
|
|||
if notes:
|
||||
description = "{} ({})".format(description, " ".join(notes)).strip()
|
||||
|
||||
cog.out("``{}``\n".format(cls.key()))
|
||||
cog.out(" {}\n\n".format(description))
|
||||
cog.out(f"``{cls.key()}``\n")
|
||||
cog.out(f" {description}\n\n")
|
||||
for example in examples:
|
||||
if example.path:
|
||||
value = live_examples[(example.path, example.key or cls.key())]
|
||||
cog.out(" ``GET {}``\n\n".format(example.path))
|
||||
cog.out(f" ``GET {example.path}``\n\n")
|
||||
else:
|
||||
value = example.value
|
||||
if example.note:
|
||||
cog.out(" {}\n\n".format(example.note))
|
||||
cog.out(f" {example.note}\n\n")
|
||||
cog.out(" .. code-block:: json\n\n")
|
||||
cog.out(textwrap.indent(json.dumps(value, indent=2), " "))
|
||||
cog.out("\n\n")
|
||||
|
|
@ -139,7 +139,7 @@ async def _fetch_live_examples(scoped_classes):
|
|||
response = await datasette.client.get(example.path)
|
||||
assert response.status_code == 200, example.path
|
||||
data = response.json()
|
||||
assert key in data, "{} missing from {}".format(key, example.path)
|
||||
assert key in data, f"{key} missing from {example.path}"
|
||||
examples[(example.path, key)] = data[key]
|
||||
finally:
|
||||
for db in datasette.databases.values():
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import json
|
||||
import textwrap
|
||||
from yaml import safe_dump
|
||||
|
||||
from ruamel.yaml import YAML
|
||||
from yaml import safe_dump
|
||||
|
||||
|
||||
def metadata_example(cog, data=None, yaml=None):
|
||||
|
|
@ -33,10 +34,10 @@ def config_example(
|
|||
else:
|
||||
data = input
|
||||
output_yaml = safe_dump(input, sort_keys=False)
|
||||
cog.out("\n.. tab:: {}\n\n".format(yaml_title))
|
||||
cog.out(f"\n.. tab:: {yaml_title}\n\n")
|
||||
cog.out(" .. code-block:: yaml\n\n")
|
||||
cog.out(textwrap.indent(output_yaml, " "))
|
||||
cog.out("\n\n.. tab:: {}\n\n".format(json_title))
|
||||
cog.out(f"\n\n.. tab:: {json_title}\n\n")
|
||||
cog.out(" .. code-block:: json\n\n")
|
||||
cog.out(textwrap.indent(json.dumps(data, indent=2), " "))
|
||||
cog.out("\n")
|
||||
|
|
@ -44,9 +45,11 @@ def config_example(
|
|||
|
||||
def internal_schema(cog):
|
||||
import asyncio
|
||||
from datasette.app import Datasette
|
||||
|
||||
from sqlite_utils import Database
|
||||
|
||||
from datasette.app import Datasette
|
||||
|
||||
ds = Datasette()
|
||||
db = ds.get_internal_database()
|
||||
|
||||
|
|
|
|||
|
|
@ -21,14 +21,12 @@ def template_context(cog):
|
|||
),
|
||||
)
|
||||
for name, doc in TEMPLATE_BASE_CONTEXT.items():
|
||||
cog.out("``{}``\n".format(name))
|
||||
cog.out(" {}\n\n".format(doc))
|
||||
cog.out(f"``{name}``\n")
|
||||
cog.out(f" {doc}\n\n")
|
||||
|
||||
for klass in PAGES.values():
|
||||
title = "{} page".format(klass.__name__.removesuffix("Context"))
|
||||
intro = "{} Rendered using the ``{}`` template.".format(
|
||||
klass.__doc__, klass.documented_template
|
||||
)
|
||||
intro = f"{klass.__doc__} Rendered using the ``{klass.documented_template}`` template."
|
||||
_section(cog, title, intro)
|
||||
if klass.extras_scope is not None:
|
||||
cog.out(
|
||||
|
|
@ -36,10 +34,10 @@ def template_context(cog):
|
|||
"<json_api>` for this page.\n\n"
|
||||
)
|
||||
for f in sorted(klass.documented_fields(), key=lambda f: f.name):
|
||||
cog.out("``{}`` - ``{}``\n".format(f.name, f.type_name))
|
||||
cog.out(" {}\n\n".format(f.help))
|
||||
cog.out(f"``{f.name}`` - ``{f.type_name}``\n")
|
||||
cog.out(f" {f.help}\n\n")
|
||||
|
||||
|
||||
def _section(cog, title, intro):
|
||||
cog.out("{}\n{}\n\n".format(title, "-" * len(title)))
|
||||
cog.out("{}\n\n".format(intro))
|
||||
cog.out(f"{intro}\n\n")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue