Applying black formatting
- Fixing flake8 configuration to agree with black - Adding black validation check to github actions
This commit is contained in:
@@ -5,17 +5,19 @@ import catrank_capnp
|
||||
from common import rand_int, rand_double, rand_bool, WORDS
|
||||
from random import choice
|
||||
from string import ascii_letters
|
||||
|
||||
try:
|
||||
# Python 2
|
||||
from itertools import izip
|
||||
# Python 2
|
||||
from itertools import izip
|
||||
except ImportError:
|
||||
izip = zip
|
||||
izip = zip
|
||||
|
||||
|
||||
class Benchmark:
|
||||
def __init__(self, compression):
|
||||
self.Request = catrank_capnp.SearchResultList.new_message
|
||||
self.Response = catrank_capnp.SearchResultList.new_message
|
||||
if compression == 'packed':
|
||||
if compression == "packed":
|
||||
self.from_bytes_request = catrank_capnp.SearchResultList.from_bytes_packed
|
||||
self.from_bytes_response = catrank_capnp.SearchResultList.from_bytes_packed
|
||||
self.to_bytes = lambda x: x.to_bytes_packed()
|
||||
@@ -28,12 +30,14 @@ class Benchmark:
|
||||
goodCount = 0
|
||||
count = rand_int(1000)
|
||||
|
||||
results = request.init('results', count)
|
||||
results = request.init("results", count)
|
||||
|
||||
for i, result in enumerate(results):
|
||||
result.score = 1000 - i
|
||||
url_size = rand_int(100)
|
||||
result.url = "http://example.com/" + ''.join([choice(ascii_letters) for _ in range(url_size)])
|
||||
result.url = "http://example.com/" + "".join(
|
||||
[choice(ascii_letters) for _ in range(url_size)]
|
||||
)
|
||||
|
||||
isCat = rand_bool()
|
||||
isDog = rand_bool()
|
||||
@@ -49,12 +53,12 @@ class Benchmark:
|
||||
|
||||
snippet += [choice(WORDS) for i in range(rand_int(20))]
|
||||
|
||||
result.snippet = ''.join(snippet)
|
||||
result.snippet = "".join(snippet)
|
||||
|
||||
return goodCount
|
||||
|
||||
def handle(self, request, response):
|
||||
results = response.init('results', len(request.results))
|
||||
results = response.init("results", len(request.results))
|
||||
|
||||
for req, resp in izip(request.results, results):
|
||||
score = req.score
|
||||
@@ -68,7 +72,6 @@ class Benchmark:
|
||||
resp.url = req.url
|
||||
resp.snippet = req.snippet
|
||||
|
||||
|
||||
def check(self, response, expected):
|
||||
goodCount = 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user