Skip to content

Commit

Permalink
fix: older pythons require resource package
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Jan 28, 2024
1 parent 275de9a commit 5495f06
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/black/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ 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"
loc = "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("black.resources", loc, encoding="utf-8") as f:
return json.load(f)

schema = importlib.resources.files("black").joinpath(loc) # type: ignore[unreachable]
schema = importlib.resources.files("black.resources").joinpath(loc) # type: ignore[unreachable]
with schema.open(encoding="utf-8") as f:
return json.load(f)

0 comments on commit 5495f06

Please sign in to comment.