From b5a7d076388b01d9ff19f97e784fd263741e35d2 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Sun, 28 Jan 2024 08:52:54 -0500 Subject: [PATCH] fix: older pythons require resource package --- src/black/schema.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/black/schema.py b/src/black/schema.py index af34bd8528a..78e9564cdbc 100644 --- a/src/black/schema.py +++ b/src/black/schema.py @@ -8,12 +8,13 @@ def get_schema(tool_name: str = "black") -> Any: """Get the stored complete schema for black's settings.""" assert tool_name == "black", "Only black is supported." - loc = "resources/black.schema.json" + pkg = "black.resources" + fname = "black.schema.json" if sys.version_info < (3, 9): - with importlib.resources.open_text("black", loc, encoding="utf-8") as f: + with importlib.resources.open_text(pkg, fname, encoding="utf-8") as f: return json.load(f) - schema = importlib.resources.files("black").joinpath(loc) # type: ignore[unreachable] + schema = importlib.resources.files(pkg).joinpath(fname) # type: ignore[unreachable] with schema.open(encoding="utf-8") as f: return json.load(f)