mirror of
https://github.com/microsoft/autogen.git
synced 2025-12-27 06:59:03 +00:00
Add mypy to pre-commit (#2068)
* Add mypy check in pre-commit * Add mypy check in pre-commit * bug fix * CI fix * add python version matrix for checking types in CI * added 3.12 to CI --------- Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
This commit is contained in:
parent
6cab643906
commit
99e48dc024
2
.github/workflows/pre-commit.yml
vendored
2
.github/workflows/pre-commit.yml
vendored
@ -18,6 +18,8 @@ jobs:
|
||||
|
||||
pre-commit-check:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
SKIP: "mypy"
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-python@v4
|
||||
|
||||
21
.github/workflows/type-check.yml
vendored
21
.github/workflows/type-check.yml
vendored
@ -13,15 +13,18 @@ permissions: {}
|
||||
|
||||
jobs:
|
||||
type-check:
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-python@v4
|
||||
- run: pip install ".[jupyter-executor]" mypy
|
||||
# As more modules are type check clean, add them here
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.version }}
|
||||
# All additional modules should be defined in setup.py
|
||||
- run: pip install ".[types]"
|
||||
# Any additional configuration should be defined in pyproject.toml
|
||||
- run: |
|
||||
mypy \
|
||||
autogen/logger \
|
||||
autogen/exception_utils.py \
|
||||
autogen/coding \
|
||||
autogen/oai/openai_utils.py
|
||||
mypy
|
||||
|
||||
@ -44,6 +44,22 @@ repos:
|
||||
website/docs/tutorial/code-executors.ipynb |
|
||||
notebook/.*
|
||||
)$
|
||||
# See https://jaredkhan.com/blog/mypy-pre-commit
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: mypy
|
||||
name: mypy
|
||||
entry: "./scripts/pre-commit-mypy-run.sh"
|
||||
language: python
|
||||
# use your preferred Python version
|
||||
# language_version: python3.8
|
||||
additional_dependencies: [".[types]"]
|
||||
types: [python]
|
||||
# use require_serial so that script
|
||||
# is only called once per commit
|
||||
require_serial: true
|
||||
# Print the number of files as a sanity-check
|
||||
verbose: true
|
||||
- repo: https://github.com/nbQA-dev/nbQA
|
||||
rev: 1.8.4
|
||||
hooks:
|
||||
|
||||
@ -62,6 +62,13 @@ max-complexity = 10
|
||||
|
||||
[tool.mypy]
|
||||
|
||||
files = [
|
||||
"autogen/logger",
|
||||
"autogen/exception_utils.py",
|
||||
"autogen/coding",
|
||||
"autogen/oai/openai_utils.py",
|
||||
]
|
||||
|
||||
strict = true
|
||||
python_version = "3.8"
|
||||
ignore_missing_imports = true
|
||||
|
||||
13
scripts/pre-commit-mypy-run.sh
Executable file
13
scripts/pre-commit-mypy-run.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# taken from: https://jaredkhan.com/blog/mypy-pre-commit
|
||||
|
||||
# A script for running mypy,
|
||||
# with all its dependencies installed.
|
||||
|
||||
set -o errexit
|
||||
|
||||
# Change directory to the project root directory.
|
||||
cd "$(dirname "$0")"/..
|
||||
|
||||
mypy
|
||||
17
setup.py
17
setup.py
@ -27,6 +27,14 @@ install_requires = [
|
||||
"docker",
|
||||
]
|
||||
|
||||
jupyter_executor = [
|
||||
"jupyter-kernel-gateway",
|
||||
"websocket-client",
|
||||
"requests",
|
||||
"jupyter-client>=8.6.0",
|
||||
"ipykernel>=6.29.0",
|
||||
]
|
||||
|
||||
setuptools.setup(
|
||||
name="pyautogen",
|
||||
version=__version__,
|
||||
@ -57,13 +65,8 @@ setuptools.setup(
|
||||
"graph": ["networkx", "matplotlib"],
|
||||
"websurfer": ["beautifulsoup4", "markdownify", "pdfminer.six", "pathvalidate"],
|
||||
"redis": ["redis"],
|
||||
"jupyter-executor": [
|
||||
"jupyter-kernel-gateway",
|
||||
"websocket-client",
|
||||
"requests",
|
||||
"jupyter-client>=8.6.0",
|
||||
"ipykernel>=6.29.0",
|
||||
],
|
||||
"jupyter-executor": jupyter_executor,
|
||||
"types": ["mypy==1.9.0"] + jupyter_executor,
|
||||
},
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user