Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add GitHub Actions check to run mypy #530

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow runs mypy for static type checking.
# See https://mypy.readthedocs.io/en/stable/index.html for more information.
#
# You can adjust the behavior by modifying this file.
name: Run mypy

on:
pull_request:
branches:
- main

jobs:
mypy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mypy
pip install -r requirements.txt

- name: Run mypy
run: mypy google/genai/ --config-file=google/genai/mypy.ini
2 changes: 1 addition & 1 deletion google/genai/_automatic_function_calling_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
if sys.version_info >= (3, 10):
VersionedUnionType = builtin_types.UnionType
else:
VersionedUnionType = typing._UnionGenericAlias
VersionedUnionType = typing._UnionGenericAlias # type: ignore[attr-defined]

_py_builtin_type_to_schema_type = {
str: types.Type.STRING,
Expand Down
2 changes: 1 addition & 1 deletion google/genai/_extra_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
if sys.version_info >= (3, 10):
from types import UnionType
else:
UnionType = typing._UnionGenericAlias
UnionType = typing._UnionGenericAlias # type: ignore[attr-defined]

_DEFAULT_MAX_REMOTE_CALLS_AFC = 10

Expand Down
2 changes: 1 addition & 1 deletion google/genai/_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
_UNION_TYPES = (typing.Union, builtin_types.UnionType)
from typing import TypeGuard
else:
VersionedUnionType = typing._UnionGenericAlias
VersionedUnionType = typing._UnionGenericAlias # type: ignore[attr-defined]
_UNION_TYPES = (typing.Union,)
from typing_extensions import TypeGuard

Expand Down
4 changes: 4 additions & 0 deletions google/genai/mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[mypy]
exclude = tests/.*
plugins = pydantic.mypy
disable_error_code = import-not-found, import-untyped, valid-type