Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Jun 11, 2020

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to GitHub API limits, only the first 60 comments can be shown.

# Get root of this repository. Assume we don't have directories nested deeper than 10 items.
p = Path(os.getcwd())
for i in range(10):
for _ in range(10):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 26-26 refactored with the following changes:

  • Replace unused for index with underscore

changed_files = ci_diff_helper.get_changed_files("HEAD", config.base)

changed_files = set(["./{}".format(filename) for filename in changed_files])
changed_files = {"./{}".format(filename) for filename in changed_files}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _get_changed_files refactored with the following changes:

  • Replace unneeded comprehension with generator
  • Replace list(), dict() or set() with comprehension

Comment on lines -38 to +41
if environment == 'production':
url_map[service] = production_url(service)
if environment == 'development':
url_map[service] = local_url(local_port)
elif environment == 'production':
url_map[service] = production_url(service)
Copy link
Author

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:

  • Simplify conditional into switch-like form

for i in range(QUEUE_SIZE):
QUEUE_NAME.append("queue-{}".format(uuid.uuid4()))

QUEUE_NAME = ["queue-{}".format(uuid.uuid4()) for _ in range(QUEUE_SIZE)]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_retry_task refactored with the following changes:

  • Replace unused for index with underscore
  • Convert for loop into list comprehension

Comment on lines -60 to +63
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
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function verify_signed_by_app refactored with the following changes:

  • Use any() instead of for loop

Comment on lines -279 to +271
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)]
Copy link
Author

Choose a reason for hiding this comment

The 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:

  • Inline variable that is only used once

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'])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function declare_multiple_valued_property refactored with the following changes:

  • Inline variable that is only used once

assert entity.abc == 0
key = entity.put()
return key
return entity.put()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function create_entity refactored with the following changes:

  • Inline variable that is only used once

def query_account_equality():
query = Account.query(Account.userid == 42)
return query
return Account.query(Account.userid == 42)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function query_account_equality refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -28 to +27
query = Account.query(Account.userid >= 40)
return query
return Account.query(Account.userid >= 40)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function query_account_inequality refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -33 to +31
query = Account.query(Account.userid >= 40, Account.userid < 50)
return query
return Account.query(Account.userid >= 40, Account.userid < 50)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function query_account_multiple_filters refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -45 to +42
query = Article.query(Article.tags != 'perl')
return query
return Article.query(Article.tags != 'perl')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function query_article_inequality refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -50 to -52
query = Article.query(ndb.OR(Article.tags < 'perl',
return Article.query(ndb.OR(Article.tags < 'perl',
Article.tags > 'perl'))
return query
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function query_article_inequality_explicit refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -69 to +64
query = Article.query(Article.tags.IN(['python', 'ruby', 'php']))
return query
return Article.query(Article.tags.IN(['python', 'ruby', 'php']))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function query_article_in refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -74 to -77
query = Article.query(ndb.OR(Article.tags == 'python',
return Article.query(ndb.OR(Article.tags == 'python',
Article.tags == 'ruby',
Article.tags == 'php'))
return query
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function query_article_in_equivalent refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -169 to +152
query = Article.query(Article._properties[keyword] == value)
return query
return Article.query(Article._properties[keyword] == value)
Copy link
Author

Choose a reason for hiding this comment

The 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:

  • Inline variable that is only used once

Comment on lines -174 to +156
query = Article.query(getattr(Article, keyword) == value)
return query
return Article.query(getattr(Article, keyword) == value)
Copy link
Author

Choose a reason for hiding this comment

The 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:

  • Inline variable that is only used once

Comment on lines -235 to +216
query = ndb.gql("SELECT * FROM Article WHERE stars > :1", 3)
return query
return ndb.gql("SELECT * FROM Article WHERE stars > :1", 3)
Copy link
Author

Choose a reason for hiding this comment

The 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:

  • Inline variable that is only used once


def test_reverse_queries(testbed):
for i in range(11):
for _ in range(11):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_reverse_queries refactored with the following changes:

  • Replace unused for index with underscore


def create_document():
document = search.Document(
return search.Document(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function create_document refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -60 to +59
document_ids = [document.id for document in results]
return document_ids
return [document.id for document in results]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function add_document_and_get_doc_id refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -107 to +105
results = [future.get_result() for future in futures]
return results
return [future.get_result() for future in futures]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function async_query refactored with the following changes:

  • Inline variable that is only used once

response = sg.send(message)

return response
return sg.send(message)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function send_simple_message refactored with the following changes:

  • Inline variable that is only used once

file_object, 'application/octet-stream'))
resp = req.execute()
return resp
return req.execute()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function MainPage.upload_object refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -53 to +52
resp = req.execute()
return resp
return req.execute()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function MainPage.delete_object refactored with the following changes:

  • Inline variable that is only used once

main.app.testing = True
client = main.app.test_client()
return client
return main.app.test_client()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function app refactored with the following changes:

  • Inline variable that is only used once

def list_buckets(service, project_id):
buckets = service.buckets().list(project=project_id).execute()
return buckets
return service.buckets().list(project=project_id).execute()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function list_buckets refactored with the following changes:

  • Inline variable that is only used once

def busy_wait(self):
for _ in range(100000):
pass
pass
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function CpuBurner.busy_wait refactored with the following changes:

  • Hoist statements out of for/while loops

label=None))
encoded_wrapped_key = base64.b64encode(wrapped_key)
return encoded_wrapped_key
return base64.b64encode(wrapped_key)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function wrap_rsa_key refactored with the following changes:

  • Inline variable that is only used once

}
response = grafeas_client.create_note(project_name, note_id, note)
return response
return grafeas_client.create_note(project_name, note_id, note)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function create_note refactored with the following changes:

  • Inline variable that is only used once

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants