Repository: meltano/meltano

Issue:
bug: Static type checking (mypy) CI job failing
### Meltano Version

N/A

### Python Version

NA

### Bug scope

Other

### Operating System

N/A

### Description

Example from `main`: https://github.com/meltano/meltano/actions/runs/3129670243/jobs/5079038959

```
nox > Running session mypy
nox > Creating virtual environment (virtualenv) using python3.9 in .nox/mypy
nox > poetry build --format=wheel --no-ansi
nox > pip uninstall --yes file:///home/runner/work/meltano/meltano/dist/meltano-2.7.0-py3-none-any.whl
nox > poetry export --format=requirements.txt --dev --extras=infra --extras=mssql --extras=repl --without-hashes
The `--dev` option is deprecated, use the `--with dev` notation instead.
nox > python -m pip install --constraint=.nox/mypy/tmp/requirements.txt file:///home/runner/work/meltano/meltano/dist/meltano-2.7.0-py3-none-any.whl
nox > python -m pip install --constraint=.nox/mypy/tmp/requirements.txt mypy sqlalchemy2-stubs types-requests
nox > mypy src/meltano
src/meltano/migrations/versions/f4c225a9492f_create_dedicated_job_state_table.py:39: error: Variable "f4c225a9492f_create_dedicated_job_state_table.SystemModel" is not valid as a type
src/meltano/migrations/versions/f4c225a9492f_create_dedicated_job_state_table.py:39: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
src/meltano/migrations/versions/f4c225a9492f_create_dedicated_job_state_table.py:39: error: Invalid base class "SystemModel"
src/meltano/migrations/versions/f4c225a9492f_create_dedicated_job_state_table.py:69: error: Need type annotation for "completed_state" (hint: "completed_state: Dict[<type>, <type>] = ...")
src/meltano/migrations/versions/f4c225a9492f_create_dedicated_job_state_table.py:70: error: Need type annotation for "partial_state" (hint: "partial_state: Dict[<type>, <type>] = ...")
src/meltano/migrations/versions/f4c225a9492f_create_dedicated_job_state_table.py:274: error: "object" has no attribute "query"
src/meltano/migrations/versions/f4c225a9492f_create_dedicated_job_state_table.py:307: error: Variable "f4c225a9492f_create_dedicated_job_state_table.SystemModel" is not valid as a type
src/meltano/migrations/versions/f4c225a9492f_create_dedicated_job_state_table.py:307: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
src/meltano/migrations/versions/f4c225a9492f_create_dedicated_job_state_table.py:307: error: Invalid base class "SystemModel"
src/meltano/migrations/versions/f4c225a9492f_create_dedicated_job_state_table.py:340: error: Need type annotation for "completed_state" (hint: "completed_state: Dict[<type>, <type>] = ...")
src/meltano/migrations/versions/f4c225a9492f_create_dedicated_job_state_table.py:341: error: Need type annotation for "partial_state" (hint: "partial_state: Dict[<type>, <type>] = ...")
src/meltano/core/job_state.py:19: error: Variable "meltano.core.models.SystemModel" is not valid as a type
src/meltano/core/job_state.py:19: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
src/meltano/core/job_state.py:19: error: Invalid base class "SystemModel"
Found 11 errors in 2 files (checked 203 source files)
nox > Command mypy src/meltano failed with exit code 1
nox > Session mypy failed.
Error: Process completed with exit code 1.
```

### Code

_No response_


Discussion:

Resolving patch:
diff --git a/noxfile.py b/noxfile.py
--- a/noxfile.py
+++ b/noxfile.py
@@ -88,7 +88,7 @@ def mypy(session: Session) -> None:
     Args:
         session: Nox session.
     """
-    args = session.posargs or ["src/meltano"]
+    args = session.posargs or ["src/meltano", "--exclude", "src/meltano/migrations/"]
 
     session.install(".")
     session.install(
diff --git a/src/meltano/core/job_state.py b/src/meltano/core/job_state.py
--- a/src/meltano/core/job_state.py
+++ b/src/meltano/core/job_state.py
@@ -6,7 +6,7 @@
 
 from sqlalchemy import Column, types
 from sqlalchemy.ext.mutable import MutableDict
-from sqlalchemy.orm import Session
+from sqlalchemy.orm import Mapped, Session
 
 from meltano.core.job import JobFinder, Payload
 from meltano.core.models import SystemModel
@@ -30,8 +30,8 @@ class JobState(SystemModel):
 
     updated_at = Column(types.DATETIME, onupdate=datetime.now)
 
-    partial_state = Column(MutableDict.as_mutable(JSONEncodedDict))
-    completed_state = Column(MutableDict.as_mutable(JSONEncodedDict))
+    partial_state: Mapped[Any] = Column(MutableDict.as_mutable(JSONEncodedDict))
+    completed_state: Mapped[Any] = Column(MutableDict.as_mutable(JSONEncodedDict))
 
     @classmethod
     def from_job_history(cls, session: Session, job_name: str):


Test patch: