Skip to content

Commit

Permalink
style: format code with Black
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in b37a211 according to the output
from Black.

Details: #23
  • Loading branch information
deepsource-autofix[bot] authored Jan 17, 2024
1 parent b37a211 commit 8832966
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
7 changes: 3 additions & 4 deletions codeinsight_sdk/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ def get_project_vulnerabilities(
"""
# First we get the inventory for the project
# Then we iterate over the inventory items and calling the inventory vulnerability endpoint for each item with a vulnerability
inventory = self.client.projects.get_inventory(project_id,
skip_vulnerabilities=False,
include_files=True
inventory = self.client.projects.get_inventory(
project_id, skip_vulnerabilities=False, include_files=True
)

# Iterate over the inventory items, find which have vulnerabilities.
Expand All @@ -38,6 +37,6 @@ def get_project_vulnerabilities(
# If the item no no vulnerabilities, ignore it
if len(item.vulnerabilities) == 0:
continue
#TODO: Summarize the vulnerabilities?
# TODO: Summarize the vulnerabilities?
vuln_items.append(item)
return vuln_items
12 changes: 6 additions & 6 deletions examples/example-9-dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from codeinsight_sdk.client import CodeInsightClient

print("Example 9: Working with Pandas DataFrames")
PROJECT_ID = 1 # Update this to your project ID
PROJECT_ID = 1 # Update this to your project ID

client = CodeInsightClient(shared.BASE_URL, shared.AUTH_TOKEN,experimental=True)
client = CodeInsightClient(shared.BASE_URL, shared.AUTH_TOKEN, experimental=True)

# Get all the project vulnerabilities.
# This will return a list of Vulnerability objects.
Expand All @@ -16,17 +16,17 @@

# Now "explode" list of vulnerabilities into separate rows.
# This will create a new row for each vulnerability.
df = df.explode('vulnerabilities', ignore_index=True)
df = df.explode("vulnerabilities", ignore_index=True)

# Next we convert the vulnerabilities column into another DataFrame
# and then merge it back into the original DataFrame so that we can
# access the vulnerability properties as columns.
df_vul = pd.json_normalize(df['vulnerabilities'])
df_vul = pd.json_normalize(df["vulnerabilities"])
df = df.merge(df_vul, left_index=True, right_index=True)

# Optionally we can drop the original vulnerabilities column
# since we no longer need it. You can also drop other columns
df.drop(columns=['vulnerabilities'],inplace=True)
df.drop(columns=["vulnerabilities"], inplace=True)

# Finally we write the output to excel
df.to_excel('example-9-output.xlsx', index=False)
df.to_excel("example-9-output.xlsx", index=False)
4 changes: 3 additions & 1 deletion tests/test_experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ def test_get_project_vulnerabilities(self, client):
)
assert len(vulnerable_items) == 1
assert vulnerable_items[0].vulnerabilities is not None
assert (vulnerable_items[0].vulnerabilities[1].vulnerabilityName == "CVE-987-65432")
assert (
vulnerable_items[0].vulnerabilities[1].vulnerabilityName == "CVE-987-65432"
)

0 comments on commit 8832966

Please sign in to comment.