Read as str no bytes

+handle when project_name is None (fails, basically)
This commit is contained in:
Thiago Moretto
2024-08-29 15:17:51 -03:00
parent c8c0a89dc6
commit cda1900b14
2 changed files with 6 additions and 2 deletions

View File

@@ -33,6 +33,10 @@ class DeployCommand:
raise SystemExit
self.project_name = get_project_name()
if self.project_name is None:
console.print("No project name found. Please ensure your project has a valid pyproject.toml file.", style="bold red")
raise SystemExit
self.client = CrewAPI(api_key=access_token)
def _handle_error(self, json_response: Dict[str, Any]) -> None:

View File

@@ -66,11 +66,11 @@ def get_git_remote_url() -> str | None:
return None
def get_project_name(pyproject_path: str = "pyproject.toml"):
def get_project_name(pyproject_path: str = "pyproject.toml") -> str | None:
"""Get the project name from the pyproject.toml file."""
try:
# Read the pyproject.toml file
with open(pyproject_path, "rb") as f:
with open(pyproject_path, "r") as f:
pyproject_content = parse_toml(f.read())
# Extract the project name