Skip to content

Fixes typing issues using mypy#122

Open
Mbeaulne wants to merge 1 commit into02-24-run_ruff_on_codebasefrom
02-24-adds_mypy_and_fixes_types
Open

Fixes typing issues using mypy#122
Mbeaulne wants to merge 1 commit into02-24-run_ruff_on_codebasefrom
02-24-adds_mypy_and_fixes_types

Conversation

@Mbeaulne
Copy link
Collaborator

@Mbeaulne Mbeaulne commented Feb 25, 2026

TL;DR

Added comprehensive type annotations and improved type safety across the codebase, along with mypy configuration and dependency updates.

What changed?

  • Type annotations: Added explicit type hints to function signatures, return types, and variable declarations throughout the backend
  • Null safety: Added null checks for database queries and API responses, raising appropriate HTTP 404 errors when resources are not found
  • Type casting: Added explicit type casting for database query results and API responses to ensure type safety
  • MyPy configuration: Updated pyproject.toml with mypy settings including namespace packages and explicit package bases
  • Dependencies: Added types-pyyaml for better YAML type checking
  • Error handling: Improved error handling for missing execution nodes and invalid component specifications

How to test?

  1. Run the existing test suite to ensure no regressions
  2. Verify mypy passes with mypy cloud_pipelines_backend/
  3. Test API endpoints that query for non-existent resources to confirm proper 404 responses
  4. Test pipeline creation with missing component specifications to verify error handling

Why make this change?

This change improves code reliability and maintainability by:

  • Catching type-related bugs at development time rather than runtime
  • Making the codebase more self-documenting through explicit type annotations
  • Providing better IDE support and developer experience
  • Ensuring proper error responses for missing resources instead of potential crashes

Copy link
Collaborator Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Mbeaulne Mbeaulne mentioned this pull request Feb 25, 2026
@Mbeaulne Mbeaulne changed the title Adds mypy and fixes types Fixes typing issues using mypy Feb 25, 2026
@Mbeaulne Mbeaulne marked this pull request as ready for review February 25, 2026 01:41
@Mbeaulne Mbeaulne requested a review from Ark-kun as a code owner February 25, 2026 01:41
Copy link
Collaborator

Same stance on this as #121 in the stack.

# hf_uri = huggingface_repo_storage.HuggingFaceRepoUri.parse(uri)
download_input_uris[uri] = container_path
return container_path
return str(container_path)
Copy link
Contributor

@Ark-kun Ark-kun Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

container_path returned by .as_posix() is str

if self.has_ended:
try:
return (
log_text: str = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.download_as_text() already returns str, doesn't it?

import secrets

from starlette.middleware.base import BaseHTTPMiddleware
from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JFYI: We try to add modules, not individual attributes.

@Mbeaulne Mbeaulne force-pushed the 02-24-run_ruff_on_codebase branch from ecc21cd to 8c96ada Compare February 25, 2026 13:10
@Mbeaulne Mbeaulne force-pushed the 02-24-adds_mypy_and_fixes_types branch 2 times, most recently from 024e961 to 534c5d6 Compare February 25, 2026 13:11
@Mbeaulne Mbeaulne force-pushed the 02-24-run_ruff_on_codebase branch 2 times, most recently from e72e2ef to 8d58045 Compare February 25, 2026 18:34
@Mbeaulne Mbeaulne force-pushed the 02-24-adds_mypy_and_fixes_types branch 2 times, most recently from 775604f to ecfe5a8 Compare February 25, 2026 18:52
@Mbeaulne Mbeaulne force-pushed the 02-24-run_ruff_on_codebase branch from 8d58045 to 101fd7b Compare February 25, 2026 18:52
Copy link
Collaborator

@morgan-wowk morgan-wowk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same approval stance as #121

@Mbeaulne Mbeaulne force-pushed the 02-24-run_ruff_on_codebase branch from 101fd7b to 560525e Compare February 25, 2026 22:00
@Mbeaulne Mbeaulne force-pushed the 02-24-adds_mypy_and_fixes_types branch from ecfe5a8 to f8f0323 Compare February 25, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants