You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the top-level of a git repo has an __init__.py in it, then the step that does
git worktree add --quiet --force --force /tmp/tmpF00/baseline-revision HEAD
will create a file baseline-revision/__init__.py. When mypy sees this, it expects "baseline-revision" to be a valid python package name. But it's not because of the hyphen.
python/mypy#8400 talks a bit about this issue, and there are folks asking for a way to suppress it.
But there's a simple fix in Darker, like
diff --git a/src/darker/linting.py b/src/darker/linting.py
index bc2055f..1e285d6 100644
--- a/src/darker/linting.py+++ b/src/darker/linting.py@@ -524,7 +524,7 @@ def _get_messages_from_linters_for_baseline(
"""
with TemporaryDirectory() as tmpdir:
- tmp_path = Path(tmpdir) / "baseline-revision"+ tmp_path = Path(tmpdir) / "baseline-revision" / root.name
with git_clone_local(root, revision, tmp_path) as clone_root:
rev1_commit = git_rev_parse(revision, root)
result = _get_messages_from_linters(
i.e., always create the worktree in a subfolder of "baseline-revision". Sharing the same name as where the repo is checked out should be most reliable. (E.g. if the project config assumes the top-level of the git repo is in PYTHONPATH).
Describe the bug
If the top-level of a git repo has an
__init__.py
in it, then the step that doeswill create a file
baseline-revision/__init__.py
. When mypy sees this, it expects "baseline-revision" to be a valid python package name. But it's not because of the hyphen.python/mypy#8400 talks a bit about this issue, and there are folks asking for a way to suppress it.
But there's a simple fix in Darker, like
i.e., always create the worktree in a subfolder of "baseline-revision". Sharing the same name as where the repo is checked out should be most reliable. (E.g. if the project config assumes the top-level of the git repo is in PYTHONPATH).
To Reproduce
Steps to reproduce the behavior:
__init__.py
at the top level and any other)darker -vvv --lint --check --lint "mypy --follow-imports=silent" api/controller/sysroot.py
"-vvv" will show the output, "baseline-revision is not a valid Python package name".
Otherwise, the effect is just to treat the baseline as having no errors, so all mypy errors on the files are emitted, without filtering.
Expected behavior
Just new mypy errors to be emitted.
Tested with:
The text was updated successfully, but these errors were encountered: