Skip to content

Commit 5de9f1a

Browse files
amillertpartheagcf-owl-bot[bot]
authored
style: update import in docs, improve python idiomaticity (#1855)
* docs: change googleapiclient import in README docs * style: improve readability when attempting to access dict value * refactor: no need to iterate over generator to sort its contents * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Anthonios Partheniou <[email protected]> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 1040301 commit 5de9f1a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

samples/compute/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Application default credentials are provided in Google API Client Libraries auto
5252
You just have to build and initialize the API:
5353

5454
```python
55-
import googleapiclient
55+
import googleapiclient.discovery
5656
compute = googleapiclient.discovery.build('compute', 'v1')
5757
```
5858

@@ -67,7 +67,7 @@ You need to provide the project ID and the zone for which you want to list insta
6767
```python
6868
def list_instances(compute, project, zone):
6969
result = compute.instances().list(project=project, zone=zone).execute()
70-
return result['items'] if 'items' in result else None
70+
return result.get('items')
7171
```
7272

7373
## Adding an instance

samples/compute/create_instance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# [START compute_apiary_list_instances]
3333
def list_instances(compute, project, zone):
3434
result = compute.instances().list(project=project, zone=zone).execute()
35-
return result["items"] if "items" in result else None
35+
return result.get("items")
3636

3737

3838
# [END compute_apiary_list_instances]

0 commit comments

Comments
 (0)