Skip to content

Fix clientwide mypy errors #482

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

Merged
merged 18 commits into from
Sep 6, 2023
Merged
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
52 changes: 35 additions & 17 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ on:
pull_request:

jobs:
lint-and_format:
name: Run linter and formatter
lint-and-format:
name: Run Linter and Formatter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -34,6 +34,24 @@ jobs:
python -m build
python -m twine check dist/*

type-checking:
name: Run Type Checking
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ["3.8", "3.9", "3.10", "3.11"]
folder: ["weaviate"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: 'pip' # caching pip dependencies
- run: pip install -r requirements-devel.txt
- name: Run mypy
run: mypy --python-version ${{matrix.version}} ${{ matrix.folder }}

unit-tests:
name: Run Unit Tests
runs-on: ubuntu-latest
Expand All @@ -43,20 +61,20 @@ jobs:
version: ["3.8", "3.9", "3.10", "3.11"]
folder: ["test", "mock_tests"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.version }}
cache: 'pip' # caching pip dependencies
- run: pip install -r requirements-devel.txt
- name: Run unittests
run: pytest --cov -v --cov-report=term-missing --cov=weaviate --cov-report xml:coverage-${{ matrix.folder }}.xml ${{ matrix.folder }}
- name: Archive code coverage results
if: matrix.version == '3.10' && (github.ref_name != 'main')
uses: actions/upload-artifact@v3
with:
name: coverage-report-${{ matrix.folder }}
path: coverage-${{ matrix.folder }}.xml
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.version }}
cache: 'pip' # caching pip dependencies
- run: pip install -r requirements-devel.txt
- name: Run unittests
run: pytest --cov -v --cov-report=term-missing --cov=weaviate --cov-report xml:coverage-${{ matrix.folder }}.xml ${{ matrix.folder }}
- name: Archive code coverage results
if: matrix.version == '3.10' && (github.ref_name != 'main')
uses: actions/upload-artifact@v3
with:
name: coverage-report-${{ matrix.folder }}
path: coverage-${{ matrix.folder }}.xml

integration-tests:
name: Run Integration Tests
Expand Down Expand Up @@ -185,7 +203,7 @@ jobs:

build-and-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
needs: [integration-tests, unit-tests, lint-and_format, test-package]
needs: [integration-tests, unit-tests, lint-and-format, type-checking, test-package]
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,16 @@ repos:
'flake8-bugbear==22.10.27',
'flake8-comprehensions==3.10.1',
'flake8-builtins==2.0.1'
]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.5.1"
hooks:
- id: mypy
entry: mypy ./weaviate
pass_filenames: false
additional_dependencies: [
'types-requests==2.31.0.2',
'types-urllib3==1.26.25.14',
'typing_extensions==4.7.1',
]
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ warn_return_any = true
warn_unused_ignores = true
exclude = ["weaviate_grpc", "docs", "mock_tests", "test", "integration"]

[[tool.mypy.overrides]]
module = "weaviate_grpc.*"
ignore_errors = true

[[tool.mypy.overrides]]
module = "grpc.*"
ignore_missing_imports = true
Expand Down
7 changes: 7 additions & 0 deletions requirements-devel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ coverage==7.3.0
werkzeug>=2.3.7
pytest-httpserver>=1.0.8

mypy>=1.5.1<2.0.0
mypy-extensions==1.0.0
tomli>=2.0.1<3.0.0
types-requests>=2.31.0.2<3.0.0
types-urllib3>=1.26.25.14<2.0.0
typing_extensions>=4.7.1<5.0.0

pre-commit

flake8
Expand Down
2 changes: 1 addition & 1 deletion test/gql/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_raw(self):
"""

# valid calls
connection_mock = mock_connection_func("post")
connection_mock = mock_connection_func("post", return_json={})
query = Query(connection_mock)

gql_query = "{Get {Group {name Members {... on Person {name}}}}}"
Expand Down
3 changes: 2 additions & 1 deletion weaviate/backup/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def create(
) from conn_err

create_status = _decode_json_response_dict(response, "Backup creation")
assert create_status is not None
if wait_for_completion:
while True:
status: dict = self.get_create_status(
Expand Down Expand Up @@ -246,7 +247,7 @@ def restore(
"Backup restore failed due to connection error."
) from conn_err
restore_status = _decode_json_response_dict(response, "Backup restore")

assert restore_status is not None
if wait_for_completion:
while True:
status: dict = self.get_restore_status(
Expand Down
Loading