Skip to content

Conversation

sivasathyaseeelan
Copy link
Contributor

@sivasathyaseeelan sivasathyaseeelan commented Jul 7, 2025

(venv) [root@4b68cec572f1 vol]# python -m cinderx.compiler --static main.pyi
JIT: Jit/symbolizer.cpp:55 -- could not find symtab
πŸš€ Running all tests...

βœ… positive_success_f (input 1) β†’ returned: 5
βœ… positive_success_f (input 2) β†’ returned: 42
❌ positive_failure_f (input 1) β†’ raised: can only concatenate str (not "int") to str
βœ… positive_failure_f (input 2) β†’ returned: 42
βœ… negative_success_f (input 1) β†’ returned: 1
βœ… negative_success_f (input 2) β†’ returned: 6
βœ… negative_failure_f (input 1) β†’ returned: 1
❌ negative_failure_f (input 2) β†’ raised: object of type 'FinalInt' has no len()
❌ negative_failure_f (input 3) β†’ raised: object of type 'bool' has no len()
βœ… connectives_success_f (input 1) β†’ returned: 1
βœ… connectives_success_f (input 2) β†’ returned: 0
βœ… connectives_success_g (input 1) β†’ returned: 1
βœ… connectives_success_g (input 2) β†’ returned: 0
βœ… connectives_success_g (input 3) β†’ returned: 0
βœ… connectives_success_h (input 1) β†’ returned: 1
βœ… connectives_success_h (input 2) β†’ returned: 0
βœ… connectives_success_h (input 3) β†’ returned: 0
❌ connectives_failure_f (input 1) β†’ raised: can only concatenate str (not "int") to str
βœ… connectives_failure_f (input 2) β†’ returned: 0
❌ connectives_failure_g (input 1) β†’ raised: can only concatenate str (not "int") to str
βœ… connectives_failure_g (input 2) β†’ returned: 6
βœ… connectives_failure_g (input 3) β†’ returned: 0
❌ connectives_failure_h (input 1) β†’ raised: can only concatenate str (not "int") to str
βœ… connectives_failure_h (input 2) β†’ returned: 0
βœ… connectives_failure_h (input 3) β†’ returned: 0
βœ… nesting_body_success_f (input 1) β†’ returned: 0
βœ… nesting_body_success_f (input 2) β†’ returned: 6
βœ… nesting_body_success_f (input 3) β†’ returned: 0
βœ… nesting_body_failure_f (input 1) β†’ returned: 0
❌ nesting_body_failure_f (input 2) β†’ raised: object of type 'FinalInt' has no len()
βœ… nesting_body_failure_f (input 3) β†’ returned: 0
βœ… struct_fields_success_f (input 1) β†’ returned: 5
❌ struct_fields_failure_f (input 1) β†’ raised: expected 'int', got 'FinalStr'
βœ… tuple_elements_success_f (input 1) β†’ returned: 5
❌ tuple_elements_failure_f (input 1) β†’ raised: unsupported operand type(s) for +: 'FinalInt' and 'str'
βœ… tuple_length_success_f (input 1) β†’ returned: 3
βœ… tuple_length_success_f (input 2) β†’ returned: 1
βœ… tuple_length_failure_f (input 1) β†’ returned: 3
❌ tuple_length_failure_f (input 2) β†’ raised: expected 'int', got 'str'
βœ… alias_success_f (input 1) β†’ returned: 1
βœ… alias_success_f (input 2) β†’ returned: 42
❌ alias_failure_f (input 1) β†’ raised: can only concatenate str (not "int") to str
βœ… alias_failure_g (input 1) β†’ returned: 1
❌ nesting_condition_success_f (input 1) β†’ raised: nesting_condition_success_f() missing 1 required positional argument: 'y'
❌ nesting_condition_success_f (input 2) β†’ raised: nesting_condition_success_f() missing 1 required positional argument: 'y'
❌ nesting_condition_failure_f (input 1) β†’ raised: nesting_condition_failure_f() missing 1 required positional argument: 'y'
❌ nesting_condition_failure_f (input 2) β†’ raised: nesting_condition_failure_f() missing 1 required positional argument: 'y'
βœ… merge_with_union_success_f (input 1) β†’ returned: ahello
βœ… merge_with_union_success_f (input 2) β†’ returned: 6
βœ… merge_with_union_success_f (input 3) β†’ returned: 0
❌ merge_with_union_failure_f (input 1) β†’ raised: can only concatenate str (not "int") to str
βœ… merge_with_union_failure_f (input 2) β†’ returned: 7
βœ… merge_with_union_failure_f (input 3) β†’ returned: 0
βœ… predicate_2way_success_g (input 1) β†’ returned: 1
βœ… predicate_2way_success_g (input 2) β†’ returned: 5
❌ predicate_2way_failure_g (input 1) β†’ raised: can only concatenate str (not "int") to str
βœ… predicate_2way_failure_g (input 2) β†’ returned: 5
βœ… predicate_1way_success_g (input 1) β†’ returned: 0
βœ… predicate_1way_success_g (input 2) β†’ returned: 6
βœ… predicate_1way_failure_g (input 1) β†’ returned: 1
βœ… predicate_1way_failure_g (input 2) β†’ returned: 6
βœ… predicate_checked_success_g (input 1) β†’ returned: False
βœ… predicate_checked_success_g (input 2) β†’ returned: True
βœ… predicate_checked_success_g (input 3) β†’ returned: True
βœ… predicate_checked_failure_g (input 1) β†’ returned: False
βœ… predicate_checked_failure_g (input 2) β†’ returned: True
βœ… predicate_checked_failure_g (input 3) β†’ returned: False

