Skip to content

Conversation

@riturajFi
Copy link
Contributor

@riturajFi riturajFi commented Sep 5, 2025

Solves: #485

Description
This update introduces strongly typed Python definitions for:

Input Types

API request and response objects

FlowContext types across all step files

It also resolves the previous issue where nested objects were incorrectly inferred as unknown in Python type definitions.

@vercel
Copy link

vercel bot commented Sep 5, 2025

@riturajFi is attempting to deploy a commit to the motia Team on Vercel.

A member of the Team first needs to authorize it.

@riturajFi riturajFi marked this pull request as draft September 5, 2025 12:24
@riturajFi riturajFi force-pushed the feat/motia_python_types_ branch from 2cc67e3 to ef637c1 Compare September 9, 2025 20:36
@riturajFi riturajFi marked this pull request as ready for review September 11, 2025 08:37
@riturajFi
Copy link
Contributor Author

@sergiofilhowz would like your review on the PR regarding functionality, code quality, edge cases etc on this PR.

@rohitg00
Copy link
Contributor

Hey @riturajFi, Thanks for your contribution - This is big!

Team is going to review this as soon as possible, currently working on a big release for the cloud.

@riturajFi riturajFi marked this pull request as draft September 17, 2025 02:33
@riturajFi riturajFi force-pushed the feat/motia_python_types_ branch from 80c38d6 to e304aec Compare September 22, 2025 13:33
@rohitg00
Copy link
Contributor

Hey @riturajFi, how's it going? Do you need any help here?

@riturajFi
Copy link
Contributor Author

Hey @riturajFi, how's it going? Do you need any help here?

Hi @rohitg00 sorry for the delay - this will be done shortly

@riturajFi riturajFi force-pushed the feat/motia_python_types_ branch 2 times, most recently from 8757c84 to 4f08e58 Compare October 1, 2025 08:33
@riturajFi riturajFi marked this pull request as ready for review October 1, 2025 12:49
@riturajFi riturajFi force-pushed the feat/motia_python_types_ branch from 0b3739d to a29b6df Compare October 2, 2025 13:47
@riturajFi
Copy link
Contributor Author

riturajFi commented Oct 4, 2025

Hi @sergiofilhowz @mfpiccolo @rohitg00 would love a review of the code and approach

@riturajFi riturajFi force-pushed the feat/motia_python_types_ branch from a29b6df to f10bec2 Compare October 5, 2025 08:49
@rohitg00
Copy link
Contributor

rohitg00 commented Oct 6, 2025

Thanks @riturajFi, we will review it this week. Thanks again.

@sergiofilhowz
Copy link
Contributor

Thank you @riturajFi I checked your PR and it looks great, I need to test to understand how it ties to Motia Cloud and Motia self-host deployment. This PR is a solid contribution, but I appreciate your patience and hope you understand this can take some time to be merged.

import importlib.util
import os
import platform
from dataclasses import asdict, is_dataclass

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'asdict' is not used.
Import of 'is_dataclass' is not used.
class ApiMiddleware[
TBody = object,
TEmitData = Never,
TResult = object,

Check failure

Code scanning / CodeQL

Syntax error Error

Syntax Error (in Python 3).
from motia_middleware import compose_middleware
from motia_rpc_stream_manager import RpcStreamManager
from motia_dot_dict import DotDict
from dataclasses import asdict, is_dataclass

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'asdict' is not used.
Import of 'is_dataclass' is not used.
@riturajFi
Copy link
Contributor Author

riturajFi commented Oct 8, 2025

Thank you @riturajFi I checked your PR and it looks great, I need to test to understand how it ties to Motia Cloud and Motia self-host deployment. This PR is a solid contribution, but I appreciate your patience and hope you understand this can take some time to be merged.

Absolutely! If the current approach proves effective, my next steps will be as follows:

  1. Enhance consistency and structure – Review and streamline file naming conventions (e.g., within the Motia folder) and eliminate any redundancies.
  2. Transition to Pydantic models – Replace TypedDicts with Pydantic types to improve validation and maintainability. (TypedDicts were initially used to align with the existing Python typing patterns.)
  3. Develop comprehensive test cases – Implement robust testing to ensure the reliability and accuracy of the system.
  4. Integrate with Motia Cloud – Determine how this component connects and interacts within the broader Motia Cloud ecosystem.
  5. Design an AI-driven typing framework – Draft a generic plan for enabling AI to generate similar typing protocols across multiple programming languages.
  6. Execute end-to-end testing – Validate the entire workflow through E2E test execution.

Current Concerns

The current workflow involves generating types in the following sequence:

Python file → TypeScript generics generated → Parsed back into Python types

This indirect approach was necessary to maintain consistency between the Python types and the TypeScript generics used in Motia operations.


All things considered, with a bit more work—perhaps over the weekend—everything should be fully aligned and complete.


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.

3 participants