Not all new mypy
type checking errors are shown by Darker
#328
Replies: 5 comments 16 replies
-
Hi @PatrickJordanCongenica, thanks for your report! The You could try to diagnose by doing the following:
I hope you get some insight by doing these steps, and please do paste any interesting findings here so we can look at it together! |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply @akaihola. Please find below the output of what you recommended.
Before I continue with the rest of the steps from your answer, is it worth pausing here for you to have a look at the output above? The final line does hint at a possible cause: |
Beta Was this translation helpful? Give feedback.
-
This is a really good problem report, since it clarified my thoughts about Darker's applicability to filtering Darker only reports type violations on modified lines, but as we see, changes in code will often trigger type violations in other, unmodified parts of the file, or, as in this case, in completely different files which weren't modified at all. To find new typing errors introduced by changes to a repository between revisions
I'm not sure if the line number information for typing errors is useful at all – maybe a more exact matching could be done with help from the diff and possibly assuming that the errors come in the same order. But as the order actually will change if functions or classes are reordered inside a file, maybe that's not a good idea, and matching indeed should be based only on line content. This approach doesn't care at all about which files and lines were modified, so this isn't actually a good fit for Darker if we consider what it attempts to do. So perhaps running On the other hand, I have successfully used Darker and |
Beta Was this translation helpful? Give feedback.
-
I just ran into flakehell which is also based on the idea of comparing two linter runs on different revisions of the code base. They call this approach "legacy first" or "baseline":
I tried it: $ flakehell baseline
9da31f51c40118197ba315c9b1fcee9a
7e83108226550b5edefc5745d6d3b322
99f0dd7bf2ae35168b544256692518af So it seems the baseline is a collection of hashes for check failures. Also note that you need to |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I've wanted to move away from
pre-commit
for a while and use the various Python formatters and linters directly, but didn't like howpylint
takes to run as it scans your entire code base rather than just the files that have changed. Then I strolled across your execellent work here, so just wanted to thank you all for providing this library!I've got
darker
up and running in mypoetry
managed code base using the following configuration:When I run
poetry run task changed_code
, I can seeblack
,isort
andpylint
run (by manually making changes to a file that would trigger each of these tools) butmypy
doesn't seem to run.As you can see from above, I'm making use of
taskipy
to abbreviate some commands and when I runpoetry run task mypy
, I get feedback that an intentional change I made violates some of the checksmypy
does:However, running
poetry run task changed_code
doesn't output the same feedback, even with specifyingmypy
in the[tool.darker]
pyproject.toml
configuration.Am I doing something wrong here?
Beta Was this translation helpful? Give feedback.
All reactions