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

Improve multiline reporting #15273

Open
ikonst opened this issue May 20, 2023 · 3 comments
Open

Improve multiline reporting #15273

ikonst opened this issue May 20, 2023 · 3 comments
Labels

Comments

@ikonst
Copy link
Contributor

ikonst commented May 20, 2023

Current multiline error/notice reporting is hacky, e.g.

mypy/mypy/messages.py

Lines 1161 to 1169 in c1fb57d

self.note("Superclass:", context, offset=ALIGN_OFFSET + OFFSET, code=code)
self.pretty_callable_or_overload(
original,
context,
offset=ALIGN_OFFSET + 2 * OFFSET,
add_class_or_static_decorator=INCLUDE_DECORATOR,
allow_dups=ALLOW_DUPS,
code=code,
)

Notice how

  • we call notice multiple times even as it relates to the same core issue
  • we pass allow_dups=True to suppress deduplication of, say, the same type
  • we mistakenly(?) dedup the "Superclass:" and "Subclass:" notices
  • by always doing allow_dups=False, we can effectively dedup when it would make sense

I think it'll be better if the extra lines could be part of the error, also reducing code duplication (we end up passing a lot of the same parameters multiple times). Is there a reason why we didn't? Is it a pattern elsewhere in the code?

@hauntsaninja
Copy link
Collaborator

I think this would be great to do. It would help with cases like #11396 where the errors are being somewhat ad hoc reconstructed

@tusharsadhwani
Copy link
Contributor

tusharsadhwani commented Jun 3, 2023

I think it'll be better if the extra lines could be part of the error

Could you clarify a bit? Current self.fail() and self.note() situation is very granular indeed, but I can't think of any way that would let us abstract it away while also preserving the current amount of flexibility.

Do we collect the error/note lines before reporting them? Do we create some class that holds the lines?

@tusharsadhwani
Copy link
Contributor

@hauntsaninja Can you help clarify the solution? I can pick this up.

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

No branches or pull requests

3 participants