Skip to content

Commit

Permalink
- run pyupgrade and fix pypy3 doctests (from 2bb0ee6)
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed May 28, 2024
1 parent 1b191c2 commit 12da5fd
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/zope/interface/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def __optional_methods_to_docs(attrs):
return ''

docs = "\n\nThe following methods are optional:\n - " + "\n-".join(
"{}\n{}".format(k, v.__doc__) for k, v in optionals.items()
f"{k}\n{v.__doc__}" for k, v in optionals.items()
)
return docs

Expand All @@ -181,7 +181,7 @@ def ref(c):
return "`%s`" % name
if mod == '_io':
mod = 'io'
return "`{}.{}`".format(mod, name)
return f"`{mod}.{name}`"

implementations_doc = "\n - ".join(
ref(c)
Expand Down
6 changes: 3 additions & 3 deletions src/zope/interface/declarations.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def __repr__(self):
declared_names = self._argument_names_for_repr(self.declared)
if declared_names:
declared_names = ', ' + declared_names
return 'classImplements({}{})'.format(name, declared_names)
return f'classImplements({name}{declared_names})'

def __reduce__(self):
return implementedBy, (self.inherit, )
Expand Down Expand Up @@ -772,7 +772,7 @@ def __repr__(self):
if len(mod_names) == 1:
mod_names = "sys.modules[%r]" % mod_names[0]
ordered_names = (
'{}, '.format(mod_names)
f'{mod_names}, '
) + ordered_names
return "{}({})".format(
function_name,
Expand Down Expand Up @@ -937,7 +937,7 @@ def __repr__(self):
# Thus, as our repr, we go with the ``directlyProvides()`` syntax.
interfaces = (self._cls, ) + self.__args[2:]
ordered_names = self._argument_names_for_repr(interfaces)
return "directlyProvides({})".format(ordered_names)
return f"directlyProvides({ordered_names})"

def __reduce__(self):
return self.__class__, self.__args
Expand Down
4 changes: 2 additions & 2 deletions src/zope/interface/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def asStructuredText(iface, munge=0, rst=False):

if rst:
def inline_literal(s):
return "``{}``".format(s)
return f"``{s}``"
else:
def inline_literal(s):
return s
Expand Down Expand Up @@ -76,7 +76,7 @@ def inline_literal(s):
level += 1
for name, desc in namesAndDescriptions:
if hasattr(desc, 'getSignatureString'): # ugh...
_call = "{}{}".format(desc.getName(), desc.getSignatureString())
_call = f"{desc.getName()}{desc.getSignatureString()}"
item = "{} -- {}".format(
inline_literal(_call),
desc.getDoc() or 'no documentation'
Expand Down
2 changes: 1 addition & 1 deletion src/zope/interface/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def _str_subject(self):
target = self.target
if target is self._NOT_GIVEN:
return "An object"
return "The object {!r}".format(target)
return f"The object {target!r}"

@property
def _str_description(self):
Expand Down
6 changes: 3 additions & 3 deletions src/zope/interface/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ def __init__(
Specification.__init__(self, bases)
self.__attrs = self.__compute_attrs(attrs)

self.__identifier__ = "{}.{}".format(__module__, name)
self.__identifier__ = f"{__module__}.{name}"

def __compute_attrs(self, attrs):
# Make sure that all recorded attributes (and methods) are of type
Expand Down Expand Up @@ -938,15 +938,15 @@ def __repr__(self):
return self._v_repr
except AttributeError:
name = str(self)
r = "<{} {}>".format(self.__class__.__name__, name)
r = f"<{self.__class__.__name__} {name}>"
self._v_repr = r # pylint:disable=attribute-defined-outside-init
return r

def __str__(self):
name = self.__name__
m = self.__ibmodule__
if m:
name = '{}.{}'.format(m, name)
name = f'{m}.{name}'
return name

def _call_conform(self, conform):
Expand Down
2 changes: 1 addition & 1 deletion src/zope/interface/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ class RegistrationEvent(ObjectEvent):
"""There has been a change in a registration
"""
def __repr__(self):
return "{} event:\n{!r}".format(self.__class__.__name__, self.object)
return f"{self.__class__.__name__} event:\n{self.object!r}"


class IRegistered(IRegistrationEvent):
Expand Down
2 changes: 1 addition & 1 deletion src/zope/interface/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def __init__(self, name='', bases=()):
self._v_utility_registrations_cache = None

def __repr__(self):
return "<{} {}>".format(self.__class__.__name__, self.__name__)
return f"<{self.__class__.__name__} {self.__name__}>"

def __reduce__(self):
# Mimic what a persistent.Persistent object does and elide
Expand Down
2 changes: 1 addition & 1 deletion src/zope/interface/ro.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ def __str__(self):
max_left = max(len(x) for x in left_lines)
max_right = max(len(x) for x in right_lines)

left_title = 'Legacy RO (len={})'.format(len(self.legacy_ro))
left_title = f'Legacy RO (len={len(self.legacy_ro)})'

right_title = 'C3 RO (len={}; inconsistent={})'.format(
len(self.c3_ro),
Expand Down
2 changes: 1 addition & 1 deletion src/zope/interface/tests/odd.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __getattr__(self, name):
raise AttributeError(name)

def __repr__(self): # pragma: no cover
return "<odd class {} at {}>".format(self.__name__, hex(id(self)))
return f"<odd class {self.__name__} at {hex(id(self))}>"


MetaClass = MetaMetaClass(
Expand Down
4 changes: 2 additions & 2 deletions src/zope/interface/tests/test_declarations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ def test__repr__(self):
IFoo = InterfaceClass("IFoo")
assert IFoo.__name__ == 'IFoo'
assert IFoo.__module__ == __name__
assert repr(IFoo) == '<InterfaceClass {}.IFoo>'.format(__name__)
assert repr(IFoo) == f'<InterfaceClass {__name__}.IFoo>'

IBar = InterfaceClass("IBar")

Expand Down Expand Up @@ -1968,7 +1968,7 @@ def __call__(self):
inst = implementedBy(Callable())
self.assertEqual(
repr(inst),
'classImplements({}.?)'.format(__name__)
f'classImplements({__name__}.?)'
)

c = Callable()
Expand Down
2 changes: 1 addition & 1 deletion src/zope/interface/tests/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2610,7 +2610,7 @@ class UtilityImplementingFoo:

for i in range(30):
comps.registerUtility(
UtilityImplementingFoo(), IFoo, name='{}'.format(i)
UtilityImplementingFoo(), IFoo, name=f'{i}'
)

orig_generation = comps.utilities._generation
Expand Down

0 comments on commit 12da5fd

Please sign in to comment.