-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored master branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,10 +108,7 @@ def test_delete_queue(): | |
@pytest.mark.order10 | ||
def test_retry_task(): | ||
QUEUE_SIZE = 3 | ||
QUEUE_NAME = [] | ||
for i in range(QUEUE_SIZE): | ||
QUEUE_NAME.append("queue-{}".format(uuid.uuid4())) | ||
|
||
QUEUE_NAME = ["queue-{}".format(uuid.uuid4()) for _ in range(QUEUE_SIZE)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function test_retry_task refactored with the following changes:
|
||
name = "projects/{}/locations/{}/queues/{}".format( | ||
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME[2]) | ||
result = snippets.retry_task( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,11 +57,10 @@ def verify_signed_by_app(data, signature): | |
for the application.""" | ||
public_certificates = app_identity.get_public_certificates() | ||
|
||
for cert in public_certificates: | ||
if verify_signature(data, signature, cert.x509_certificate_pem): | ||
return True | ||
|
||
return False | ||
return any( | ||
verify_signature(data, signature, cert.x509_certificate_pem) | ||
for cert in public_certificates | ||
) | ||
Comment on lines
-60
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function verify_signed_by_app refactored with the following changes:
|
||
|
||
|
||
class MainPage(webapp2.RequestHandler): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,5 +16,4 @@ | |
# The app engine runtime will call this function during instance startup. | ||
def webapp_add_wsgi_middleware(app): | ||
from google.appengine.ext.appstats import recording | ||
app = recording.appstats_wsgi_middleware(app) | ||
return app | ||
return recording.appstats_wsgi_middleware(app) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function webapp_add_wsgi_middleware refactored with the following changes:
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,5 +31,4 @@ def webapp_add_wsgi_middleware(app): | |
The wrapped WSGI application. | ||
""" | ||
|
||
app = I18nMiddleware(app) | ||
return app | ||
return I18nMiddleware(app) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function webapp_add_wsgi_middleware refactored with the following changes:
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,9 +22,8 @@ class Account(ndb.Model): | |
|
||
|
||
def create_entity_using_keyword_arguments(): | ||
sandy = Account( | ||
return Account( | ||
username='Sandy', userid=123, email='[email protected]') | ||
return sandy | ||
Comment on lines
-25
to
-27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function create_entity_using_keyword_arguments refactored with the following changes:
|
||
|
||
|
||
def create_entity_using_attributes(): | ||
|
@@ -55,13 +54,11 @@ def demonstrate_entity_attribute_type_checking(sandy): | |
|
||
|
||
def save_entity(sandy): | ||
sandy_key = sandy.put() | ||
return sandy_key | ||
return sandy.put() | ||
Comment on lines
-58
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function save_entity refactored with the following changes:
|
||
|
||
|
||
def get_entity(sandy_key): | ||
sandy = sandy_key.get() | ||
return sandy | ||
return sandy_key.get() | ||
Comment on lines
-63
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function get_entity refactored with the following changes:
|
||
|
||
|
||
def get_key_kind_and_id(sandy_key): | ||
|
@@ -71,14 +68,12 @@ def get_key_kind_and_id(sandy_key): | |
|
||
|
||
def get_url_safe_key(sandy_key): | ||
url_string = sandy_key.urlsafe() | ||
return url_string | ||
return sandy_key.urlsafe() | ||
Comment on lines
-74
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function get_url_safe_key refactored with the following changes:
|
||
|
||
|
||
def get_entity_from_url_safe_key(url_string): | ||
sandy_key = ndb.Key(urlsafe=url_string) | ||
sandy = sandy_key.get() | ||
return sandy | ||
return sandy_key.get() | ||
Comment on lines
-80
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function get_entity_from_url_safe_key refactored with the following changes:
|
||
|
||
|
||
def get_key_and_numeric_id_from_url_safe_key(url_string): | ||
|
@@ -145,8 +140,7 @@ def equivalent_ways_to_define_key_with_parent(): | |
|
||
|
||
def create_root_key(): | ||
sandy_key = ndb.Key(Account, '[email protected]') | ||
return sandy_key | ||
return ndb.Key(Account, '[email protected]') | ||
Comment on lines
-148
to
+143
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function create_root_key refactored with the following changes:
|
||
|
||
|
||
def create_entity_with_parent_keys(): | ||
|
@@ -168,8 +162,7 @@ def create_entity_with_parent_keys(): | |
|
||
|
||
def get_parent_key_of_entity(initial_revision): | ||
message_key = initial_revision.key.parent() | ||
return message_key | ||
return initial_revision.key.parent() | ||
Comment on lines
-171
to
+165
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function get_parent_key_of_entity refactored with the following changes:
|
||
|
||
|
||
def operate_on_multiple_keys_at_once(list_of_entities): | ||
|
@@ -207,8 +200,7 @@ class FlexEmployee(ndb.Expando): | |
|
||
|
||
def create_expando_model_entity_with_defined_properties(): | ||
employee = FlexEmployee(name='Sandy', location='SF') | ||
return employee | ||
return FlexEmployee(name='Sandy', location='SF') | ||
Comment on lines
-210
to
+203
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function create_expando_model_entity_with_defined_properties refactored with the following changes:
|
||
|
||
|
||
class Specialized(ndb.Expando): | ||
|
@@ -276,8 +268,7 @@ def reserve_model_ids_with_a_parent(p): | |
|
||
|
||
def construct_keys_from_range_of_reserved_ids(first, last): | ||
keys = [ndb.Key(MyModel, id) for id in range(first, last+1)] | ||
return keys | ||
return [ndb.Key(MyModel, id) for id in range(first, last+1)] | ||
Comment on lines
-279
to
+271
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function construct_keys_from_range_of_reserved_ids refactored with the following changes:
|
||
|
||
|
||
def reserve_model_ids_up_to(N): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,5 +57,4 @@ class Foo(ndb.Model): | |
|
||
|
||
def declare_multiple_valued_property(): | ||
entity = Foo(A=[1, 1, 2, 3], B=['x', 'y', 'x']) | ||
return entity | ||
return Foo(A=[1, 1, 2, 3], B=['x', 'y', 'x']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function declare_multiple_valued_property refactored with the following changes:
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,7 @@ def create_entity(): | |
# Create an entity and write it to the Datastore. | ||
entity = my_models.MyModel(name='booh', xyz=[10**100, 6**666]) | ||
assert entity.abc == 0 | ||
key = entity.put() | ||
return key | ||
return entity.put() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function create_entity refactored with the following changes:
|
||
|
||
|
||
def read_and_update_entity(key): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,18 +20,15 @@ | |
|
||
|
||
def query_account_equality(): | ||
query = Account.query(Account.userid == 42) | ||
return query | ||
return Account.query(Account.userid == 42) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_account_equality refactored with the following changes:
|
||
|
||
|
||
def query_account_inequality(): | ||
query = Account.query(Account.userid >= 40) | ||
return query | ||
return Account.query(Account.userid >= 40) | ||
Comment on lines
-28
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_account_inequality refactored with the following changes:
|
||
|
||
|
||
def query_account_multiple_filters(): | ||
query = Account.query(Account.userid >= 40, Account.userid < 50) | ||
return query | ||
return Account.query(Account.userid >= 40, Account.userid < 50) | ||
Comment on lines
-33
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_account_multiple_filters refactored with the following changes:
|
||
|
||
|
||
def query_account_in_steps(): | ||
|
@@ -42,14 +39,12 @@ def query_account_in_steps(): | |
|
||
|
||
def query_article_inequality(): | ||
query = Article.query(Article.tags != 'perl') | ||
return query | ||
return Article.query(Article.tags != 'perl') | ||
Comment on lines
-45
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_article_inequality refactored with the following changes:
|
||
|
||
|
||
def query_article_inequality_explicit(): | ||
query = Article.query(ndb.OR(Article.tags < 'perl', | ||
return Article.query(ndb.OR(Article.tags < 'perl', | ||
Article.tags > 'perl')) | ||
return query | ||
Comment on lines
-50
to
-52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_article_inequality_explicit refactored with the following changes:
|
||
|
||
|
||
def articles_with_tags_example(): | ||
|
@@ -66,33 +61,28 @@ def articles_with_tags_example(): | |
|
||
|
||
def query_article_in(): | ||
query = Article.query(Article.tags.IN(['python', 'ruby', 'php'])) | ||
return query | ||
return Article.query(Article.tags.IN(['python', 'ruby', 'php'])) | ||
Comment on lines
-69
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_article_in refactored with the following changes:
|
||
|
||
|
||
def query_article_in_equivalent(): | ||
query = Article.query(ndb.OR(Article.tags == 'python', | ||
return Article.query(ndb.OR(Article.tags == 'python', | ||
Article.tags == 'ruby', | ||
Article.tags == 'php')) | ||
return query | ||
Comment on lines
-74
to
-77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_article_in_equivalent refactored with the following changes:
|
||
|
||
|
||
def query_article_nested(): | ||
query = Article.query(ndb.AND(Article.tags == 'python', | ||
return Article.query(ndb.AND(Article.tags == 'python', | ||
ndb.OR(Article.tags.IN(['ruby', 'jruby']), | ||
ndb.AND(Article.tags == 'php', | ||
Article.tags != 'perl')))) | ||
return query | ||
Comment on lines
-81
to
-85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_article_nested refactored with the following changes:
|
||
|
||
|
||
def query_greeting_order(): | ||
query = Greeting.query().order(Greeting.content, -Greeting.date) | ||
return query | ||
return Greeting.query().order(Greeting.content, -Greeting.date) | ||
Comment on lines
-89
to
+81
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_greeting_order refactored with the following changes:
|
||
|
||
|
||
def query_greeting_multiple_orders(): | ||
query = Greeting.query().order(Greeting.content).order(-Greeting.date) | ||
return query | ||
return Greeting.query().order(Greeting.content).order(-Greeting.date) | ||
Comment on lines
-94
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_greeting_multiple_orders refactored with the following changes:
|
||
|
||
|
||
def query_purchase_with_customer_key(): | ||
|
@@ -106,9 +96,8 @@ class Purchase(ndb.Model): | |
# [END purchase_with_customer_key_models] | ||
|
||
def query_purchases_for_customer_via_key(customer_entity): | ||
purchases = Purchase.query( | ||
return Purchase.query( | ||
Purchase.customer == customer_entity.key).fetch() | ||
return purchases | ||
Comment on lines
-109
to
-111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_purchase_with_customer_key.query_purchases_for_customer_via_key refactored with the following changes:
|
||
|
||
return Customer, Purchase, query_purchases_for_customer_via_key | ||
|
||
|
@@ -123,12 +112,10 @@ class Purchase(ndb.Model): | |
# [END purchase_with_ancestor_key_models] | ||
|
||
def create_purchase_for_customer_with_ancestor(customer_entity): | ||
purchase = Purchase(parent=customer_entity.key) | ||
return purchase | ||
return Purchase(parent=customer_entity.key) | ||
Comment on lines
-126
to
+115
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_purchase_with_ancestor_key.create_purchase_for_customer_with_ancestor refactored with the following changes:
|
||
|
||
def query_for_purchases_of_customer_with_ancestor(customer_entity): | ||
purchases = Purchase.query(ancestor=customer_entity.key).fetch() | ||
return purchases | ||
return Purchase.query(ancestor=customer_entity.key).fetch() | ||
Comment on lines
-130
to
+118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_purchase_with_ancestor_key.query_for_purchases_of_customer_with_ancestor refactored with the following changes:
|
||
|
||
return (Customer, Purchase, | ||
create_purchase_for_customer_with_ancestor, | ||
|
@@ -143,36 +130,30 @@ def print_query(): | |
|
||
|
||
def query_contact_with_city(): | ||
query = Contact.query(Contact.addresses.city == 'Amsterdam') | ||
return query | ||
return Contact.query(Contact.addresses.city == 'Amsterdam') | ||
Comment on lines
-146
to
+133
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_contact_with_city refactored with the following changes:
|
||
|
||
|
||
def query_contact_sub_entities_beware(): | ||
query = Contact.query(Contact.addresses.city == 'Amsterdam', # Beware! | ||
return Contact.query(Contact.addresses.city == 'Amsterdam', # Beware! | ||
Contact.addresses.street == 'Spear St') | ||
return query | ||
Comment on lines
-151
to
-153
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_contact_sub_entities_beware refactored with the following changes:
|
||
|
||
|
||
def query_contact_multiple_values_in_single_sub_entity(): | ||
query = Contact.query(Contact.addresses == Address(city='San Francisco', | ||
return Contact.query(Contact.addresses == Address(city='San Francisco', | ||
street='Spear St')) | ||
return query | ||
Comment on lines
-157
to
-159
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_contact_multiple_values_in_single_sub_entity refactored with the following changes:
|
||
|
||
|
||
def query_properties_named_by_string_on_expando(): | ||
property_to_query = 'location' | ||
query = FlexEmployee.query(ndb.GenericProperty(property_to_query) == 'SF') | ||
return query | ||
return FlexEmployee.query(ndb.GenericProperty(property_to_query) == 'SF') | ||
Comment on lines
-164
to
+148
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_properties_named_by_string_on_expando refactored with the following changes:
|
||
|
||
|
||
def query_properties_named_by_string_for_defined_properties(keyword, value): | ||
query = Article.query(Article._properties[keyword] == value) | ||
return query | ||
return Article.query(Article._properties[keyword] == value) | ||
Comment on lines
-169
to
+152
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_properties_named_by_string_for_defined_properties refactored with the following changes:
|
||
|
||
|
||
def query_properties_named_by_string_using_getattr(keyword, value): | ||
query = Article.query(getattr(Article, keyword) == value) | ||
return query | ||
return Article.query(getattr(Article, keyword) == value) | ||
Comment on lines
-174
to
+156
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function query_properties_named_by_string_using_getattr refactored with the following changes:
|
||
|
||
|
||
def order_query_results_by_property(keyword): | ||
|
@@ -232,5 +213,4 @@ def fetch_good_articles_using_gql_with_explicit_bind(): | |
|
||
|
||
def fetch_good_articles_using_gql_with_inlined_bind(): | ||
query = ndb.gql("SELECT * FROM Article WHERE stars > :1", 3) | ||
return query | ||
return ndb.gql("SELECT * FROM Article WHERE stars > :1", 3) | ||
Comment on lines
-235
to
+216
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function fetch_good_articles_using_gql_with_inlined_bind refactored with the following changes:
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -318,7 +318,7 @@ def test_print_query_keys(testbed, capsys): | |
|
||
|
||
def test_reverse_queries(testbed): | ||
for i in range(11): | ||
for _ in range(11): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function test_reverse_queries refactored with the following changes:
|
||
Bar().put() | ||
|
||
(bars, cursor, more), (r_bars, r_cursor, r_more) = ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ def search_terms(index): | |
|
||
|
||
def create_document(): | ||
document = search.Document( | ||
return search.Document( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function create_document refactored with the following changes:
|
||
# Setting the doc_id is optional. If omitted, the search service will | ||
# create an identifier. | ||
doc_id='PA6-5000', | ||
|
@@ -46,7 +46,6 @@ def create_document(): | |
search.GeoField( | ||
name='home_location', value=search.GeoPoint(37.619, -122.37)) | ||
]) | ||
return document | ||
|
||
|
||
def add_document_to_index(document): | ||
|
@@ -57,8 +56,7 @@ def add_document_to_index(document): | |
def add_document_and_get_doc_id(documents): | ||
index = search.Index('products') | ||
results = index.put(documents) | ||
document_ids = [document.id for document in results] | ||
return document_ids | ||
return [document.id for document in results] | ||
Comment on lines
-60
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function add_document_and_get_doc_id refactored with the following changes:
|
||
|
||
|
||
def get_document_by_id(): | ||
|
@@ -104,8 +102,7 @@ def delete_all_in_index(index): | |
|
||
def async_query(index): | ||
futures = [index.search_async('foo'), index.search_async('bar')] | ||
results = [future.get_result() for future in futures] | ||
return results | ||
return [future.get_result() for future in futures] | ||
Comment on lines
-107
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function async_query refactored with the following changes:
|
||
|
||
|
||
def query_options(): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,9 +36,7 @@ def send_simple_message(recipient): | |
html_content='<strong>Example</strong> message.') | ||
|
||
sg = sendgrid.SendGridAPIClient(SENDGRID_API_KEY) | ||
response = sg.send(message) | ||
|
||
return response | ||
return sg.send(message) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function send_simple_message refactored with the following changes:
|
||
# [END sendgrid-send] | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,13 +45,11 @@ def upload_object(self, bucket, file_object): | |
bucket=bucket, body=body, | ||
media_body=googleapiclient.http.MediaIoBaseUpload( | ||
file_object, 'application/octet-stream')) | ||
resp = req.execute() | ||
return resp | ||
return req.execute() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function MainPage.upload_object refactored with the following changes:
|
||
|
||
def delete_object(self, bucket, filename): | ||
req = storage.objects().delete(bucket=bucket, object=filename) | ||
resp = req.execute() | ||
return resp | ||
return req.execute() | ||
Comment on lines
-53
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function MainPage.delete_object refactored with the following changes:
|
||
|
||
def get(self): | ||
string_io_file = StringIO.StringIO('Hello World!') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,9 +39,7 @@ def fetch_times(limit): | |
query = datastore_client.query(kind='visit') | ||
query.order = ['-timestamp'] | ||
|
||
times = query.fetch(limit=limit) | ||
|
||
return times | ||
return query.fetch(limit=limit) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function fetch_times refactored with the following changes:
|
||
# [END gae_python37_datastore_store_and_fetch_times] | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function map_services refactored with the following changes: