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

Use protoc's --pyi_out instead of mypy-protobuf package #174

Merged
merged 30 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8bc29be
Use protoc's pyi_out instead of mypy-protobuf package
keepingitneil Mar 19, 2024
e7f991b
type check GHA
keepingitneil Mar 19, 2024
6b86458
generated protobuf
github-actions[bot] Mar 19, 2024
f8d4e71
check types after building protocol
keepingitneil Mar 19, 2024
769fcae
generated protobuf
github-actions[bot] Mar 19, 2024
c0f038f
make sure of success
keepingitneil Mar 19, 2024
bfff2ed
fix ruff
keepingitneil Mar 19, 2024
675085c
run on every push while we iterate
keepingitneil Mar 19, 2024
893f060
cooking
keepingitneil Mar 19, 2024
19dbdbd
remove condition
keepingitneil Mar 19, 2024
354d9b4
cooking
keepingitneil Mar 19, 2024
7434dc8
list packages
keepingitneil Mar 19, 2024
d26aec4
list packages
keepingitneil Mar 19, 2024
1fee61e
cooking
keepingitneil Mar 19, 2024
437a214
py.typed files
keepingitneil Mar 19, 2024
6a9601c
install types
keepingitneil Mar 19, 2024
7b28202
cooking
keepingitneil Mar 19, 2024
82ad9f3
cooking
keepingitneil Mar 19, 2024
c0707f6
types
keepingitneil Mar 19, 2024
32be456
cooking
keepingitneil Mar 19, 2024
5b244d1
include bad types to make sure the type checker is actually working
keepingitneil Mar 19, 2024
e8b3218
generated protobuf
github-actions[bot] Mar 19, 2024
afab34e
types working
keepingitneil Mar 19, 2024
8146668
Update __init__.py
keepingitneil Mar 20, 2024
a094f65
Update __init__.py
keepingitneil Mar 20, 2024
ef119b9
Update room.py
keepingitneil Mar 20, 2024
c7d9c79
Test bad type
keepingitneil Mar 20, 2024
d1573a0
test bad type
keepingitneil Mar 20, 2024
b77ca65
fix type after testing
keepingitneil Mar 20, 2024
4b5b969
typo
keepingitneil Mar 20, 2024
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
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
Loading