Skip to content

Add support for recursive datatypes checking#4647

Closed
y-vas wants to merge 2 commits into
reflex-dev:mainfrom
y-vas:main
Closed

Add support for recursive datatypes checking#4647
y-vas wants to merge 2 commits into
reflex-dev:mainfrom
y-vas:main

Conversation

@y-vas
Copy link
Copy Markdown

@y-vas y-vas commented Jan 16, 2025

All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

New Feature Submission:

  • Does your submission pass the tests?
  • Have you linted your code locally prior to submission?

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

After these steps, you're ready to open a pull request.

a. Give a descriptive title to your PR.

b. Describe your changes.


I did not added full test because I just wanted to fix it on my local enviroment...
but i hope it helps 

Recursive datatypes or ForwardRefs are detected as invalid 
```
from typing import Dict, List, Optional, ForwardRef, get_type_hints
DataType = List[Dict[str, Optional["DataType"]]]
```
example error:
```
web-app_1  |   File "/src/web_app/components/logSettings/tree.py", line 80, in _form_item
web-app_1  |     rx.text(   data_["title"]    ),
web-app_1  |                ~~~~~^^^^^^^^^
web-app_1  |   File "/src/.venv/lib/python3.11/site-packages/reflex/vars/object.py", line 193, in __getitem__
web-app_1  |     return ObjectItemOperation.create(self, key).guess_type()
web-app_1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
web-app_1  |   File "/src/.venv/lib/python3.11/site-packages/reflex/vars/base.py", line 781, in guess_type
web-app_1  |     raise TypeError(f"Unsupported type {var_type} for guess_type.")
web-app_1  | TypeError: Unsupported type ForwardRef('DataType') for guess_type.
```

c. Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such).

@Lendemor Lendemor requested a review from adhami3310 January 16, 2025 15:51
@adhami3310
Copy link
Copy Markdown
Member

hey there! that looks good, can we have some repro code? ideally it can be added to test cases but at the very least so we can test this PR

@adhami3310
Copy link
Copy Markdown
Member

This doesn't seem to work on the example above. I will be closing it for now until a more viable solution emerges.

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