Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commita469af8

Browse files
committed
src: No PyDev warnings
+ Mark all unused vars and other non-pep8 (PyDev) warnings+ test_utils: + enable & fix forgotten IterableList looped path. + unittestize all assertions.+ remote: minor fix progress dispatching unknown err-lines
1 parentbe44602 commita469af8

29 files changed

+172
-157
lines changed

‎git/__init__.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66
# flake8: noqa
7-
7+
#@PydevCodeAnalysisIgnore
88
importos
99
importsys
1010
importinspect
@@ -32,17 +32,17 @@ def _init_externals():
3232

3333
#{ Imports
3434

35-
fromgit.configimportGitConfigParser
36-
fromgit.objectsimport*
37-
fromgit.refsimport*
38-
fromgit.diffimport*
39-
fromgit.excimport*
40-
fromgit.dbimport*
41-
fromgit.cmdimportGit
42-
fromgit.repoimportRepo
43-
fromgit.remoteimport*
44-
fromgit.indeximport*
45-
fromgit.utilimport (
35+
fromgit.configimportGitConfigParser# @NoMove @IgnorePep8
36+
fromgit.objectsimport*# @NoMove @IgnorePep8
37+
fromgit.refsimport*# @NoMove @IgnorePep8
38+
fromgit.diffimport*# @NoMove @IgnorePep8
39+
fromgit.excimport*# @NoMove @IgnorePep8
40+
fromgit.dbimport*# @NoMove @IgnorePep8
41+
fromgit.cmdimportGit# @NoMove @IgnorePep8
42+
fromgit.repoimportRepo# @NoMove @IgnorePep8
43+
fromgit.remoteimport*# @NoMove @IgnorePep8
44+
fromgit.indeximport*# @NoMove @IgnorePep8
45+
fromgit.utilimport (# @NoMove @IgnorePep8
4646
LockFile,
4747
BlockingLockFile,
4848
Stats,

‎git/compat.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
fromgitdb.utils.compatimport (
1515
xrange,
16-
MAXSIZE,
17-
izip,
16+
MAXSIZE,# @UnusedImport
17+
izip,# @UnusedImport
1818
)
1919
fromgitdb.utils.encodingimport (
20-
string_types,
21-
text_type,
22-
force_bytes,
23-
force_text
20+
string_types,# @UnusedImport
21+
text_type,# @UnusedImport
22+
force_bytes,# @UnusedImport
23+
force_text# @UnusedImport
2424
)
2525

2626

@@ -33,17 +33,21 @@
3333
ifPY3:
3434
importio
3535
FileType=io.IOBase
36+
3637
defbyte_ord(b):
3738
returnb
39+
3840
defbchr(n):
3941
returnbytes([n])
42+
4043
defmviter(d):
4144
returnd.values()
42-
range=xrange
45+
46+
range=xrange# @ReservedAssignment
4347
unicode=str
4448
binary_type=bytes
4549
else:
46-
FileType=file
50+
FileType=file# @UndefinedVariable on PY3
4751
# usually, this is just ascii, which might not enough for our encoding needs
4852
# Unless it's set specifically, we override it to be utf-8
4953
ifdefenc=='ascii':
@@ -52,7 +56,8 @@ def mviter(d):
5256
bchr=chr
5357
unicode=unicode
5458
binary_type=str
55-
range=xrange
59+
range=xrange# @ReservedAssignment
60+
5661
defmviter(d):
5762
returnd.itervalues()
5863

‎git/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
classMetaParserBuilder(abc.ABCMeta):
4141

4242
"""Utlity class wrapping base-class methods into decorators that assure read-only properties"""
43-
def__new__(metacls,name,bases,clsdict):
43+
def__new__(cls,name,bases,clsdict):
4444
"""
4545
Equip all base-class methods with a needs_values decorator, and all non-const methods
4646
with a set_dirty_and_flush_changes decorator in addition to that."""
@@ -62,7 +62,7 @@ def __new__(metacls, name, bases, clsdict):
6262
# END for each base
6363
# END if mutating methods configuration is set
6464

65-
new_type=super(MetaParserBuilder,metacls).__new__(metacls,name,bases,clsdict)
65+
new_type=super(MetaParserBuilder,cls).__new__(cls,name,bases,clsdict)
6666
returnnew_type
6767

6868

‎git/db.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
bin_to_hex,
88
hex_to_bin
99
)
10-
fromgitdb.dbimportGitDB
10+
fromgitdb.dbimportGitDB# @UnusedImport
1111
fromgitdb.dbimportLooseObjectDB
1212

1313
from .excimport (
@@ -54,7 +54,7 @@ def partial_to_complete_sha_hex(self, partial_hexsha):
5454
:note: currently we only raise BadObject as git does not communicate
5555
AmbiguousObjects separately"""
5656
try:
57-
hexsha,typename,size=self._git.get_object_header(partial_hexsha)
57+
hexsha,typename,size=self._git.get_object_header(partial_hexsha)# @UnusedVariable
5858
returnhex_to_bin(hexsha)
5959
except (GitCommandError,ValueError):
6060
raiseBadObject(partial_hexsha)

‎git/exc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66
""" Module containing all exceptions thrown througout the git package, """
77

8-
fromgitdb.excimport*# NOQA
8+
fromgitdb.excimport*# NOQA @UnusedWildImport
99
fromgit.compatimportUnicodeMixin,safe_decode,string_types
1010

1111

‎git/index/base.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def _delete_entries_cache(self):
170170

171171
def_deserialize(self,stream):
172172
"""Initialize this instance with index values read from the given stream"""
173-
self.version,self.entries,self._extension_data,conten_sha=read_cache(stream)
173+
self.version,self.entries,self._extension_data,conten_sha=read_cache(stream)# @UnusedVariable
174174
returnself
175175

176176
def_entries_sorted(self):
@@ -404,7 +404,7 @@ def raise_exc(e):
404404
continue
405405
# END glob handling
406406
try:
407-
forroot,dirs,filesinos.walk(abs_path,onerror=raise_exc):
407+
forroot,dirs,filesinos.walk(abs_path,onerror=raise_exc):# @UnusedVariable
408408
forrela_fileinfiles:
409409
# add relative paths only
410410
yieldos.path.join(root.replace(rs,''),rela_file)
@@ -599,7 +599,6 @@ def _store_path(self, filepath, fprogress):
599599
"""Store file at filepath in the database and return the base index entry
600600
Needs the git_working_dir decorator active ! This must be assured in the calling code"""
601601
st=os.lstat(filepath)# handles non-symlinks as well
602-
stream=None
603602
ifS_ISLNK(st.st_mode):
604603
# in PY3, readlink is string, but we need bytes. In PY2, it's just OS encoded bytes, we assume UTF-8
605604
open_stream=lambda:BytesIO(force_bytes(os.readlink(filepath),encoding=defenc))
@@ -1102,11 +1101,11 @@ def handle_stderr(proc, iter_checked_out_files):
11021101
try:
11031102
self.entries[(co_path,0)]
11041103
exceptKeyError:
1105-
dir=co_path
1106-
ifnotdir.endswith('/'):
1107-
dir+='/'
1104+
folder=co_path
1105+
ifnotfolder.endswith('/'):
1106+
folder+='/'
11081107
forentryinmviter(self.entries):
1109-
ifentry.path.startswith(dir):
1108+
ifentry.path.startswith(folder):
11101109
p=entry.path
11111110
self._write_path_to_stdin(proc,p,p,make_exc,
11121111
fprogress,read_from_stdout=False)

‎git/index/fun.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def write_tree_from_cache(entries, odb, sl, si=0):
264264

265265
# enter recursion
266266
# ci - 1 as we want to count our current item as well
267-
sha,tree_entry_list=write_tree_from_cache(entries,odb,slice(ci-1,xi),rbound+1)
267+
sha,tree_entry_list=write_tree_from_cache(entries,odb,slice(ci-1,xi),rbound+1)# @UnusedVariable
268268
tree_items_append((sha,S_IFDIR,base))
269269

270270
# skip ahead

‎git/objects/__init__.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@
33
"""
44
# flake8: noqa
55
from __future__importabsolute_import
6+
67
importinspect
8+
79
from .baseimport*
10+
from .blobimport*
11+
from .commitimport*
12+
from .submoduleimportutilassmutil
13+
from .submodule.baseimport*
14+
from .submodule.rootimport*
15+
from .tagimport*
16+
from .treeimport*
817
# Fix import dependency - add IndexObject to the util module, so that it can be
918
# imported by the submodule.base
10-
from .submoduleimportutilassmutil
1119
smutil.IndexObject=IndexObject
1220
smutil.Object=Object
1321
del(smutil)
14-
from .submodule.baseimport*
15-
from .submodule.rootimport*
1622

1723
# must come after submodule was made available
18-
from .tagimport*
19-
from .blobimport*
20-
from .commitimport*
21-
from .treeimport*
2224

2325
__all__= [nameforname,objinlocals().items()
2426
ifnot (name.startswith('_')orinspect.ismodule(obj))]

‎git/objects/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __init__(self, repo, binsha):
4040
assertlen(binsha)==20,"Require 20 byte binary sha, got %r, len = %i"% (binsha,len(binsha))
4141

4242
@classmethod
43-
defnew(cls,repo,id):
43+
defnew(cls,repo,id):# @ReservedAssignment
4444
"""
4545
:return: New Object instance of a type appropriate to the object type behind
4646
id. The id of the newly created object will be a binsha even though

‎git/objects/commit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def _get_intermediate_items(cls, commit):
140140
def_set_cache_(self,attr):
141141
ifattrinCommit.__slots__:
142142
# read the data in a chunk, its faster - then provide a file wrapper
143-
binsha,typename,self.size,stream=self.repo.odb.stream(self.binsha)
143+
binsha,typename,self.size,stream=self.repo.odb.stream(self.binsha)# @UnusedVariable
144144
self._deserialize(BytesIO(stream.read()))
145145
else:
146146
super(Commit,self)._set_cache_(attr)
@@ -267,7 +267,7 @@ def _iter_from_process_or_stream(cls, repo, proc_or_stream):
267267
hexsha=line.strip()
268268
iflen(hexsha)>40:
269269
# split additional information, as returned by bisect for instance
270-
hexsha,rest=line.split(None,1)
270+
hexsha,_=line.split(None,1)
271271
# END handle extra info
272272

273273
assertlen(hexsha)==40,"Invalid line: %s"%hexsha

‎git/objects/fun.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ def traverse_trees_recursive(odb, tree_shas, path_prefix):
157157
ifnotitem:
158158
continue
159159
# END skip already done items
160-
entries= [Noneforninrange(nt)]
160+
entries= [Nonefor_inrange(nt)]
161161
entries[ti]=item
162-
sha,mode,name=item# its faster to unpack
162+
sha,mode,name=item# its faster to unpack @UnusedVariable
163163
is_dir=S_ISDIR(mode)# type mode bits
164164

165165
# find this item in all other tree data items

‎git/objects/tag.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class TagObject(base.Object):
2121
type="tag"
2222
__slots__= ("object","tag","tagger","tagged_date","tagger_tz_offset","message")
2323

24-
def__init__(self,repo,binsha,object=None,tag=None,
24+
def__init__(self,repo,binsha,object=None,tag=None,# @ReservedAssignment
2525
tagger=None,tagged_date=None,tagger_tz_offset=None,message=None):
2626
"""Initialize a tag object with additional data
2727
@@ -55,8 +55,8 @@ def _set_cache_(self, attr):
5555
ostream=self.repo.odb.stream(self.binsha)
5656
lines=ostream.read().decode(defenc).splitlines()
5757

58-
obj,hexsha=lines[0].split(" ")# object <hexsha>
59-
type_token,type_name=lines[1].split(" ")# type <type_name>
58+
obj,hexsha=lines[0].split(" ")# object <hexsha> @UnusedVariable
59+
type_token,type_name=lines[1].split(" ")# type <type_name> @UnusedVariable
6060
self.object= \
6161
get_object_type_by_name(type_name.encode('ascii'))(self.repo,hex_to_bin(hexsha))
6262

‎git/refs/reference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __str__(self):
5050

5151
#{ Interface
5252

53-
defset_object(self,object,logmsg=None):
53+
defset_object(self,object,logmsg=None):# @ReservedAssignment
5454
"""Special version which checks if the head-log needs an update as well
5555
:return: self"""
5656
oldbinsha=None

‎git/refs/symbolic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def set_commit(self, commit, logmsg=None):
218218

219219
returnself
220220

221-
defset_object(self,object,logmsg=None):
221+
defset_object(self,object,logmsg=None):# @ReservedAssignment
222222
"""Set the object we point to, possibly dereference our symbolic reference first.
223223
If the reference does not exist, it will be created
224224
@@ -229,7 +229,7 @@ def set_object(self, object, logmsg=None):
229229
:note: plain SymbolicReferences may not actually point to objects by convention
230230
:return: self"""
231231
ifisinstance(object,SymbolicReference):
232-
object=object.object
232+
object=object.object# @ReservedAssignment
233233
# END resolve references
234234

235235
is_detached=True
@@ -595,7 +595,7 @@ def _iter_items(cls, repo, common_path=None):
595595
# END for each directory to walk
596596

597597
# read packed refs
598-
forsha,rela_pathincls._iter_packed_refs(repo):
598+
forsha,rela_pathincls._iter_packed_refs(repo):# @UnusedVariable
599599
ifrela_path.startswith(common_path):
600600
rela_paths.add(rela_path)
601601
# END relative path matches common path

‎git/remote.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def _from_line(cls, remote, line):
176176
split_token="..."
177177
ifcontrol_character==" ":
178178
split_token=".."
179-
old_sha,new_sha=summary.split(' ')[0].split(split_token)
179+
old_sha,new_sha=summary.split(' ')[0].split(split_token)# @UnusedVariable
180180
# have to use constructor here as the sha usually is abbreviated
181181
old_commit=old_sha
182182
# END message handling
@@ -262,7 +262,7 @@ def _from_line(cls, repo, line, fetch_line):
262262
# parse lines
263263
control_character,operation,local_remote_ref,remote_local_ref,note=match.groups()
264264
try:
265-
new_hex_sha,fetch_operation,fetch_note=fetch_line.split("\t")
265+
new_hex_sha,fetch_operation,fetch_note=fetch_line.split("\t")# @UnusedVariable
266266
ref_type_name,fetch_note=fetch_note.split(' ',1)
267267
exceptValueError:# unpack error
268268
raiseValueError("Failed to parse FETCH_HEAD line: %r"%fetch_line)
@@ -625,8 +625,8 @@ def _get_fetch_info_from_stderr(self, proc, progress):
625625
forplineinprogress_handler(line):
626626
# END handle special messages
627627
forcmdincmds:
628-
iflen(line)>1andline[0]==' 'andline[1]==cmd:
629-
fetch_info_lines.append(line)
628+
iflen(pline)>1andpline[0]==' 'andpline[1]==cmd:
629+
fetch_info_lines.append(pline)
630630
continue
631631
# end find command code
632632
# end for each comand code we know

‎git/repo/fun.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def rev_parse(repo, rev):
284284
try:
285285
iftoken=="~":
286286
obj=to_commit(obj)
287-
foriteminxrange(num):
287+
for_inxrange(num):
288288
obj=obj.parents[0]
289289
# END for each history item to walk
290290
eliftoken=="^":

‎git/test/lib/asserts.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
importstat
99

1010
fromnose.toolsimport (
11-
assert_equal,
12-
assert_not_equal,
13-
assert_raises,
14-
raises,
15-
assert_true,
16-
assert_false
11+
assert_equal,# @UnusedImport
12+
assert_not_equal,# @UnusedImport
13+
assert_raises,# @UnusedImport
14+
raises,# @UnusedImport
15+
assert_true,# @UnusedImport
16+
assert_false# @UnusedImport
1717
)
1818

1919
try:
2020
fromunittest.mockimportpatch
2121
exceptImportError:
22-
frommockimportpatch
22+
frommockimportpatch# @NoMove @UnusedImport
2323

2424
__all__= ['assert_instance_of','assert_not_instance_of',
2525
'assert_none','assert_not_none',

‎git/test/performance/test_streams.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def test_large_data_streaming(self, rwrepo):
120120

121121
# read all
122122
st=time()
123-
s,t,size,data=rwrepo.git.get_object_data(gitsha)
123+
hexsha,typename,size,data=rwrepo.git.get_object_data(gitsha)# @UnusedVariable
124124
gelapsed_readall=time()-st
125125
print("Read %i KiB of %s data at once using git-cat-file in %f s ( %f Read KiB / s)"
126126
% (size_kib,desc,gelapsed_readall,size_kib/gelapsed_readall),file=sys.stderr)
@@ -131,7 +131,7 @@ def test_large_data_streaming(self, rwrepo):
131131

132132
# read chunks
133133
st=time()
134-
s,t,size,stream=rwrepo.git.stream_object_data(gitsha)
134+
hexsha,typename,size,stream=rwrepo.git.stream_object_data(gitsha)# @UnusedVariable
135135
whileTrue:
136136
data=stream.read(cs)
137137
iflen(data)<cs:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp