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

Find a way to make sphinx output in tests more predictable #194

Open
flying-sheep opened this issue Jan 5, 2022 · 3 comments
Open

Find a way to make sphinx output in tests more predictable #194

flying-sheep opened this issue Jan 5, 2022 · 3 comments

Comments

@flying-sheep
Copy link
Contributor

flying-sheep commented Jan 5, 2022

The Sphinx output changes depending on if PEP 604 Union syntax is used. It’s not about from __future__ import annotations, it’s about actually using the syntax!

Even on versions < 3.10, a simple type like int gets compiled to different things, depending on what syntax is used in the file:

  • "int" if the file contains no new-style union syntax,
  • *int* if the file contains new-style union syntax,

E.g. when you don‘t use | union syntax,

from __future__ import annotations

def function(x: bool) -> str: ...

gets compiled to ":

...
Parameters:
   * **x** ("bool") -- foo

And when you do use | union syntax anywhere in the file (or is it just anywhere in the compilation unit?),

from __future__ import annotations

def function(x: bool) -> str | int: ...

gets compiled to *:

...
Parameters:
   * **x** (*bool*) -- foo
@gaborbernat
Copy link
Member

A PR for this would we welcome.

@flying-sheep
Copy link
Contributor Author

Idk what the best approach is, or even where to fix this. Can we configure Sphinx to produce more predictable output? Or do we need an upstream change there?

@gaborbernat
Copy link
Member

That would be to discover 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants