detect-breaking-changes.py — anthropic-sdk-python Source File
Architecture documentation for detect-breaking-changes.py, a python file in the anthropic-sdk-python codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR e9c55d52_4360_b6d8_1678_cf4b84ab4a22["detect-breaking-changes.py"] 42faf450_4542_3635_bb7f_62cffcc3e979["sys"] e9c55d52_4360_b6d8_1678_cf4b84ab4a22 --> 42faf450_4542_3635_bb7f_62cffcc3e979 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"] e9c55d52_4360_b6d8_1678_cf4b84ab4a22 --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875 525f4270_cbfe_512c_fbe4_e6566e0cdf13["pathlib"] e9c55d52_4360_b6d8_1678_cf4b84ab4a22 --> 525f4270_cbfe_512c_fbe4_e6566e0cdf13 a0b28eb3_d4e0_bb21_6a83_ba005c9793f4["rich"] e9c55d52_4360_b6d8_1678_cf4b84ab4a22 --> a0b28eb3_d4e0_bb21_6a83_ba005c9793f4 fed69547_66f5_5b4b_225b_8c08ccdf8e37["griffe"] e9c55d52_4360_b6d8_1678_cf4b84ab4a22 --> fed69547_66f5_5b4b_225b_8c08ccdf8e37 a14e76e1_f449_49ca_7c89_38ec58be4dc2["rich.text"] e9c55d52_4360_b6d8_1678_cf4b84ab4a22 --> a14e76e1_f449_49ca_7c89_38ec58be4dc2 8b7e35b5_95d7_af63_a9e8_37279f370bed["rich.style"] e9c55d52_4360_b6d8_1678_cf4b84ab4a22 --> 8b7e35b5_95d7_af63_a9e8_37279f370bed style e9c55d52_4360_b6d8_1678_cf4b84ab4a22 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from __future__ import annotations
import sys
from typing import Iterator
from pathlib import Path
import rich
import griffe
from rich.text import Text
from rich.style import Style
def public_members(obj: griffe.Object | griffe.Alias) -> dict[str, griffe.Object | griffe.Alias]:
if isinstance(obj, griffe.Alias):
# ignore imports for now, they're technically part of the public API
# but we don't have good preventative measures in place to prevent
# changing them
return {}
return {name: value for name, value in obj.all_members.items() if not name.startswith("_")}
def find_breaking_changes(
new_obj: griffe.Object | griffe.Alias,
old_obj: griffe.Object | griffe.Alias,
*,
path: list[str],
) -> Iterator[Text | str]:
new_members = public_members(new_obj)
old_members = public_members(old_obj)
for name, old_member in old_members.items():
if isinstance(old_member, griffe.Alias) and len(path) > 2:
# ignore imports in `/types/` for now, they're technically part of the public API
# but we don't have good preventative measures in place to prevent changing them
continue
new_member = new_members.get(name)
if new_member is None:
cls_name = old_member.__class__.__name__
yield Text(f"({cls_name})", style=Style(color="rgb(119, 119, 119)"))
yield from [" " for _ in range(10 - len(cls_name))]
yield f" {'.'.join(path)}.{name}"
yield "\n"
continue
yield from find_breaking_changes(new_member, old_member, path=[*path, name])
def main() -> None:
try:
against_ref = sys.argv[1]
except IndexError as err:
raise RuntimeError("You must specify a base ref to run breaking change detection against") from err
package = griffe.load(
"anthropic",
search_paths=[Path(__file__).parent.parent.joinpath("src")],
)
old_package = griffe.load_git(
"anthropic",
ref=against_ref,
search_paths=["src"],
)
assert isinstance(package, griffe.Module)
assert isinstance(old_package, griffe.Module)
output = list(find_breaking_changes(package, old_package, path=["anthropic"]))
if output:
rich.print(Text("Breaking changes detected!", style=Style(color="rgb(165, 79, 87)")))
rich.print()
for text in output:
rich.print(text, end="")
sys.exit(1)
main()
Domain
Subdomains
Dependencies
- griffe
- pathlib
- rich
- rich.style
- rich.text
- sys
- typing
Source
Frequently Asked Questions
What does detect-breaking-changes.py do?
detect-breaking-changes.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, SyncAPI subdomain.
What functions are defined in detect-breaking-changes.py?
detect-breaking-changes.py defines 3 function(s): find_breaking_changes, main, public_members.
What does detect-breaking-changes.py depend on?
detect-breaking-changes.py imports 7 module(s): griffe, pathlib, rich, rich.style, rich.text, sys, typing.
Where is detect-breaking-changes.py in the architecture?
detect-breaking-changes.py is located at scripts/detect-breaking-changes.py (domain: AnthropicClient, subdomain: SyncAPI, directory: scripts).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free