Run pyupgrade to clean up Python 2 syntaxes
Update all .py source files by $ pyupgrade --py3-only $(git ls-files | grep ".py$") to modernize the code according to Python 3 syntaxes. Also add the pyupgrade hook to pre-commit to avoid merging additional Python 2 syntaxes. Change-Id: I920992b0fdd3df6f7276268d57e7345c70272d12
This commit is contained in:
parent
6f912c92d0
commit
116055a912
@ -23,3 +23,8 @@ repos:
|
||||
hooks:
|
||||
- id: hacking
|
||||
additional_dependencies: []
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.18.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: [--py3-only]
|
||||
|
@ -99,7 +99,7 @@ def get_class_name(obj, fully_qualified=True):
|
||||
return obj.__name__
|
||||
|
||||
if fully_qualified and hasattr(obj, '__module__'):
|
||||
return '%s.%s' % (obj.__module__, obj.__name__)
|
||||
return '{}.{}'.format(obj.__module__, obj.__name__)
|
||||
else:
|
||||
return obj.__name__
|
||||
|
||||
|
@ -85,7 +85,7 @@ def moved_function(new_func, old_func_name, old_module_name,
|
||||
return old_new_func
|
||||
|
||||
|
||||
class moved_read_only_property(object):
|
||||
class moved_read_only_property:
|
||||
"""Descriptor for read-only properties moved to another location.
|
||||
|
||||
This works like the ``@property`` descriptor but can be used instead to
|
||||
|
@ -33,7 +33,7 @@ def _fetch_first_result(fget, fset, fdel, apply_func, value_not_found=None):
|
||||
return value_not_found
|
||||
|
||||
|
||||
class removed_property(object):
|
||||
class removed_property:
|
||||
"""Property descriptor that deprecates a property.
|
||||
|
||||
This works like the ``@property`` descriptor but can be used instead to
|
||||
|
@ -52,7 +52,7 @@ def blip_blop_blip_unwrapped(type='cat'):
|
||||
return "The %s meowed quietly" % type
|
||||
|
||||
|
||||
class WoofWoof(object):
|
||||
class WoofWoof:
|
||||
@property
|
||||
def bark(self):
|
||||
return 'woof'
|
||||
@ -73,7 +73,7 @@ class WoofWoof(object):
|
||||
return 'super-duper'
|
||||
|
||||
|
||||
class KittyKat(object):
|
||||
class KittyKat:
|
||||
|
||||
@moves.moved_method('supermeow')
|
||||
def meow(self, volume=11):
|
||||
@ -87,7 +87,7 @@ class KittyKat(object):
|
||||
return 'supermeow'
|
||||
|
||||
|
||||
class Giraffe(object):
|
||||
class Giraffe:
|
||||
color = 'orange'
|
||||
colour = moves.moved_read_only_property('colour', 'color')
|
||||
|
||||
@ -98,7 +98,7 @@ class Giraffe(object):
|
||||
heightt = moves.moved_read_only_property('heightt', 'height')
|
||||
|
||||
|
||||
class NewHotness(object):
|
||||
class NewHotness:
|
||||
def hot(self):
|
||||
return 'cold'
|
||||
|
||||
@ -136,28 +136,28 @@ yellowish_sun = moves.moved_function(yellow_sun, 'yellowish_sun', __name__)
|
||||
|
||||
|
||||
@removals.remove()
|
||||
class EFSF(object):
|
||||
class EFSF:
|
||||
pass
|
||||
|
||||
|
||||
@removals.remove(category=PendingDeprecationWarning)
|
||||
class EFSF_2(object):
|
||||
class EFSF_2:
|
||||
pass
|
||||
|
||||
|
||||
@removals.removed_class("StarLord")
|
||||
class StarLord(object):
|
||||
class StarLord:
|
||||
def __init__(self):
|
||||
self.name = "star"
|
||||
|
||||
|
||||
class StarLordJr(StarLord):
|
||||
def __init__(self, name):
|
||||
super(StarLordJr, self).__init__()
|
||||
super().__init__()
|
||||
self.name = name
|
||||
|
||||
|
||||
class ThingB(object):
|
||||
class ThingB:
|
||||
@removals.remove()
|
||||
def black_tristars(self):
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user