main() — fastapi Function Reference
Architecture documentation for the main() function in contributors.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD 33126480_1652_4075_be09_22addb8f6752["main()"] cf4b5bfd_e515_e220_1b74_2b9dbfada762["contributors.py"] 33126480_1652_4075_be09_22addb8f6752 -->|defined in| cf4b5bfd_e515_e220_1b74_2b9dbfada762 7c05826d_e58f_1156_2d56_d4b1b1d17662["get_pr_nodes()"] 33126480_1652_4075_be09_22addb8f6752 -->|calls| 7c05826d_e58f_1156_2d56_d4b1b1d17662 fd24d1b1_d90e_7d94_aa7a_9cbcf808fa8a["get_contributors()"] 33126480_1652_4075_be09_22addb8f6752 -->|calls| fd24d1b1_d90e_7d94_aa7a_9cbcf808fa8a f797bbee_6e12_b81c_88e8_d1a80b53f1cd["get_users_to_write()"] 33126480_1652_4075_be09_22addb8f6752 -->|calls| f797bbee_6e12_b81c_88e8_d1a80b53f1cd 9b2f18cc_2f02_7681_cb1c_129629470781["update_content()"] 33126480_1652_4075_be09_22addb8f6752 -->|calls| 9b2f18cc_2f02_7681_cb1c_129629470781 style 33126480_1652_4075_be09_22addb8f6752 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
scripts/contributors.py lines 238–312
def main() -> None:
logging.basicConfig(level=logging.INFO)
settings = Settings()
logging.info(f"Using config: {settings.model_dump_json()}")
g = Github(settings.github_token.get_secret_value())
repo = g.get_repo(settings.github_repository)
pr_nodes = get_pr_nodes(settings=settings)
contributors_results = get_contributors(pr_nodes=pr_nodes)
authors = contributors_results.authors
top_contributors = get_users_to_write(
counter=contributors_results.contributors,
authors=authors,
)
top_translators = get_users_to_write(
counter=contributors_results.translators,
authors=authors,
)
top_translations_reviewers = get_users_to_write(
counter=contributors_results.translation_reviewers,
authors=authors,
)
# For local development
# contributors_path = Path("../docs/en/data/contributors.yml")
contributors_path = Path("./docs/en/data/contributors.yml")
# translators_path = Path("../docs/en/data/translators.yml")
translators_path = Path("./docs/en/data/translators.yml")
# translation_reviewers_path = Path("../docs/en/data/translation_reviewers.yml")
translation_reviewers_path = Path("./docs/en/data/translation_reviewers.yml")
updated = [
update_content(content_path=contributors_path, new_content=top_contributors),
update_content(content_path=translators_path, new_content=top_translators),
update_content(
content_path=translation_reviewers_path,
new_content=top_translations_reviewers,
),
]
if not any(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-contributors-{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(contributors_path),
str(translators_path),
str(translation_reviewers_path),
],
check=True,
)
logging.info("Committing updated file")
message = "👥 Update FastAPI People - Contributors and Translators"
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/contributors.py.
Where is main() defined?
main() is defined in scripts/contributors.py at line 238.
What does main() call?
main() calls 4 function(s): get_contributors, get_pr_nodes, get_users_to_write, update_content.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free