Skip to content

Commit 6ec3f72

Browse files
committed
feat: add static type checking support using .pyi stub files
1 parent 561d334 commit 6ec3f72

129 files changed

Lines changed: 80446 additions & 2 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ jobs:
3030
- name: Install dependencies
3131
run: pip install -e .[test]
3232

33+
- name: Verify generated typing stubs
34+
if: matrix.python-version == '3.13'
35+
run: python typing/generate_type_stubs.py --check
36+
3337
- name: Run tests
3438
run: pytest -k "not example"
3539
env:

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ jobs:
2525
- name: Install dependencies
2626
run: pip install -e .[test]
2727

28+
- name: Verify generated typing stubs
29+
if: matrix.python-version == '3.13'
30+
run: python typing/generate_type_stubs.py --check
31+
2832
- name: Run tests
2933
run: pytest -k "not example"
3034
env:
@@ -50,6 +54,7 @@ jobs:
5054
- name: Build sdist and wheel
5155
run: |
5256
pip install build
57+
python typing/generate_type_stubs.py --check
5358
python -m build
5459
5560
- uses: actions/upload-artifact@v7

MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
include README.md HISTORY.md LICENSE
2-
recursive-include tests *.py
2+
recursive-include serpapi *.pyi py.typed
3+
recursive-include tests *.py

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ readme = "README.md"
1010
license = { text = "MIT" }
1111
authors = [{ name = "SerpApi", email = "support@serpapi.com" }]
1212
requires-python = ">=3.6"
13-
dependencies = ["requests"]
13+
dependencies = ["requests", "typing_extensions"]
1414
keywords = [
1515
"scrape", "serp", "api", "serpapi", "scraping", "json", "search",
1616
"localized", "rank", "google", "bing", "baidu", "yandex", "yahoo",
@@ -39,6 +39,7 @@ classifiers = [
3939
[project.optional-dependencies]
4040
color = ["pygments"]
4141
test = ["pytest"]
42+
dev = ["markdownify"]
4243

4344
[project.urls]
4445
Homepage = "https://github.com/serpapi/serpapi-python"
@@ -50,6 +51,10 @@ version = { attr = "serpapi.__version__.__version__" }
5051

5152
[tool.setuptools.packages.find]
5253
exclude = ["tests", "tests.*"]
54+
namespaces = false
55+
56+
[tool.setuptools.package-data]
57+
serpapi = ["*.pyi", "py.typed"]
5358

5459
[tool.pytest.ini_options]
5560
testpaths = ["tests"]

serpapi/__init__.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This file is generated by typing/generate_type_stubs.py.
2+
# Do not edit by hand; update typing/engines/*.json and rerun the generator.
3+
from .__version__ import __version__ as __version__
4+
from .core import Client as Client, account as account, locations as locations, search as search, search_archive as search_archive
5+
from .exceptions import APIKeyNotProvided as APIKeyNotProvided, HTTPConnectionError as HTTPConnectionError, HTTPError as HTTPError, SearchIDNotProvided as SearchIDNotProvided, SerpApiError as SerpApiError, TimeoutError as TimeoutError
6+
from .models import SerpResults as SerpResults

0 commit comments

Comments
 (0)