Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/codegen/cli/workspace/initialize_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
Tuple of (codegen_folder, docs_folder, examples_folder)
"""
repo = get_git_repo()
REPO_PATH = Path(repo.workdir)

Check failure on line 39 in src/codegen/cli/workspace/initialize_workspace.py

View workflow job for this annotation

GitHub Actions / mypy

error: Item "None" of "Repository | None" has no attribute "workdir" [union-attr]
CODEGEN_FOLDER = REPO_PATH / CODEGEN_DIR
PROMPTS_FOLDER = REPO_PATH / PROMPTS_DIR
DOCS_FOLDER = REPO_PATH / DOCS_DIR
Expand All @@ -59,7 +59,7 @@
CODEMODS_DIR.mkdir(parents=True, exist_ok=True)

# Initialize virtual environment
status_obj.update(f" {'Creating' if isinstance(status, str) else 'Checking'} virtual environment...")

Check failure on line 62 in src/codegen/cli/workspace/initialize_workspace.py

View workflow job for this annotation

GitHub Actions / mypy

error: Item "None" of "Status | None" has no attribute "update" [union-attr]
venv = VenvManager()
if not venv.is_initialized():
venv.create_venv()
Expand All @@ -78,44 +78,43 @@
if not repo:
rich.print("No git repository found. Please run this command in a git repository.")
else:
status_obj.update(f" {'Updating' if isinstance(status, Status) else status} .gitignore...")

Check failure on line 81 in src/codegen/cli/workspace/initialize_workspace.py

View workflow job for this annotation

GitHub Actions / mypy

error: Item "None" of "Status | None" has no attribute "update" [union-attr]
modify_gitignore(CODEGEN_FOLDER)

# Create or update config.toml with basic repo info
if not session: # Only create if session doesn't exist (it handles config itself)
org_name, repo_name = get_git_organization_and_repo(repo)
config = {}
if CONFIG_PATH.exists():
config = toml.load(CONFIG_PATH)
config.update(
{
"organization_name": config.get("organization_name", org_name),
"repo_name": config.get("repo_name", repo_name),
}
)
CONFIG_PATH.write_text(toml.dumps(config))
org_name, repo_name = get_git_organization_and_repo(repo)
config = {}
if CONFIG_PATH.exists():
config = toml.load(CONFIG_PATH)
config.update(
{
"organization_name": config.get("organization_name", org_name),
"repo_name": config.get("repo_name", repo_name),
}
)
CONFIG_PATH.write_text(toml.dumps(config))

# Create notebook template
create_notebook(JUPYTER_DIR)

# Only fetch docs and examples if requested and session is provided
if fetch_docs and session:
status_obj.update("Fetching latest docs & examples...")

Check failure on line 102 in src/codegen/cli/workspace/initialize_workspace.py

View workflow job for this annotation

GitHub Actions / mypy

error: Item "None" of "Status | None" has no attribute "update" [union-attr]
shutil.rmtree(DOCS_FOLDER, ignore_errors=True)
shutil.rmtree(EXAMPLES_FOLDER, ignore_errors=True)

DOCS_FOLDER.mkdir(parents=True, exist_ok=True)
EXAMPLES_FOLDER.mkdir(parents=True, exist_ok=True)

response = RestAPI(session.token).get_docs()

Check failure on line 109 in src/codegen/cli/workspace/initialize_workspace.py

View workflow job for this annotation

GitHub Actions / mypy

error: Incompatible types in assignment (expression has type "dict[Any, Any]", variable has type "Response") [assignment]
populate_api_docs(DOCS_FOLDER, response.docs, status_obj)

Check failure on line 110 in src/codegen/cli/workspace/initialize_workspace.py

View workflow job for this annotation

GitHub Actions / mypy

error: "Response" has no attribute "docs" [attr-defined]

Check failure on line 110 in src/codegen/cli/workspace/initialize_workspace.py

View workflow job for this annotation

GitHub Actions / mypy

error: Argument 3 to "populate_api_docs" has incompatible type "Status | None"; expected "Status" [arg-type]
populate_examples(session, EXAMPLES_FOLDER, response.examples, status_obj)

Check failure on line 111 in src/codegen/cli/workspace/initialize_workspace.py

View workflow job for this annotation

GitHub Actions / mypy

error: "Response" has no attribute "examples" [attr-defined]

Check failure on line 111 in src/codegen/cli/workspace/initialize_workspace.py

View workflow job for this annotation

GitHub Actions / mypy

error: Argument 4 to "populate_examples" has incompatible type "Status | None"; expected "Status" [arg-type]

# Set programming language
if programming_language:
session.config.programming_language = programming_language
else:
session.config.programming_language = str(response.language)

Check failure on line 117 in src/codegen/cli/workspace/initialize_workspace.py

View workflow job for this annotation

GitHub Actions / mypy

error: "Response" has no attribute "language" [attr-defined]

session.write_config()

Expand Down