πŸ“Š Summary:
Passed: 50
Failed: 17
(venv) [root@4b68cec572f1 vol]# python -m cinderx.compiler --static examples.pyi
JIT: Jit/symbolizer.cpp:55 -- could not find symtab
πŸš€ Running all tests...

βœ… filter_success β†’ returned: [2, 4]
βœ… filter_failure β†’ returned: ['a', 1, 'b', 2]
βœ… flatten_success β†’ returned: [1, 2, 3, 4, 5]
❌ flatten_failure β†’ raised: expected 'list', got 'int'
βœ… is_tree_node_success β†’ returned: True
βœ… is_tree_node_success β†’ returned: False
βœ… is_tree_node_failure β†’ returned: True
βœ… is_tree_node_failure β†’ returned: True
βœ… rainfall_success β†’ returned: 5.233333333333333
βœ… rainfall_failure β†’ returned: 5.233333333333333

πŸ“Š Summary:
Passed: 9
Failed: 1
(venv) [root@4b68cec572f1 vol]# 

Setup

cd cinder
docker run -v "$PWD:/vol" -w /vol -it --rm --entrypoint /bin/bash ghcr.io/facebookincubator/cinder-runtime:cinder-3.10
/cinder/bin/python3 -m venv /vol/venv
source /vol/venv/bin/activate
pip install -r /vol/requirements.txt
python -m cinderx.compiler --static main.pyi
python -m cinderx.compiler --static examples.pyi

Copy link
Member

@bennn bennn left a comment

Choose a reason for hiding this comment

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

To run the typechecker, try ./python -m cinderx.compiler --static main.pyi

@@ -0,0 +1,174 @@
from typing import Callable, TypeVar, Union, List, Dict, Optional, Tuple

Copy link
Member

Choose a reason for hiding this comment

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

add import __static__ and import __strict__
(per https://github.com/facebookincubator/cinder)

### Example tree_node
## success
TreeNodeSuccess = Tuple[int, List['TreeNodeSuccess']]
def is_tree_node_success(node: object) -> bool:
Copy link
Member

Choose a reason for hiding this comment

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

-> TypeGuard[TreeNodeSuccess]

@bennn
Copy link
Member

bennn commented Jul 8, 2025

Update: running the "typechecker" command ./python -m cinderx.compiler --static main.pyi doesn't seem to typecheck any code. We tried replacing the return statement of rainfall_failure with return "hello" and it didn't complain about float vs. string.

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.

2 participants