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

Track distant side effects of changes by doing an extra baseline run for linters #383

Closed
akaihola opened this issue Aug 28, 2022 · 0 comments · Fixed by #393
Closed

Track distant side effects of changes by doing an extra baseline run for linters #383

akaihola opened this issue Aug 28, 2022 · 0 comments · Fixed by #393
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@akaihola
Copy link
Owner

akaihola commented Aug 28, 2022

Problem: Darker only shows linter erros on modified lines. But e.g. when correcting a function signature, mypy easily finds the static typing errors in invocations on unmodified lines elsewhere in the same or other .py files.

Solution: Check out rev1, run the linters, and record their outputs as the baseline. Check out rev2, run them again, and record the result. Similar to Black and Flynt processing, parse git diff output. Hide only linter messages which

  1. fall on an equal chunk, and
  2. also appear in the recorded baseline with an identical messages and a line number corresponding to the chunk's location in rev1.

This still won't solve code moves between files, but it's still vastly better than the current algorithm.

Background:

We found prior art in basedmypy and flakehell baseline.

It seems that baseline support in basedmypy is still rather primitive – it uses a heuristic of scanning for the same type checking error within ±50 lines, which can of course lead to false positives/negatives. We should make use of information from git diff gives about moved code, as Darker already does when filtering modifications from Black (and soon Flynt).

I suspect the same applies to flakehell baseline since the baseline file is just a list of hashes, and it doesn't use a diff to track code moves.

Related: We're documenting the current shortcomings in #380.

Originally posted by @akaihola in #328 (reply in thread)

@akaihola akaihola self-assigned this Aug 28, 2022
@akaihola akaihola added the enhancement New feature or request label Aug 28, 2022
@akaihola akaihola added this to the 1.6.0 milestone Aug 28, 2022
@akaihola akaihola modified the milestones: 1.6.0, 1.6.1, 1.7.0 Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant