Conversation
| # 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): |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
Function _get_changed_files refactored with the following changes:
- Replace unneeded comprehension with generator
- Replace list(), dict() or set() with comprehension
| 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) |
There was a problem hiding this comment.
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)] |
There was a problem hiding this comment.
Function test_retry_task refactored with the following changes:
- Replace unused for index with underscore
- Convert for loop into list comprehension
| 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 | ||
| ) |
There was a problem hiding this comment.
Function verify_signed_by_app refactored with the following changes:
- Use any() instead of for loop
| 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)] |
There was a problem hiding this comment.
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']) |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Function query_account_equality refactored with the following changes:
- Inline variable that is only used once
| query = Account.query(Account.userid >= 40) | ||
| return query | ||
| return Account.query(Account.userid >= 40) |
There was a problem hiding this comment.
Function query_account_inequality refactored with the following changes:
- Inline variable that is only used once
| query = Account.query(Account.userid >= 40, Account.userid < 50) | ||
| return query | ||
| return Account.query(Account.userid >= 40, Account.userid < 50) |
There was a problem hiding this comment.
Function query_account_multiple_filters refactored with the following changes:
- Inline variable that is only used once
| query = Article.query(Article.tags != 'perl') | ||
| return query | ||
| return Article.query(Article.tags != 'perl') |
There was a problem hiding this comment.
Function query_article_inequality refactored with the following changes:
- Inline variable that is only used once
| query = Article.query(ndb.OR(Article.tags < 'perl', | ||
| return Article.query(ndb.OR(Article.tags < 'perl', | ||
| Article.tags > 'perl')) | ||
| return query |
There was a problem hiding this comment.
Function query_article_inequality_explicit refactored with the following changes:
- Inline variable that is only used once
| query = Article.query(Article.tags.IN(['python', 'ruby', 'php'])) | ||
| return query | ||
| return Article.query(Article.tags.IN(['python', 'ruby', 'php'])) |
There was a problem hiding this comment.
Function query_article_in refactored with the following changes:
- Inline variable that is only used once
| query = Article.query(ndb.OR(Article.tags == 'python', | ||
| return Article.query(ndb.OR(Article.tags == 'python', | ||
| Article.tags == 'ruby', | ||
| Article.tags == 'php')) | ||
| return query |
There was a problem hiding this comment.
Function query_article_in_equivalent refactored with the following changes:
- Inline variable that is only used once
| query = Article.query(Article._properties[keyword] == value) | ||
| return query | ||
| return Article.query(Article._properties[keyword] == value) |
There was a problem hiding this comment.
Function query_properties_named_by_string_for_defined_properties refactored with the following changes:
- Inline variable that is only used once
| query = Article.query(getattr(Article, keyword) == value) | ||
| return query | ||
| return Article.query(getattr(Article, keyword) == value) |
There was a problem hiding this comment.
Function query_properties_named_by_string_using_getattr refactored with the following changes:
- Inline variable that is only used once
| query = ndb.gql("SELECT * FROM Article WHERE stars > :1", 3) | ||
| return query | ||
| return ndb.gql("SELECT * FROM Article WHERE stars > :1", 3) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
Function test_reverse_queries refactored with the following changes:
- Replace unused for index with underscore
|
|
||
| def create_document(): | ||
| document = search.Document( | ||
| return search.Document( |
There was a problem hiding this comment.
Function create_document refactored with the following changes:
- Inline variable that is only used once
| document_ids = [document.id for document in results] | ||
| return document_ids | ||
| return [document.id for document in results] |
There was a problem hiding this comment.
Function add_document_and_get_doc_id refactored with the following changes:
- Inline variable that is only used once
| results = [future.get_result() for future in futures] | ||
| return results | ||
| return [future.get_result() for future in futures] |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
Function MainPage.upload_object refactored with the following changes:
- Inline variable that is only used once
| resp = req.execute() | ||
| return resp | ||
| return req.execute() |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Function create_note refactored with the following changes:
- Inline variable that is only used once
Branch
masterrefactored 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
masterbranch, then run: