Skip to content

Commit c66f7ad

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 9318ec2 commit c66f7ad

File tree

4 files changed

+37
-32
lines changed

4 files changed

+37
-32
lines changed

src/setuptools_scm/_file_finders/git.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ def _git_toplevel(path: str) -> str | None:
2828
# CI environments you can easily end up in a cloned repo
2929
# with incorrect permissions and we don't want to silently
3030
# ignore files.
31-
if '--add safe.directory' in res.stderr:
31+
if "--add safe.directory" in res.stderr:
3232
log.error(res.stderr)
33-
raise SystemExit("git introspection failed: %s" % res.stderr.split('\n')[0])
33+
raise SystemExit(
34+
"git introspection failed: %s" % res.stderr.split("\n")[0]
35+
)
3436
# BAIL if there is no commit
3537
warnings.warn("listing git files failed - pretending there aren't any")
3638
return None

testing/test_file_finder.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,21 @@ def _sep(paths: Iterable[str]) -> set[str]:
5050
return {path.replace("/", os.path.sep) for path in paths}
5151

5252

53-
@pytest.mark.filterwarnings('ignore:listing git files failed')
53+
@pytest.mark.filterwarnings("ignore:listing git files failed")
5454
def test_basic(inwd: WorkDir) -> None:
5555
assert set(find_files()) == _sep({"file1", "adir/filea", "bdir/fileb"})
5656
assert set(find_files(".")) == _sep({"./file1", "./adir/filea", "./bdir/fileb"})
5757
assert set(find_files("adir")) == _sep({"adir/filea"})
5858

5959

60-
@pytest.mark.filterwarnings('ignore:listing git files failed')
60+
@pytest.mark.filterwarnings("ignore:listing git files failed")
6161
def test_whitespace(inwd: WorkDir) -> None:
6262
(inwd.cwd / "adir" / "space file").touch()
6363
inwd.add_and_commit()
6464
assert set(find_files("adir")) == _sep({"adir/space file", "adir/filea"})
6565

6666

67-
@pytest.mark.filterwarnings('ignore:listing git files failed')
67+
@pytest.mark.filterwarnings("ignore:listing git files failed")
6868
def test_case(inwd: WorkDir) -> None:
6969
(inwd.cwd / "CamelFile").touch()
7070
(inwd.cwd / "file2").touch()
@@ -74,7 +74,7 @@ def test_case(inwd: WorkDir) -> None:
7474
)
7575

7676

77-
@pytest.mark.filterwarnings('ignore:listing git files failed')
77+
@pytest.mark.filterwarnings("ignore:listing git files failed")
7878
@pytest.mark.skipif(
7979
os.path.normcase("B") != os.path.normcase("b"), reason="case sensitive filesystem"
8080
)
@@ -88,22 +88,22 @@ def test_case_cwd_evil(inwd: WorkDir, monkeypatch: pytest.MonkeyPatch) -> None:
8888
)
8989

9090

91-
@pytest.mark.filterwarnings('ignore:listing git files failed')
91+
@pytest.mark.filterwarnings("ignore:listing git files failed")
9292
@pytest.mark.skipif(sys.platform == "win32", reason="symlinks to dir not supported")
9393
def test_symlink_dir(inwd: WorkDir) -> None:
9494
(inwd.cwd / "adir" / "bdirlink").symlink_to("../bdir")
9595
inwd.add_and_commit()
9696
assert set(find_files("adir")) == _sep({"adir/filea", "adir/bdirlink/fileb"})
9797

9898

99-
@pytest.mark.filterwarnings('ignore:listing git files failed')
99+
@pytest.mark.filterwarnings("ignore:listing git files failed")
100100
@pytest.mark.skipif(sys.platform == "win32", reason="symlinks to dir not supported")
101101
def test_symlink_dir_source_not_in_scm(inwd: WorkDir) -> None:
102102
(inwd.cwd / "adir" / "bdirlink").symlink_to("../bdir")
103103
assert set(find_files("adir")) == _sep({"adir/filea"})
104104

105105

106-
@pytest.mark.filterwarnings('ignore:listing git files failed')
106+
@pytest.mark.filterwarnings("ignore:listing git files failed")
107107
@pytest.mark.skipif(
108108
sys.platform == "win32", reason="symlinks to files not supported on windows"
109109
)
@@ -115,7 +115,7 @@ def test_symlink_file(inwd: WorkDir) -> None:
115115
) # -> ../file1
116116

117117

118-
@pytest.mark.filterwarnings('ignore:listing git files failed')
118+
@pytest.mark.filterwarnings("ignore:listing git files failed")
119119
@pytest.mark.skipif(
120120
sys.platform == "win32", reason="symlinks to files not supported on windows"
121121
)
@@ -124,15 +124,15 @@ def test_symlink_file_source_not_in_scm(inwd: WorkDir) -> None:
124124
assert set(find_files("adir")) == _sep({"adir/filea"})
125125

