Modernize code to use f-strings

This also removes the encoding on the top, since Python 3 does it by
default. It also changes some methods to use `yield from`.
This commit is contained in:
Rapptz
2021-04-04 04:40:19 -04:00
parent 9fc2ab9c99
commit 9d39b135f4
67 changed files with 262 additions and 378 deletions

View File

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
"""
The MIT License (MIT)
@ -61,7 +59,7 @@ class Colour:
def __init__(self, value):
if not isinstance(value, int):
raise TypeError('Expected int parameter, received %s instead.' % value.__class__.__name__)
raise TypeError(f'Expected int parameter, received {value.__class__.__name__} instead.')
self.value = value
@ -75,10 +73,10 @@ class Colour:
return not self.__eq__(other)
def __str__(self):
return '#{:0>6x}'.format(self.value)
return f'#{self.value:0>6x}'
def __repr__(self):
return '<Colour value=%s>' % self.value
return f'<Colour value={self.value}>'
def __hash__(self):
return hash(self.value)
@ -132,7 +130,7 @@ class Colour:
Parameters
------------
seed: Optional[Union[:class:`int`, :class:`str`, :class:`float`, :class:`bytes`, :class:`bytearray`]]
The seed to initialize the RNG with. If ``None`` is passed the default RNG is used.
The seed to initialize the RNG with. If ``None`` is passed the default RNG is used.
.. versionadded:: 1.7
"""