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

python domain: support unary subtraction operator (ast.USub) during annotation parsing #11904

Conversation

jayaddison
Copy link
Contributor

@jayaddison jayaddison commented Jan 21, 2024

Feature or Bugfix

  • Bugfix

Purpose

  • Allow negative literal integers expressed using the unary subtraction operator when parsing Python type annotations.

Detail

  • Unary addition is not supported since literals such as +2 resolves to 2.
  • Unusual edge cases could remain - this does not attempt to handle foo[1+2j] for example -- but that seems unlikely to be a likely annotation (?).
  • Strictly speaking, does not add test coverage for the intersphinx case mentioned in the test bugreport; but I believe that these changes will solve the problem.

Relates

@AA-Turner AA-Turner merged commit 2418e00 into sphinx-doc:master Jan 21, 2024
22 checks passed
@jayaddison jayaddison deleted the issue-11900/reftarget-parse-unary-subtraction branch January 21, 2024 14:35
@nulano
Copy link

nulano commented Jan 21, 2024

Thank you, I can confirm the reference is resolved with sphinx installed from master.

@jayaddison
Copy link
Contributor Author

You're welcome - thanks for taking the time to check and confirm the results!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reference target not found for typing.Literal with negative integer argument
3 participants