Skip to content

Commit 0228f31

Browse files
committed
feat(packages): fixed all mypy issues
1 parent 8988bb2 commit 0228f31

30 files changed

+219
-156
lines changed

.github/ISSUE_TEMPLATE/custom.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,3 @@ labels: ''
66
assignees: ''
77

88
---
9-
10-

.github/dependabot.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: 2
22
updates:
3-
- package-ecosystem: "pip"
4-
directory: "/"
5-
schedule:
6-
interval: "weekly"
3+
- package-ecosystem: "pip"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/codeql-analysis.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ name: "CodeQL"
1313

1414
on:
1515
push:
16-
branches: [ "main" ]
16+
branches: ["main"]
1717
pull_request:
18-
branches: [ "main" ]
18+
branches: ["main"]
1919
schedule:
20-
- cron: '16 8 * * 4'
20+
- cron: '16 8 * * 4'
2121

2222
jobs:
2323
analyze:
@@ -31,19 +31,19 @@ jobs:
3131
strategy:
3232
fail-fast: false
3333
matrix:
34-
language: [ 'python' ]
34+
language: ['python']
3535
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
3636
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
3737

3838
steps:
39-
- name: Checkout repository
40-
uses: actions/checkout@v3
39+
- name: Checkout repository
40+
uses: actions/checkout@v3
4141

4242
# Initializes the CodeQL tools for scanning.
43-
- name: Initialize CodeQL
44-
uses: github/codeql-action/init@v2
45-
with:
46-
languages: ${{ matrix.language }}
43+
- name: Initialize CodeQL
44+
uses: github/codeql-action/init@v2
45+
with:
46+
languages: ${{ matrix.language }}
4747
# If you wish to specify custom queries, you can do so here or in a config file.
4848
# By default, queries listed here will override any specified in a config file.
4949
# Prefix the list here with "+" to use these queries and those in the config file.
@@ -54,8 +54,8 @@ jobs:
5454

5555
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5656
# If this step fails, then you should remove it and run the build manually (see below)
57-
- name: Autobuild
58-
uses: github/codeql-action/autobuild@v2
57+
- name: Autobuild
58+
uses: github/codeql-action/autobuild@v2
5959

6060
# ℹ️ Command-line programs to run using the OS shell.
6161
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -67,7 +67,7 @@ jobs:
6767
# echo "Run, Build Application using script"
6868
# ./location_of_script_within_repo/buildscript.sh
6969

70-
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@v2
72-
with:
73-
category: "/language:${{matrix.language}}"
70+
- name: Perform CodeQL Analysis
71+
uses: github/codeql-action/analyze@v2
72+
with:
73+
category: "/language:${{matrix.language}}"

.github/workflows/python-app.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: "PyNotion-Lint"
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: ["main"]
66
pull_request:
7-
branches: [ "main" ]
7+
branches: ["main"]
88

99
permissions:
1010
contents: read
@@ -15,16 +15,16 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18-
- uses: actions/checkout@v3
19-
- name: Set up Python 3.10
20-
uses: actions/setup-python@v3
21-
with:
22-
python-version: "3.11"
23-
- name: Install Poetry
24-
uses: snok/install-poetry@v1
25-
- name: Install dependencies
26-
run: |
27-
poetry install
28-
- name: Lint with pylint
29-
run: |
30-
poetry run pylint src
18+
- uses: actions/checkout@v3
19+
- name: Set up Python 3.10
20+
uses: actions/setup-python@v3
21+
with:
22+
python-version: "3.11"
23+
- name: Install Poetry
24+
uses: snok/install-poetry@v1
25+
- name: Install dependencies
26+
run: |
27+
poetry install
28+
- name: Lint with pylint
29+
run: |
30+
poetry run pylint src

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ dmypy.json
130130
.idea
131131
.vscode
132132
*.json
133-
.DS_Store
133+
.DS_Store

.pre-commit-config.yaml

