-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
More than one target found for cross-reference with quotes around type annotation #10400
Comments
…e' and 'WorkerState' distributed/active_memory_manager.py:docstring of distributed.active_memory_manager.ActiveMemoryManagerExtension.pending:: WARNING: more than one target found for cross-reference 'TaskState': distributed.worker_state_machine.TaskState, distributed.scheduler.TaskState distributed/active_memory_manager.py:docstring of distributed.active_memory_manager.ActiveMemoryManagerExtension.pending:: WARNING: more than one target found for cross-reference 'WorkerState': distributed.worker_state_machine.WorkerState, distributed.scheduler.WorkerState distributed/active_memory_manager.py:docstring of distributed.active_memory_manager.ActiveMemoryManagerExtension.pending:: WARNING: more than one target found for cross-reference 'WorkerState': distributed.worker_state_machine.WorkerState, distributed.scheduler.WorkerState distributed/active_memory_manager.py:docstring of distributed.active_memory_manager.ActiveMemoryManagerExtension.workers_memory:: WARNING: more than one target found for cross-reference 'WorkerState': distributed.worker_state_machine.WorkerState, distributed.scheduler.WorkerState distributed/active_memory_manager.py:docstring of distributed.active_memory_manager.Suggestion.candidates:: WARNING: more than one target found for cross-reference 'WorkerState': distributed.worker_state_machine.WorkerState, distributed.scheduler.WorkerState distributed/active_memory_manager.py:docstring of distributed.active_memory_manager.Suggestion.ts:: WARNING: more than one target found for cross-reference 'TaskState': distributed.worker_state_machine.TaskState, distributed.scheduler.TaskState workaround for sphinx-doc/sphinx#10400
…e' and 'WorkerState' distributed/active_memory_manager.py:docstring of distributed.active_memory_manager.ActiveMemoryManagerExtension.pending:: WARNING: more than one target found for cross-reference 'TaskState': distributed.worker_state_machine.TaskState, distributed.scheduler.TaskState distributed/active_memory_manager.py:docstring of distributed.active_memory_manager.ActiveMemoryManagerExtension.pending:: WARNING: more than one target found for cross-reference 'WorkerState': distributed.worker_state_machine.WorkerState, distributed.scheduler.WorkerState distributed/active_memory_manager.py:docstring of distributed.active_memory_manager.ActiveMemoryManagerExtension.pending:: WARNING: more than one target found for cross-reference 'WorkerState': distributed.worker_state_machine.WorkerState, distributed.scheduler.WorkerState distributed/active_memory_manager.py:docstring of distributed.active_memory_manager.ActiveMemoryManagerExtension.workers_memory:: WARNING: more than one target found for cross-reference 'WorkerState': distributed.worker_state_machine.WorkerState, distributed.scheduler.WorkerState distributed/active_memory_manager.py:docstring of distributed.active_memory_manager.Suggestion.candidates:: WARNING: more than one target found for cross-reference 'WorkerState': distributed.worker_state_machine.WorkerState, distributed.scheduler.WorkerState distributed/active_memory_manager.py:docstring of distributed.active_memory_manager.Suggestion.ts:: WARNING: more than one target found for cross-reference 'TaskState': distributed.worker_state_machine.TaskState, distributed.scheduler.TaskState workaround for sphinx-doc/sphinx#10400
I don't think this is fixable very easily because sphinx imports the concrete type and uses typing.get_type_hints to resolve the annotation, anything in "if TYPE_CHECKING:` will become a ForwardRef |
I think the only workaround here is as documented in https://github.com/agronholm/sphinx-autodoc-typehints#dealing-with-circular-imports #!/usr/bin/env python
from __future__ import annotations
from crate_anon.anonymise import patient
class AlterMethod:
"""
AlterMethod class
"""
def alter(
self,
patient: patient.Patient = None,
) -> None:
"""
alter method
""" |
@graingert Apologies for the delay in replying. I can confirm that your workaround works. Thank you! |
Describe the bug
If you have two classes with the same name and have quotes around a type annotation when referencing one of them, you get the warning
more than one target found for cross-reference
If you import the class normally, it works fine. In the real world case I need to use quotes to avoid circular dependencies.
How to Reproduce
You get the error:
Expected behavior
Sphinx should be able to resolve the cross reference and not produce a warning.
Your project
https://github.com/martinburchell/sphinx-test (minimal test case based on https://github.com/RudolfCardinal/crate)
Screenshots
No response
OS
Linux
Python version
3.8.10
Sphinx version
4.4.0, 4.5.0, latest 5.x from GitHub
Sphinx extensions
sphinx.ext.autodoc
Extra tools
No response
Additional context
Works in 4.2.0, 4.3.0, 4.3.1, 4.3.2
Broken since:
Fix #9899: py domain: Allows cross-reference specifier to :type: option
commit acaf705
The text was updated successfully, but these errors were encountered: