Skip to content

Commit 703b04f

Browse files
authored
Make the code a bit nicer (ramnes#143)
1 parent 899c257 commit 703b04f

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

examples/databases/create_database.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def manual_inputs(parent_id="", db_name="") -> tuple:
2323
input_text = input("\nEnter the parent page ID or URL: ").strip()
2424
# Checking if the page exists
2525
try:
26-
if input_text[0:4] == "http":
26+
if input_text[:4] == "http":
2727
parent_id = get_id(input_text)
2828
print(f"\nThe ID of the target page is: {parent_id}")
2929
else:
@@ -78,10 +78,9 @@ def create_database(parent_id: str, db_name: str) -> dict:
7878
title = [{"type": "text", "text": {"content": db_name}}]
7979
icon = {"type": "emoji", "emoji": "🎉"}
8080
parent = {"type": "page_id", "page_id": parent_id}
81-
newdb = notion.databases.create(
81+
return notion.databases.create(
8282
parent=parent, title=title, properties=properties, icon=icon
8383
)
84-
return newdb
8584

8685

8786
if __name__ == "__main__":

notion_client/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def client(self) -> Union[httpx.Client, httpx.AsyncClient]:
8282

8383
@client.setter
8484
def client(self, client: Union[httpx.Client, httpx.AsyncClient]) -> None:
85-
client.base_url = httpx.URL(self.options.base_url + "/v1/")
85+
client.base_url = httpx.URL(f"{self.options.base_url}/v1/")
8686
client.timeout = httpx.Timeout(timeout=self.options.timeout_ms / 1_000)
8787
client.headers = httpx.Headers(
8888
{

notion_client/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def pick(base: Dict[Any, Any], *keys: str) -> Dict[Any, Any]:
1111

1212
def get_url(object_id: str) -> str:
1313
"""Return the URL for the object with the given id."""
14-
return "https://notion.so/" + UUID(object_id).hex
14+
return f"https://notion.so/{UUID(object_id).hex}"
1515

1616

1717
def get_id(url: str) -> str:

0 commit comments

Comments
 (0)