Lines changed: 68 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,69 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
13
repos:
2-
- repo: https://github.com/pre-commit/mirrors-mypy
3-
rev: v1.8.0
4-
hooks:
5-
- id: mypy
6-
name: mypy
7-
description: "Mypy static type checker"
8-
- repo: https://github.com/pycqa/isort
9-
rev: 5.13.2
10-
hooks:
11-
- id: isort
12-
- repo: https://github.com/psf/black
13-
rev: 23.12.1
14-
hooks:
15-
- id: black
16-
name: black
17-
entry: black
18-
description: "Black: The uncompromising code formatter."
19-
language: python
20-
language_version: python3.10
21-
- repo: https://github.com/charliermarsh/ruff-pre-commit
22-
rev: "v0.1.14"
23-
hooks:
24-
- id: ruff
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v2.4.0
6+
hooks:
7+
- id: check-ast
8+
- id: trailing-whitespace
9+
- id: check-toml
10+
- id: end-of-file-fixer
11+
12+
- repo: https://github.com/asottile/add-trailing-comma
13+
rev: v2.1.0
14+
hooks:
15+
- id: add-trailing-comma
16+
17+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
18+
rev: v2.1.0
19+
hooks:
20+
- id: pretty-format-yaml
21+
args:
22+
- --autofix
23+
- --preserve-quotes
24+
- --indent=2
25+
26+
- repo: local
27+
hooks:
28+
- id: ruff
29+
name: ruff
30+
description: "Run 'ruff' for extremely fast Python linting"
31+
entry: ruff check --force-exclude
32+
language: python
33+
types_or: [python, pyi]
34+
args: []
35+
require_serial: true
36+
additional_dependencies: []
37+
minimum_pre_commit_version: "2.9.2"
38+
39+
- id: ruff-format
40+
name: ruff-format
41+
description: "Run 'ruff format' for extremely fast Python formatting"
42+
entry: ruff format --force-exclude
43+
language: python
44+
types_or: [python, pyi]
45+
args: []
46+
require_serial: true
47+
additional_dependencies: []
48+
minimum_pre_commit_version: "2.9.2"
49+
50+
- id: black
51+
name: Format with Black
52+
entry: poetry run black
53+
language: system
54+
types: [python]
55+
56+
- id: isort
57+
name: isort
58+
entry: poetry run isort
59+
language: system
60+
types: [python]
61+
62+
- id: mypy
63+
name: Validate types with MyPy
64+
entry: poetry run mypy
65+
language: system
66+
types: [python]
67+
pass_filenames: false
68+
args:
69+
- "src"

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,3 @@ Follow these steps to set up your development environment for PyNotion:
227227

228228
We welcome contributions to PyNotion! Before making a major change, please open an issue to discuss your proposed
229229
changes. To submit a contribution, simply create a pull request.
230-

examples/database/create_database.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from dotenv import load_dotenv
2-
32
from examples.config import base_config
43
from pynotionclient import PyNotion
54
from pynotionclient.schema.database import (
@@ -30,14 +29,19 @@
3029

3130
# # Create database payload
3231
parent_payload = ParentConfiguration(
33-
type="page_id", page_id=base_config.page_id
32+
type="page_id",
33+
page_id=base_config.page_id,
3434
) # The parent is the page where the database will be created.
3535
icon_payload = IconConfiguration(
36-
type="emoji", emoji="🎮"
36+
type="emoji",
37+
emoji="🎮",
3738
) # The icon is the icon that will be displayed on the database.
3839
text = TextConfiguration(content="Game") # The text is the text that will be displayed as the title of the database.
3940
content = ContentConfiguration(
40-
type="text", plain_text="Game", href="https://www.google.com", text=text
41+
type="text",
42+
plain_text="Game",
43+
href="https://www.google.com",
44+
text=text,
4145
) # The content has other info's of the title.
4246

4347
# Cover schema
@@ -54,15 +58,15 @@
5458
SelectOptionsConfiguration(color="green", name="Code"),
5559
SelectOptionsConfiguration(color="red", name="Game"),
5660
],
57-
)
61+
),
5862
).model_dump(),
5963
"Cuisines": MultiSelectConfiguration(
6064
multi_select=SelectOptionsListConfig(
6165
options=[
6266
SelectOptionsConfiguration(color="orange", name="Italian"),
6367
SelectOptionsConfiguration(color="blue", name="French"),
6468
],
65-
)
69+
),
6670
).model_dump(),
6771
"Price": NumberConfiguration(
6872
number=NumberFormatConfiguration(

examples/database/query_database.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from dotenv import load_dotenv
2-
32
from examples.config import base_config
43
from pynotionclient import PyNotion
54
from pynotionclient.schema.database import (
@@ -24,10 +23,12 @@
2423
filter_object = Filter(page_size=100, filter=property_filter)
2524

2625
response_dict_payload: NotionDatabaseResponseSchema = py_notion_client.database.query_database(
27-
database_id=base_config.database_id, payload=filter_dict
26+
database_id=base_config.database_id,
27+
payload=filter_dict,
2828
)
2929
response_filter_payload: NotionDatabaseResponseSchema = py_notion_client.database.query_database(
30-
database_id=base_config.database_id, payload=filter_object
30+
database_id=base_config.database_id,
31+
payload=filter_object,
3132
)
3233

3334
# Since we are using pydantic the result can be used either as on object or as a dictionary or json.
@@ -36,8 +37,8 @@
3637
# For example: CustomizedSelect is the key name for the table named "CustomizedSelect" in my database.
3738

3839
print(
39-
response_dict_payload.results[0].properties.Name.json(indent=4)
40+
response_dict_payload.results[0].properties.Name.json(indent=4),
4041
) # Print the first result's Select property as json.
4142
print(
42-
response_filter_payload.results[0].properties.Name.json(indent=4)
43+
response_filter_payload.results[0].properties.Name.json(indent=4),
4344
) # Print the first result's Select property as json.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
from pynotionclient.config.constants import Constants
22
from pynotionclient.config.urls import Urls
3+
4+
__all__ = [
5+
"Constants",
6+
"Urls",
7+
]

0 commit comments

Comments
 (0)