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

CI for testing mypy across different python versions #1699

Merged
merged 1 commit into from
Jan 25, 2024
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
11 changes: 5 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,20 @@ jobs:
- name: Install Python ${{ matrix.ver }} dependencies
run: |
python3 -m pip install --upgrade pip setuptools
python3 -m pip install tox numpy mypy pytest-mypy-plugins
python3 -m pip install build tox numpy mypy pytest-mypy-plugins

- name: Execute Python tests
run: tox

- name: Install metaflow
run: pip install .

- name: Generate Stubs
run: cd ./stubs && rm -rf metaflow-stubs/ && python -c "from metaflow.cmd.develop.stub_generator import StubGenerator; StubGenerator('./metaflow-stubs').write_out()" && cd -

- name: Install metaflow-stubs
run: cd ./stubs && pip install . && cd -
if: contains(fromJson('["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]'), matrix.ver)
run: metaflow develop stubs install --force

- name: Run mypy tests
- name: Run mypy tests for Python 3.7 to 3.12
if: contains(fromJson('["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]'), matrix.ver)
run: cd ./stubs && pytest --mypy-ini-file test/setup.cfg --mypy-only-local-stub && cd -

R:
Expand Down
198 changes: 198 additions & 0 deletions stubs/test/test_stubs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
- case: project_decorator_validity
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, project

Expand Down Expand Up @@ -36,6 +45,15 @@

- case: pypi_base_decorator_validity
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, pypi_base

Expand Down Expand Up @@ -76,6 +94,15 @@

- case: conda_base_decorator_validity
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, conda_base

Expand Down Expand Up @@ -116,6 +143,15 @@

- case: schedule_decorator_validity
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, schedule

Expand Down Expand Up @@ -156,6 +192,15 @@

- case: trigger_decorator_validity
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, trigger

Expand Down Expand Up @@ -196,6 +241,15 @@

- case: trigger_on_finish_decorator_validity
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, trigger_on_finish

Expand Down Expand Up @@ -236,6 +290,15 @@

- case: step_decorator_validity
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, step

Expand Down Expand Up @@ -292,6 +355,15 @@

- case: decorator_order
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, step, retry, catch

Expand Down Expand Up @@ -322,6 +394,15 @@

- case: batch_decorator_validity
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, step, batch

Expand Down Expand Up @@ -374,6 +455,15 @@

- case: kubernetes_decorator_validity
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, step, kubernetes

Expand Down Expand Up @@ -426,6 +516,15 @@

- case: environment_decorator_validity
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, step, environment

Expand Down Expand Up @@ -478,6 +577,15 @@

- case: card_decorator_validity
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, step, card

Expand Down Expand Up @@ -530,6 +638,15 @@

- case: catch_decorator_validity
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, step, catch

Expand Down Expand Up @@ -582,6 +699,15 @@

- case: pypi_decorator_validity
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, step, pypi

Expand Down Expand Up @@ -634,6 +760,15 @@

- case: conda_decorator_validity
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, step, conda

Expand Down Expand Up @@ -686,6 +821,15 @@

- case: resources_decorator_validity
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, step, resources

Expand Down Expand Up @@ -738,6 +882,15 @@

- case: retry_decorator_validity
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, step, retry

Expand Down Expand Up @@ -790,6 +943,15 @@

- case: secrets_decorator_validity
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, step, secrets

Expand Down Expand Up @@ -842,6 +1004,15 @@

- case: timeout_decorator_validity
regex: yes
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, step, timeout

Expand Down Expand Up @@ -893,6 +1064,15 @@
main:22: error: .*incompatible type.*\[arg-type\]

- case: client_types
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import Flow, Run, Step, Task, DataArtifact

Expand All @@ -916,6 +1096,15 @@
main:11: error: Invalid index type "int" for "Step"; expected type "str" [index]

- case: current_object
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import current

Expand All @@ -929,6 +1118,15 @@
main:7: error: Property "flow_name" defined in "Current" is read-only [misc]

- case: sample_flow
parametrized:
- python_version: "3.7"
- python_version: "3.8"
- python_version: "3.9"
- python_version: "3.10"
- python_version: "3.11"
- python_version: "3.12"
mypy_config:
python_version = {{ python_version }}
main: |
from metaflow import FlowSpec, step, batch, project, schedule

Expand Down