Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions mypy/stubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,14 @@ def get_description(self, concise: bool = False) -> str:
return _style(self.object_desc, bold=True) + " " + self.message

stub_line = None
stub_file: None = None
stub_file = None
if not isinstance(self.stub_object, Missing):
stub_line = self.stub_object.line
# TODO: Find a way of getting the stub file
# TODO: find out how we can get filenames from other nodes:
if isinstance(self.stub_object, nodes.TypeInfo):
stub_file = os.path.abspath(
self.stub_object.module_name.replace(".", os.path.sep) + ".pyi"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This might not be accurate. Sometimes stubtest's definitions come from .py files (e.g. with packages that have mixed inline types and stubs). While it's rare for such definitions to be involved in errors, it's possible, and it would be very confusing if we lied.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's also not necessarily the case that the stubs are relative to the current directory. They could be installed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes, this is more complex than I thought!

)

stub_loc_str = ""
if stub_line:
Expand Down