Fix type checking + lint

This commit is contained in:
Thiago Moretto
2024-08-29 15:02:19 -03:00
parent 9a10cc15f4
commit c8c0a89dc6

View File

@@ -39,7 +39,7 @@ def parse_toml(content):
return simple_toml_parser(content) return simple_toml_parser(content)
def get_git_remote_url() -> str: def get_git_remote_url() -> str | None:
"""Get the Git repository's remote URL.""" """Get the Git repository's remote URL."""
try: try:
# Run the git remote -v command # Run the git remote -v command
@@ -63,6 +63,8 @@ def get_git_remote_url() -> str:
except FileNotFoundError: except FileNotFoundError:
console.print("Git command not found. Make sure Git is installed and in your PATH.", style="bold red") console.print("Git command not found. Make sure Git is installed and in your PATH.", style="bold red")
return None
def get_project_name(pyproject_path: str = "pyproject.toml"): def get_project_name(pyproject_path: str = "pyproject.toml"):
"""Get the project name from the pyproject.toml file.""" """Get the project name from the pyproject.toml file."""
@@ -83,7 +85,7 @@ def get_project_name(pyproject_path: str = "pyproject.toml"):
print(f"Error: {pyproject_path} not found.") print(f"Error: {pyproject_path} not found.")
except KeyError: except KeyError:
print(f"Error: {pyproject_path} is not a valid pyproject.toml file.") print(f"Error: {pyproject_path} is not a valid pyproject.toml file.")
except tomllib.TOMLDecodeError if sys.version_info >= (3, 11) else Exception as e: except tomllib.TOMLDecodeError if sys.version_info >= (3, 11) else Exception as e: # type: ignore
print( print(
f"Error: {pyproject_path} is not a valid TOML file." f"Error: {pyproject_path} is not a valid TOML file."
if sys.version_info >= (3, 11) if sys.version_info >= (3, 11)