-
-
Notifications
You must be signed in to change notification settings - Fork 469
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate and Enhance Type Checking with Mypy (#264)
Co-authored-by: Jason Liu <jxnl@users.noreply.github.com>
- Loading branch information
1 parent
161f0dd
commit 94e3296
Showing
9 changed files
with
304 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Continuous Integration | ||
|
||
on: | ||
push: | ||
pull_request: | ||
branches: [ main ] | ||
|
||
env: | ||
WORKING_DIRECTORY: "." | ||
MYPY_OUTPUT_FILENAME: "mypy.log" | ||
CUSTOM_FLAGS: "--python-version=3.9 --color-output --no-pretty --follow-imports=skip" | ||
CUSTOM_PACKAGES: "instructor/cli/cli.py instructor/cli/usage.py" | ||
|
||
jobs: | ||
MyPy: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Environment setup | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
- name: Install dev dependencies | ||
run: | | ||
python3 -m pip install --upgrade pip setuptools wheel | ||
python3 -m pip install -r requirements.txt | ||
- name: Run Continuous Integration Action | ||
run: | | ||
export CUSTOM_PACKAGES="${{ env.CUSTOM_PACKAGES }}" && | ||
export CUSTOM_FLAGS="${{ env.CUSTOM_FLAGS }}" && | ||
curl -sSL https://raw.githubusercontent.com/gao-hongnan/omniverse/continuous-integration/scripts/devops/continuous-integration/type_mypy.sh | | ||
bash | tee ${{ env.WORKING_DIRECTORY }}/${{ env.MYPY_OUTPUT_FILENAME }} | ||
- name: Upload Artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: mypy-log | ||
path: ${{ env.WORKING_DIRECTORY }}/${{ env.MYPY_OUTPUT_FILENAME }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Reference: | ||
# https://github.com/openai/openai-python/blob/main/mypy.ini | ||
# https://github.com/pytorch/pytorch/blob/main/mypy.ini | ||
[mypy] | ||
pretty=True | ||
show_error_codes=True | ||
python_version=3.9 | ||
|
||
strict_equality=True | ||
implicit_reexport=True | ||
check_untyped_defs=True | ||
no_implicit_optional=True | ||
|
||
warn_return_any=False | ||
warn_unreachable=True | ||
warn_unused_configs=True | ||
|
||
# Turn these options off as it could cause conflicts | ||
# with the Pyright options. | ||
warn_unused_ignores=False | ||
warn_redundant_casts=False | ||
|
||
disallow_any_generics=True | ||
disallow_untyped_defs=True | ||
disallow_untyped_calls=True | ||
disallow_subclassing_any=True | ||
disallow_incomplete_defs=True | ||
disallow_untyped_decorators=True | ||
cache_fine_grained=True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from typing import Literal | ||
|
||
from typing_extensions import TypeAlias | ||
|
||
ModelNames: TypeAlias = Literal[ | ||
"gpt-3.5-turbo", | ||
"gpt-3.5-turbo-16k", | ||
"gpt-4", | ||
"gpt-4-32k", | ||
"text-embedding-ada-002", | ||
"text-embedding-ada-002-v2", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.