Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0fa0047

Browse filesBrowse files
authored
Merge pull request #1765 from EliahKagan/gc-imports
Extract all "import gc" to module level
2 parents 6c40024 + d70ba69 commit 0fa0047
Copy full SHA for 0fa0047

File tree

10 files changed

+11
-20
lines changed
Filter options

10 files changed

+11
-20
lines changed

‎git/objects/submodule/base.py

Copy file name to clipboardExpand all lines: git/objects/submodule/base.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This module is part of GitPython and is released under the
22
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
33

4+
import gc
45
from io import BytesIO
56
import logging
67
import os
@@ -1079,8 +1080,6 @@ def remove(
10791080
self._clear_cache()
10801081
wtd = mod.working_tree_dir
10811082
del mod # Release file-handles (Windows).
1082-
import gc
1083-
10841083
gc.collect()
10851084
rmtree(str(wtd))
10861085
# END delete tree if possible

‎test/performance/test_commit.py

Copy file name to clipboardExpand all lines: test/performance/test_commit.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
"""Performance tests for commits (iteration, traversal, and serialization)."""
77

8+
import gc
89
from io import BytesIO
910
from time import time
1011
import sys
@@ -17,8 +18,6 @@
1718

1819
class TestPerformance(TestBigRepoRW, TestCommitSerialization):
1920
def tearDown(self):
20-
import gc
21-
2221
gc.collect()
2322

2423
# ref with about 100 commits in its history.

‎test/performance/test_streams.py

Copy file name to clipboardExpand all lines: test/performance/test_streams.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
"""Performance tests for data streaming."""
55

6+
import gc
67
import os
78
import subprocess
89
import sys
@@ -92,8 +93,6 @@ def test_large_data_streaming(self, rwrepo):
9293

9394
# del db file so git has something to do.
9495
ostream = None
95-
import gc
96-
9796
gc.collect()
9897
os.remove(db_file)
9998

‎test/test_base.py

Copy file name to clipboardExpand all lines: test/test_base.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# This module is part of GitPython and is released under the
44
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
55

6+
import gc
67
import os
78
import sys
89
import tempfile
@@ -20,8 +21,6 @@
2021

2122
class TestBase(_TestBase):
2223
def tearDown(self):
23-
import gc
24-
2524
gc.collect()
2625

2726
type_tuples = (

‎test/test_docs.py

Copy file name to clipboardExpand all lines: test/test_docs.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# This module is part of GitPython and is released under the
44
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
55

6+
import gc
67
import os
78
import sys
89

@@ -16,8 +17,6 @@
1617

1718
class Tutorials(TestBase):
1819
def tearDown(self):
19-
import gc
20-
2120
gc.collect()
2221

2322
# ACTUALLY skipped by git.util.rmtree (in local onerror function), from the last call to it via

‎test/test_git.py

Copy file name to clipboardExpand all lines: test/test_git.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# This module is part of GitPython and is released under the
44
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
55

6+
import gc
67
import inspect
78
import logging
89
import os
@@ -34,8 +35,6 @@ def setUpClass(cls):
3435
cls.git = Git(cls.rorepo.working_dir)
3536

3637
def tearDown(self):
37-
import gc
38-
3938
gc.collect()
4039

4140
def _assert_logged_for_popen(self, log_watcher, name, value):

‎test/test_quick_doc.py

Copy file name to clipboardExpand all lines: test/test_quick_doc.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# This module is part of GitPython and is released under the
22
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
33

4+
import gc
5+
46
from test.lib import TestBase
57
from test.lib.helper import with_rw_directory
68

79

810
class QuickDoc(TestBase):
911
def tearDown(self):
10-
import gc
11-
1212
gc.collect()
1313

1414
@with_rw_directory

‎test/test_remote.py

Copy file name to clipboardExpand all lines: test/test_remote.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# This module is part of GitPython and is released under the
44
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
55

6+
import gc
67
import os
78
import os.path as osp
89
from pathlib import Path
@@ -105,8 +106,6 @@ def assert_received_message(self):
105106

106107
class TestRemote(TestBase):
107108
def tearDown(self):
108-
import gc
109-
110109
gc.collect()
111110

112111
def _print_fetchhead(self, repo):

‎test/test_repo.py

Copy file name to clipboardExpand all lines: test/test_repo.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# This module is part of GitPython and is released under the
44
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
55

6+
import gc
67
import glob
78
import io
89
from io import BytesIO
@@ -72,8 +73,6 @@ def tearDown(self):
7273
if osp.isfile(lfp):
7374
raise AssertionError("Previous TC left hanging git-lock file: {}".format(lfp))
7475

75-
import gc
76-
7776
gc.collect()
7877

7978
def test_new_should_raise_on_invalid_repo_location(self):

‎test/test_submodule.py

Copy file name to clipboardExpand all lines: test/test_submodule.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
33

44
import contextlib
5+
import gc
56
import os
67
import os.path as osp
78
from pathlib import Path
@@ -61,8 +62,6 @@ def update(self, op, cur_count, max_count, message=""):
6162

6263
class TestSubmodule(TestBase):
6364
def tearDown(self):
64-
import gc
65-
6665
gc.collect()
6766

6867
k_subm_current = "c15a6e1923a14bc760851913858a3942a4193cdb"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.