126126

127-
@pytest.mark.filterwarnings('ignore:listing git files failed')
127+
@pytest.mark.filterwarnings("ignore:listing git files failed")
128128
@pytest.mark.skipif(sys.platform == "win32", reason="symlinks to dir not supported")
129129
def test_symlink_loop(inwd: WorkDir) -> None:
130130
(inwd.cwd / "adir" / "loop").symlink_to("../adir")
131131
inwd.add_and_commit()
132132
assert set(find_files("adir")) == _sep({"adir/filea", "adir/loop"}) # -> ../adir
133133

134134

135-
@pytest.mark.filterwarnings('ignore:listing git files failed')
135+
@pytest.mark.filterwarnings("ignore:listing git files failed")
136136
@pytest.mark.skipif(sys.platform == "win32", reason="symlinks to dir not supported")
137137
def test_symlink_loop_outside_path(inwd: WorkDir) -> None:
138138
(inwd.cwd / "bdir" / "loop").symlink_to("../bdir")
@@ -141,15 +141,15 @@ def test_symlink_loop_outside_path(inwd: WorkDir) -> None:
141141
assert set(find_files("adir")) == _sep({"adir/filea", "adir/bdirlink/fileb"})
142142

143143

144-
@pytest.mark.filterwarnings('ignore:listing git files failed')
144+
@pytest.mark.filterwarnings("ignore:listing git files failed")
145145
@pytest.mark.skipif(sys.platform == "win32", reason="symlinks to dir not supported")
146146
def test_symlink_dir_out_of_git(inwd: WorkDir) -> None:
147147
(inwd.cwd / "adir" / "outsidedirlink").symlink_to(os.path.join(__file__, ".."))
148148
inwd.add_and_commit()
149149
assert set(find_files("adir")) == _sep({"adir/filea"})
150150

151151

152-
@pytest.mark.filterwarnings('ignore:listing git files failed')
152+
@pytest.mark.filterwarnings("ignore:listing git files failed")
153153
@pytest.mark.skipif(
154154
sys.platform == "win32", reason="symlinks to files not supported on windows"
155155
)
@@ -159,7 +159,7 @@ def test_symlink_file_out_of_git(inwd: WorkDir) -> None:
159159
assert set(find_files("adir")) == _sep({"adir/filea"})
160160

161161

162-
@pytest.mark.filterwarnings('ignore:listing git files failed')
162+
@pytest.mark.filterwarnings("ignore:listing git files failed")
163163
@pytest.mark.parametrize("path_add", ["{cwd}", "{cwd}" + os.pathsep + "broken"])
164164
def test_ignore_root(
165165
inwd: WorkDir, monkeypatch: pytest.MonkeyPatch, path_add: str
@@ -168,7 +168,7 @@ def test_ignore_root(
168168
assert find_files() == []
169169

170170

171-
@pytest.mark.filterwarnings('ignore:listing git files failed')
171+
@pytest.mark.filterwarnings("ignore:listing git files failed")
172172
def test_empty_root(inwd: WorkDir) -> None:
173173
subdir = inwd.cwd / "cdir" / "subdir"
174174
subdir.mkdir(parents=True)
@@ -177,7 +177,7 @@ def test_empty_root(inwd: WorkDir) -> None:
177177
assert set(find_files("cdir")) == _sep({"cdir/subdir/filec"})
178178

179179

180-
@pytest.mark.filterwarnings('ignore:listing git files failed')
180+
@pytest.mark.filterwarnings("ignore:listing git files failed")
181181
def test_empty_subdir(inwd: WorkDir) -> None:
182182
subdir = inwd.cwd / "adir" / "emptysubdir" / "subdir"
183183
subdir.mkdir(parents=True)
@@ -188,7 +188,7 @@ def test_empty_subdir(inwd: WorkDir) -> None:
188188
)
189189

190190

191-
@pytest.mark.filterwarnings('ignore:listing git files failed')
191+
@pytest.mark.filterwarnings("ignore:listing git files failed")
192192
@pytest.mark.skipif(sys.platform == "win32", reason="symlinks not supported on windows")
193193
def test_double_include_through_symlink(inwd: WorkDir) -> None:
194194
(inwd.cwd / "data").mkdir()
@@ -208,7 +208,7 @@ def test_double_include_through_symlink(inwd: WorkDir) -> None:
208208
)
209209

210210

