Skip to content

Commit

Permalink
Use protoc's --pyi_out instead of mypy-protobuf package (#174)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
keepingitneil and github-actions[bot] committed Mar 20, 2024
1 parent 95f4cb8 commit 574fe4e
Show file tree
Hide file tree
Showing 30 changed files with 2,123 additions and 4,412 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/build-protocol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,9 @@ jobs:
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "25.2"
version: "25.3"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: install mypy-protobuf
run: pip3 install mypy-protobuf

- name: generate python stubs
run: ./generate_proto.sh

Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/check-types.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Check Types

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
type-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

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

- name: Download ffi
run: python -m pip install requests && python livekit-rtc/rust-sdks/download_ffi.py --output $(python -m site --user-site)/livekit/rtc/resources

- name: Install mypy
run: python -m pip install --upgrade mypy

- name: Install packages
run: python -m pip install ./livekit-api ./livekit-protocol ./livekit-rtc

- name: Check Types
run: python -m mypy --install-type --non-interactive -p 'livekit-protocol' -p 'livekit-api' -p 'livekit-rtc'
13 changes: 6 additions & 7 deletions livekit-api/livekit/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""LiveKit API SDK
"""
"""LiveKit API SDK"""

# flake8: noqa
# re-export packages from protocol
from livekit.protocol.egress import * # type: ignore
from livekit.protocol.ingress import * # type: ignore
from livekit.protocol.models import * # type: ignore
from livekit.protocol.room import * # type: ignore
from livekit.protocol.webhook import * # type: ignore
from livekit.protocol.egress import *
from livekit.protocol.ingress import *
from livekit.protocol.models import *
from livekit.protocol.room import *
from livekit.protocol.webhook import *

from .twirp_client import TwirpError, TwirpErrorCode
from .livekit_api import LiveKitAPI
Expand Down
Empty file.
5 changes: 3 additions & 2 deletions livekit-api/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@

import os
import pathlib
from typing import Any, Dict

import setuptools
import setuptools # type: ignore

here = pathlib.Path(__file__).parent.resolve()
about = {}
about: Dict[Any, Any] = {}
with open(os.path.join(here, "livekit", "api", "version.py"), "r") as f:
exec(f.read(), about)

Expand Down
3 changes: 2 additions & 1 deletion livekit-api/tests/test_access_token.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
import datetime

import pytest # type: ignore
from livekit.api import AccessToken, TokenVerifier, VideoGrants

TEST_API_KEY = "myapikey"
Expand Down
7 changes: 4 additions & 3 deletions livekit-api/tests/test_webhook.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import pytest
from livekit.api import WebhookReceiver, TokenVerifier, AccessToken
import hashlib
import base64
import hashlib

import pytest # type: ignore
from livekit.api import AccessToken, TokenVerifier, WebhookReceiver

TEST_API_KEY = "myapikey"
TEST_API_SECRET = "thiskeyistotallyunsafe"
Expand Down
2 changes: 1 addition & 1 deletion livekit-protocol/generate_proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ API_OUT_PYTHON=./livekit/protocol
protoc \
-I=$API_PROTOCOL \
--python_out=$API_OUT_PYTHON \
--mypy_out=$API_OUT_PYTHON \
--pyi_out=$API_OUT_PYTHON \
$API_PROTOCOL/livekit_egress.proto \
$API_PROTOCOL/livekit_room.proto \
$API_PROTOCOL/livekit_webhook.proto \
Expand Down
2 changes: 1 addition & 1 deletion livekit-protocol/livekit/protocol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
from . import models
from . import room
from . import webhook
from .version import __version__
from .version import __version__
2 changes: 1 addition & 1 deletion livekit-protocol/livekit/protocol/agent.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 574fe4e

Please sign in to comment.