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

Set role to data when creating an Optional from | None #285

Merged
merged 2 commits into from
Jan 13, 2023

Conversation

hoodmane
Copy link
Collaborator

This is not super important, but when converting | None to Optional the code sets the role incorrectly to class and so generates dead links.

Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

Please add tests 👍 I think is data only on 3.11 not 3.10.

@hoodmane
Copy link
Collaborator Author

It's also a data in Python 3.10 -- note that Optional is in _PYDATA_ANNOTATIONS so if an Optional is generated directly instead of via a conversion from A | None then it will get :py:data:. So the test can just ask for e.g., Union[str, None] and Optional[str] to produce the same output.

@gaborbernat gaborbernat merged commit 27dd8e7 into tox-dev:main Jan 13, 2023
@hoodmane hoodmane deleted the alternatives-optional-role branch January 13, 2023 18:45
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