Skip to content

Cinder#28

Open
sivasathyaseeelan wants to merge 3 commits intoutahplt:mainfrom
sivasathyaseeelan:cinder
Open

Cinder#28
sivasathyaseeelan wants to merge 3 commits intoutahplt:mainfrom
sivasathyaseeelan:cinder

Conversation

@sivasathyaseeelan
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread cinder/examples.pyi
@@ -0,0 +1,174 @@
from typing import Callable, TypeVar, Union, List, Dict, Optional, Tuple

Copy link
Copy Markdown
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)

Comment thread cinder/examples.pyi
### Example tree_node
## success
TreeNodeSuccess = Tuple[int, List['TreeNodeSuccess']]
def is_tree_node_success(node: object) -> bool:
Copy link
Copy Markdown
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
Copy Markdown
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