211-
@pytest.mark.filterwarnings('ignore:listing git files failed')
211+
@pytest.mark.filterwarnings("ignore:listing git files failed")
212212
@pytest.mark.skipif(sys.platform == "win32", reason="symlinks not supported on windows")
213213
def test_symlink_not_in_scm_while_target_is(inwd: WorkDir) -> None:
214214
(inwd.cwd / "data").mkdir()
@@ -228,14 +228,14 @@ def test_symlink_not_in_scm_while_target_is(inwd: WorkDir) -> None:
228228
)
229229

230230

231-
@pytest.mark.filterwarnings('ignore:listing git files failed')
231+
@pytest.mark.filterwarnings("ignore:listing git files failed")
232232
@pytest.mark.issue(587)
233233
@pytest.mark.skip_commit
234234
def test_not_commited(inwd: WorkDir) -> None:
235235
assert find_files() == []
236236

237237

238-
@pytest.mark.filterwarnings('ignore:listing git files failed')
238+
@pytest.mark.filterwarnings("ignore:listing git files failed")
239239
def test_unexpanded_git_archival(wd: WorkDir, monkeypatch: pytest.MonkeyPatch) -> None:
240240
# When substitutions in `.git_archival.txt` are not expanded, files should
241241
# not be automatically listed.
@@ -245,7 +245,7 @@ def test_unexpanded_git_archival(wd: WorkDir, monkeypatch: pytest.MonkeyPatch) -
245245
assert find_files() == []
246246

247247

248-
@pytest.mark.filterwarnings('ignore:listing git files failed')
248+
@pytest.mark.filterwarnings("ignore:listing git files failed")
249249
@pytest.mark.parametrize("archive_file", [".git_archival.txt", ".hg_archival.txt"])
250250
def test_archive(
251251
wd: WorkDir, monkeypatch: pytest.MonkeyPatch, archive_file: str

testing/test_git.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import os
55
import shutil
66
import subprocess
7-
import textwrap
87
import sys
8+
import textwrap
99

1010
from datetime import date
1111
from datetime import datetime
@@ -161,7 +161,7 @@ def break_folder_permissions(path: Path) -> Generator[None, None, None]:
161161
sudo_devnull(["chgrp", "-R", str(original_stat.st_gid), path], check=True)
162162

163163

164-
@pytest.mark.filterwarnings('ignore::UserWarning')
164+
@pytest.mark.filterwarnings("ignore::UserWarning")
165165
@pytest.mark.issue("https://github.com/pypa/setuptools-scm/issues/784")
166166
def test_not_owner(wd: WorkDir) -> None:
167167
with break_folder_permissions(wd.cwd):
@@ -869,7 +869,7 @@ def test_git_no_commits_uses_fallback_version(wd: WorkDir) -> None:
869869
def test_dubious_dir(
870870
wd: WorkDir, caplog: pytest.LogCaptureFixture, monkeypatch: pytest.MonkeyPatch
871871
) -> None:
872-
'''Test that we exit clearly if we are in a unsafe directory'''
872+
"""Test that we exit clearly if we are in a unsafe directory"""
873873
wd.commit_testfile()
874874
git_wd = git.GitWorkdir(wd.cwd)
875875

@@ -882,15 +882,18 @@ def test_dubious_dir(
882882
git config --global --add safe.directory /this/is/a/fake/path
883883
""")
884884
_orig_run = run
885+
885886
def _run(*args, **kwargs):
886-
if args[0] == ['git', 'rev-parse', 'HEAD']:
887-
return CompletedProcess(args=[],
888-
stdout="%cI",
889-
stderr=stderr, returncode=128)
887+
if args[0] == ["git", "rev-parse", "HEAD"]:
888+
return CompletedProcess(
889+
args=[], stdout="%cI", stderr=stderr, returncode=128
890+
)
890891
return _orig_run(*args, **kwargs)
891892

892893
with pytest.raises(SystemExit):
893-
with patch.object(setuptools_scm._file_finders.git, '_run', _run):
894+
with patch.object(setuptools_scm._file_finders.git, "_run", _run):
894895
file_list = git_find_files(str(wd.cwd))
895896

896-
assert 'fatal: detected dubious ownership in repository' in ' '.join(caplog.messages)
897+
assert "fatal: detected dubious ownership in repository" in " ".join(
898+
caplog.messages
899+
)

testing/test_mercurial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def test_hg_command_from_env_is_invalid(
9797
assert wd.get_version(fallback_version="1.0") == "1.0"
9898

9999

100-
@pytest.mark.filterwarnings('ignore:listing git files failed')
100+
@pytest.mark.filterwarnings("ignore:listing git files failed")
101101
def test_find_files_stop_at_root_hg(
102102
wd: WorkDir, monkeypatch: pytest.MonkeyPatch
103103
) -> None:

0 commit comments

Comments
 (0)