Skip to content

Commit 8e54ab0

Browse files
committed
fix(mypy): fixed mypy issues
1 parent 1b47353 commit 8e54ab0

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

examples/config.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
from functools import lru_cache
2+
from typing import Optional
23

34
from pydantic_settings import BaseSettings, SettingsConfigDict
45

56

67
# Create configuration with pydantic BaseSettings https://pydantic-docs.helpmanual.io/usage/settings/.
78
class Config(BaseSettings):
8-
notion_secret_token: str
9-
database_id: str
10-
page_id: str
9+
notion_secret_token: str = ""
10+
database_id: str = ""
11+
page_id: str = ""
1112

1213
model_config = SettingsConfigDict(
1314
env_file=".env",

examples/database/create_database.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,11 @@
8181
properties=properties,
8282
)
8383

84-
response: CreateDatabaseResponseSchema = py_notion_client.database.create_database(
84+
response: CreateDatabaseResponseSchema | str = py_notion_client.database.create_database(
8585
payload=create_database_payload,
8686
)
8787

88-
print(response.model_dump_json(indent=4))
88+
if isinstance(response, str):
89+
print(response)
90+
else:
91+
print(response.model_dump_json(indent=4))

examples/database/query_database.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
property_filter = PropertyFilter(property="Name", rich_text=rich_text_filter)
1919
filter_object = Filter(page_size=100, filter=property_filter)
2020

21-
response_dict_payload: NotionDatabaseResponseSchema = py_notion_client.database.query_database(
21+
response_dict_payload: NotionDatabaseResponseSchema | str = py_notion_client.database.query_database(
2222
database_id=base_config.database_id,
2323
payload=filter_dict,
2424
)
25-
response_filter_payload: NotionDatabaseResponseSchema = py_notion_client.database.query_database(
25+
response_filter_payload: NotionDatabaseResponseSchema | str = py_notion_client.database.query_database(
2626
database_id=base_config.database_id,
2727
payload=filter_object,
2828
)
@@ -32,9 +32,14 @@
3232
# Inside the properties use the key name you gave for each table in your database to access the value.
3333
# For example: CustomizedSelect is the key name for the table named "CustomizedSelect" in my database.
3434

35-
print(
36-
response_dict_payload.results[0].properties.Name.json(indent=4),
37-
) # Print the first result's Select property as json.
38-
print(
39-
response_filter_payload.results[0].properties.Name.json(indent=4),
40-
) # Print the first result's Select property as json.
35+
if isinstance(response_dict_payload, str):
36+
print(response_dict_payload)
37+
38+
if isinstance(response_dict_payload, NotionDatabaseResponseSchema):
39+
print(
40+
response_dict_payload.results[0].properties.Name.json(indent=4),
41+
) # Print the first result's Select property as json.
42+
if isinstance(response_filter_payload, NotionDatabaseResponseSchema):
43+
print(
44+
response_filter_payload.results[0].properties.Name.json(indent=4),
45+
) # Print the first result's Select property as json.

pynotionclient/schema/database/response/rich_text_filter_schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55

66
class RichTextFilter(ContainsFilter, EqualsFilter, EmptyFilter):
7-
starts_with: Optional[str]
8-
ends_with: Optional[str]
7+
starts_with: Optional[str] = None
8+
ends_with: Optional[str] = None

0 commit comments

Comments
 (0)