Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect type hint in experimental engine #155

Merged
merged 1 commit into from
Feb 28, 2025

Conversation

thomasaarholt
Copy link
Contributor

@thomasaarholt thomasaarholt commented Feb 28, 2025

This type hint was causing our Python 3.9 test suit to throw some type errors.

    def generate(self, content, system_prompt: Union[str | List[Union[str, bytes]]] = None, **kwargs):
E   TypeError: unsupported operand type(s) for |: 'type' and '_GenericAlias'

The typehint wasn't correct on any Python version, but Python 3.9 doesn't support | between types. The new hint is more correct, at least. Not sure why it can take a list[bytes] though.

@fralik
Copy link

fralik commented Feb 28, 2025

2 cents:
| syntax requires python >= 3.10, since textgrad is python >= 3.9 (

python_requires=">=3.9",
), then it's probably better to use , syntax.

@thomasaarholt
Copy link
Contributor Author

Ugh, I see my editor auto formatted it! Let me fix.

@thomasaarholt
Copy link
Contributor Author

@fralik, yep, that was what my edit did, but then my editor added tons of formatting noise. Fixed now.

That was the only case of | used for type hinting in the codebase, according to my grep.

@vinid
Copy link
Collaborator

vinid commented Feb 28, 2025

Thank you!

@vinid vinid added this pull request to the merge queue Feb 28, 2025
Merged via the queue into zou-group:main with commit 203685e Feb 28, 2025
2 checks passed
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