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

Commit3cef949

Browse files
committed
Rename Iterable due to typing.Iterable. Add deprecation warning
1 parentc3903d8 commit3cef949

File tree

2 files changed

+58
-5
lines changed

2 files changed

+58
-5
lines changed

‎git/util.py‎

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
importtime
1919
fromunittestimportSkipTest
2020
fromurllib.parseimporturlsplit,urlunsplit
21+
importwarnings
2122

2223
# typing ---------------------------------------------------------
2324

@@ -1013,15 +1014,52 @@ def __delitem__(self, index: Union[SupportsIndex, int, slice, str]) -> Any:
10131014
list.__delitem__(self,delindex)
10141015

10151016

1017+
classIterableClassWatcher(type):
1018+
def__init__(cls,name,bases,clsdict):
1019+
forbaseinbases:
1020+
iftype(base)==cls:
1021+
warnings.warn("GitPython Iterable is deprecated due to naming clash. Use IterableObj instead",
1022+
DeprecationWarning)
1023+
super(IterableClassWatcher,cls).__init__(name,bases,clsdict)
1024+
1025+
10161026
classIterable(object):
10171027

10181028
"""Defines an interface for iterable items which is to assure a uniform
10191029
way to retrieve and iterate items within the git repository"""
10201030
__slots__= ()
10211031
_id_attribute_="attribute that most suitably identifies your instance"
1032+
__metaclass__=IterableClassWatcher
10221033

10231034
@classmethod
1024-
deflist_items(cls,repo:'Repo',*args:Any,**kwargs:Any)->IterableList['IterableObj']:
1035+
deflist_items(cls,repo,*args,**kwargs):
1036+
"""
1037+
Find all items of this type - subclasses can specify args and kwargs differently.
1038+
If no args are given, subclasses are obliged to return all items if no additional
1039+
arguments arg given.
1040+
1041+
:note: Favor the iter_items method as it will
1042+
:return:list(Item,...) list of item instances"""
1043+
out_list=IterableList(cls._id_attribute_)
1044+
out_list.extend(cls.iter_items(repo,*args,**kwargs))
1045+
returnout_list
1046+
1047+
@classmethod
1048+
defiter_items(cls,repo:'Repo',*args:Any,**kwargs:Any):
1049+
# return typed to be compatible with subtypes e.g. Remote
1050+
"""For more information about the arguments, see list_items
1051+
:return: iterator yielding Items"""
1052+
raiseNotImplementedError("To be implemented by Subclass")
1053+
1054+
1055+
classIterableObj():
1056+
"""Defines an interface for iterable items which is to assure a uniform
1057+
way to retrieve and iterate items within the git repository"""
1058+
__slots__= ()
1059+
_id_attribute_="attribute that most suitably identifies your instance"
1060+
1061+
@classmethod
1062+
deflist_items(cls,repo:'Repo',*args:Any,**kwargs:Any)->IterableList[T]:
10251063
"""
10261064
Find all items of this type - subclasses can specify args and kwargs differently.
10271065
If no args are given, subclasses are obliged to return all items if no additional
@@ -1044,10 +1082,6 @@ def iter_items(cls, repo: 'Repo', *args: Any, **kwargs: Any) -> Iterator:
10441082
#} END classes
10451083

10461084

1047-
classIterableObj(Iterable):
1048-
pass
1049-
1050-
10511085
classNullHandler(logging.Handler):
10521086
defemit(self,record:object)->None:
10531087
pass

‎t.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
classWatcher(type):
2+
def__init__(cls,name,bases,clsdict):
3+
[print("ooooo")forbaseinbasesifissubclass(base,name)]
4+
super(Watcher,cls).__init__(name,bases,clsdict)
5+
6+
7+
classSuperClass(metaclass=Watcher):
8+
pass
9+
10+
11+
classSubClass0(SuperClass):
12+
pass
13+
14+
15+
classSubClass1(SuperClass):
16+
print("test")
17+
18+
classnormo():
19+
print("wooo")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp