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

Commit82dd956

Browse files
committed
Use type.__fullyqualname__ attribute
1 parentd5e8a37 commit82dd956

21 files changed

+35
-46
lines changed

‎Lib/_collections_abc.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,9 +528,7 @@ def _type_repr(obj):
528528
(Keep this roughly in sync with the typing version.)
529529
"""
530530
ifisinstance(obj,type):
531-
ifobj.__module__=='builtins':
532-
returnobj.__qualname__
533-
returnf'{obj.__module__}.{obj.__qualname__}'
531+
returnobj.__fullyqualname__
534532
ifobjisEllipsis:
535533
return'...'
536534
ifisinstance(obj,FunctionType):

‎Lib/_py_abc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def register(cls, subclass):
7171

7272
def_dump_registry(cls,file=None):
7373
"""Debug helper to print the ABC registry."""
74-
print(f"Class:{cls.__module__}.{cls.__qualname__}",file=file)
74+
print(f"Class:{cls.__fullyqualname__}",file=file)
7575
print(f"Inv. counter:{get_cache_token()}",file=file)
7676
fornameincls.__dict__:
7777
ifname.startswith("_abc_"):

‎Lib/abc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def __subclasscheck__(cls, subclass):
124124

125125
def_dump_registry(cls,file=None):
126126
"""Debug helper to print the ABC registry."""
127-
print(f"Class:{cls.__module__}.{cls.__qualname__}",file=file)
127+
print(f"Class:{cls.__fullyqualname__}",file=file)
128128
print(f"Inv. counter:{get_cache_token()}",file=file)
129129
(_abc_registry,_abc_cache,_abc_negative_cache,
130130
_abc_negative_cache_version)=_get_dump(cls)

‎Lib/codecs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ def __new__(cls, encode, decode, streamreader=None, streamwriter=None,
107107
returnself
108108

109109
def__repr__(self):
110-
return"<%s.%s object for encoding %s at %#x>"% \
111-
(self.__class__.__module__,self.__class__.__qualname__,
110+
return"<%s object for encoding %s at %#x>"% \
111+
(self.__class__.__fullyqualname__,
112112
self.name,id(self))
113113

114114
def__getnewargs__(self):

‎Lib/contextlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ def enter_context(self, cm):
525525
_enter=cls.__enter__
526526
_exit=cls.__exit__
527527
exceptAttributeError:
528-
raiseTypeError(f"'{cls.__module__}.{cls.__qualname__}' object does "
528+
raiseTypeError(f"'{cls.__fullyqualname__}' object does "
529529
f"not support the context manager protocol")fromNone
530530
result=_enter(cm)
531531
self._push_cm_exit(cm,_exit)
@@ -662,7 +662,7 @@ async def enter_async_context(self, cm):
662662
_enter=cls.__aenter__
663663
_exit=cls.__aexit__
664664
exceptAttributeError:
665-
raiseTypeError(f"'{cls.__module__}.{cls.__qualname__}' object does "
665+
raiseTypeError(f"'{cls.__fullyqualname__}' object does "
666666
f"not support the asynchronous context manager protocol"
667667
)fromNone
668668
result=await_enter(cm)

‎Lib/doctest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ def __run(self, test, compileflags, out):
14011401
# They start with `SyntaxError:` (or any other class name)
14021402
exception_line_prefixes= (
14031403
f"{exception[0].__qualname__}:",
1404-
f"{exception[0].__module__}.{exception[0].__qualname__}:",
1404+
f"{exception[0].__fullyqualname__}:",
14051405
)
14061406
exc_msg_index=next(
14071407
index

‎Lib/inspect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,9 +1501,9 @@ def repl(match):
15011501
ifisinstance(annotation,types.GenericAlias):
15021502
returnstr(annotation)
15031503
ifisinstance(annotation,type):
1504-
ifannotation.__module__in ('builtins',base_module):
1504+
ifannotation.__module__==base_module:
15051505
returnannotation.__qualname__
1506-
returnannotation.__module__+'.'+annotation.__qualname__
1506+
returnannotation.__fullyqualname__
15071507
returnrepr(annotation)
15081508

15091509
defformatannotationrelativeto(object):

‎Lib/multiprocessing/pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def __del__(self, _warn=warnings.warn, RUN=RUN):
272272

273273
def__repr__(self):
274274
cls=self.__class__
275-
return (f'<{cls.__module__}.{cls.__qualname__} '
275+
return (f'<{cls.__fullyqualname__} '
276276
f'state={self._state} '
277277
f'pool_size={len(self._pool)}>')
278278

‎Lib/pdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,7 @@ def do_whatis(self, arg):
17261726
return
17271727
# Is it a class?
17281728
ifvalue.__class__istype:
1729-
self.message('Class%s.%s'% (value.__module__,value.__qualname__))
1729+
self.message(f'Class{value.__fullyqualname__}')
17301730
return
17311731
# None of the above...
17321732
self.message(type(value))

‎Lib/test/support/asyncore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def __init__(self, sock=None, map=None):
256256
self.socket=None
257257

258258
def__repr__(self):
259-
status= [self.__class__.__module__+"."+self.__class__.__qualname__]
259+
status= [self.__class__.__fullyqualname__]
260260
ifself.acceptingandself.addr:
261261
status.append('listening')
262262
elifself.connected:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp