pyupgrade --py37-plus **/*.py (#1654)

* pyupgrade --py37-plus **/*.py

* fixup! Format Python code with psf/black push
This commit is contained in:
Christian Clauss
2020-01-03 15:25:36 +01:00
committed by John Law
parent 34c808b375
commit 28419cf839
77 changed files with 71 additions and 128 deletions

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
An auto-balanced binary tree!
"""

View File

@ -467,7 +467,7 @@ class RedBlackTree:
from pprint import pformat
if self.left is None and self.right is None:
return "'%s %s'" % (self.label, (self.color and "red") or "blk")
return "'{} {}'".format(self.label, (self.color and "red") or "blk")
return pformat(
{
"%s %s"

View File

@ -2,7 +2,7 @@ from random import random
from typing import Tuple
class Node(object):
class Node:
"""
Treap's node
Treap is a binary tree by value and heap by priority
@ -18,11 +18,10 @@ class Node(object):
from pprint import pformat
if self.left is None and self.right is None:
return "'%s: %.5s'" % (self.value, self.prior)
return f"'{self.value}: {self.prior:.5}'"
else:
return pformat(
{"%s: %.5s" % (self.value, self.prior): (self.left, self.right)},
indent=1,
{f"{self.value}: {self.prior:.5}": (self.left, self.right)}, indent=1,
)
def __str__(self):

View File

@ -1,4 +1,4 @@
class Heap(object):
class Heap:
"""A generic Heap class, can be used as min or max by passing the key function accordingly.
"""

View File

@ -28,7 +28,7 @@ class HashTable:
def _step_by_step(self, step_ord):
print("step {0}".format(step_ord))
print(f"step {step_ord}")
print([i for i in range(len(self.values))])
print(self.values)

View File

@ -1,7 +1,7 @@
__author__ = "Omkar Pathak"
class Stack(object):
class Stack:
""" A stack is an abstract data type that serves as a collection of
elements with two principal operations: push() and pop(). push() adds an
element to the top of the stack, and pop() removes an element from the top