main() — fastapi Function Reference
Architecture documentation for the main() function in sponsors.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD 2551f96f_dafc_1264_4aa4_d4ca9c29d970["main()"] 056ab1dd_e9bf_db94_7561_c9133dc915c2["sponsors.py"] 2551f96f_dafc_1264_4aa4_d4ca9c29d970 -->|defined in| 056ab1dd_e9bf_db94_7561_c9133dc915c2 e9b739de_0cfd_85f5_029a_698cbb21a09e["get_individual_sponsors()"] 2551f96f_dafc_1264_4aa4_d4ca9c29d970 -->|calls| e9b739de_0cfd_85f5_029a_698cbb21a09e dcb347d6_8c86_b380_c197_49c4b43b5cf2["update_content()"] 2551f96f_dafc_1264_4aa4_d4ca9c29d970 -->|calls| dcb347d6_8c86_b380_c197_49c4b43b5cf2 style 2551f96f_dafc_1264_4aa4_d4ca9c29d970 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
scripts/sponsors.py lines 159–218
def main() -> None:
logging.basicConfig(level=logging.INFO)
settings = Settings()
logging.info(f"Using config: {settings.model_dump_json()}")
g = Github(settings.pr_token.get_secret_value())
repo = g.get_repo(settings.github_repository)
tiers = get_individual_sponsors(settings=settings)
keys = list(tiers.keys())
keys.sort(reverse=True)
sponsors = []
for key in keys:
sponsor_group = []
for login, sponsor in tiers[key].items():
sponsor_group.append(
{"login": login, "avatarUrl": sponsor.avatarUrl, "url": sponsor.url}
)
sponsors.append(sponsor_group)
github_sponsors = {
"sponsors": sponsors,
}
# For local development
# github_sponsors_path = Path("../docs/en/data/github_sponsors.yml")
github_sponsors_path = Path("./docs/en/data/github_sponsors.yml")
updated = update_content(
content_path=github_sponsors_path, new_content=github_sponsors
)
if not updated:
logging.info("The data hasn't changed, finishing.")
return
logging.info("Setting up GitHub Actions git user")
subprocess.run(["git", "config", "user.name", "github-actions[bot]"], check=True)
subprocess.run(
["git", "config", "user.email", "github-actions[bot]@users.noreply.github.com"],
check=True,
)
branch_name = f"fastapi-people-sponsors-{secrets.token_hex(4)}"
logging.info(f"Creating a new branch {branch_name}")
subprocess.run(["git", "checkout", "-b", branch_name], check=True)
logging.info("Adding updated file")
subprocess.run(
[
"git",
"add",
str(github_sponsors_path),
],
check=True,
)
logging.info("Committing updated file")
message = "👥 Update FastAPI People - Sponsors"
subprocess.run(["git", "commit", "-m", message], check=True)
logging.info("Pushing branch")
subprocess.run(["git", "push", "origin", branch_name], check=True)
logging.info("Creating PR")
pr = repo.create_pull(title=message, body=message, base="master", head=branch_name)
logging.info(f"Created PR: {pr.number}")
logging.info("Finished")
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does main() do?
main() is a function in the fastapi codebase, defined in scripts/sponsors.py.
Where is main() defined?
main() is defined in scripts/sponsors.py at line 159.
What does main() call?
main() calls 2 function(s): get_individual_sponsors, update_content.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free