Home / Function/ format_file() — anthropic-sdk-python Function Reference

format_file() — anthropic-sdk-python Function Reference

Architecture documentation for the format_file() function in ruffen-docs.py from the anthropic-sdk-python codebase.

Function python AnthropicClient SyncAPI calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  b4018bb7_0839_2d9d_220a_52ca08d1a87c["format_file()"]
  3965d879_b0ae_9368_c20d_7ddc509b318b["ruffen-docs.py"]
  b4018bb7_0839_2d9d_220a_52ca08d1a87c -->|defined in| 3965d879_b0ae_9368_c20d_7ddc509b318b
  6349cc08_8f33_6ef3_b949_a683c0665aea["main()"]
  6349cc08_8f33_6ef3_b949_a683c0665aea -->|calls| b4018bb7_0839_2d9d_220a_52ca08d1a87c
  1ef0ada9_3a11_ea8f_5e8f_176327d79666["format_str()"]
  b4018bb7_0839_2d9d_220a_52ca08d1a87c -->|calls| 1ef0ada9_3a11_ea8f_5e8f_176327d79666
  style b4018bb7_0839_2d9d_220a_52ca08d1a87c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

scripts/utils/ruffen-docs.py lines 122–140

def format_file(
    filename: str,
    skip_errors: bool,
) -> int:
    with open(filename, encoding="UTF-8") as f:
        contents = f.read()
    new_contents, errors = format_str(contents)
    for error in errors:
        lineno = contents[: error.offset].count("\n") + 1
        print(f"{filename}:{lineno}: code block parse error {error.exc}")
    if errors and not skip_errors:
        return 1
    if contents != new_contents:
        print(f"{filename}: Rewriting...")
        with open(filename, "w", encoding="UTF-8") as f:
            f.write(new_contents)
        return 0
    else:
        return 0

Subdomains

Calls

Called By

Frequently Asked Questions

What does format_file() do?
format_file() is a function in the anthropic-sdk-python codebase, defined in scripts/utils/ruffen-docs.py.
Where is format_file() defined?
format_file() is defined in scripts/utils/ruffen-docs.py at line 122.
What does format_file() call?
format_file() calls 1 function(s): format_str.
What calls format_file()?
format_file() is called by 1 function(s): main.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free