Skip to content

ci: add type checking to CI#10

Open
okwn wants to merge 3 commits into
agentmail-to:mainfrom
okwn:ci/add-type-stubs
Open

ci: add type checking to CI#10
okwn wants to merge 3 commits into
agentmail-to:mainfrom
okwn:ci/add-type-stubs

Conversation

@okwn
Copy link
Copy Markdown

@okwn okwn commented May 22, 2026

Summary

Adds type checking to CI.

Testing

mypy passes with --strict flag.


Summary by cubic

Enforce strict type checking in CI to prevent typing regressions and tighten our annotations with no runtime changes. Also adds an MIT LICENSE.

  • Refactors
    • CI now runs mypy . --strict during the compile step.
    • Annotated __dir__() -> list[str] across packages and tightened event callback types.
    • Minor import/typing cleanups to satisfy mypy and keep code consistent.

Written for commit b30d262. Summary will update on new commits. Review in cubic

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

11 issues found across 45 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/agentmail/pods/__init__.py">

<violation number="1" location="src/agentmail/pods/__init__.py:44">
P0: `list[str]` annotation breaks Python 3.8 compatibility at import time</violation>
</file>

<file name="src/agentmail/webhooks/__init__.py">

<violation number="1" location="src/agentmail/webhooks/__init__.py:51">
P1: `list[str]` return type annotation breaks Python 3.8 runtime compatibility</violation>
</file>

<file name="src/agentmail/__init__.py">

<violation number="1" location="src/agentmail/__init__.py:441">
P1: Python 3.8 compatibility regression: `list[str]` is only valid at runtime in Python 3.9+. Use `typing.List[str]` instead.</violation>
</file>

<file name="src/agentmail/messages/__init__.py">

<violation number="1" location="src/agentmail/messages/__init__.py:109">
P1: `list[str]` breaks Python 3.8 compatibility at runtime</violation>
</file>

<file name="src/agentmail/agent/__init__.py">

<violation number="1" location="src/agentmail/agent/__init__.py:34">
P1: `list[str]` return annotation breaks Python 3.8 compatibility</violation>
</file>

<file name="src/agentmail/lists/types/__init__.py">

<violation number="1" location="src/agentmail/lists/types/__init__.py:47">
P1: Runtime compatibility break on Python 3.8: `list[str]` is not subscriptable at runtime in Python versions before 3.9. The project supports `python = "^3.8"` and this file does not use `from __future__ import annotations` to postpone evaluation.</violation>
</file>

<file name="src/agentmail/websockets/types/__init__.py">

<violation number="1" location="src/agentmail/websockets/types/__init__.py:31">
P1: `list[str]` annotation is not compatible with Python 3.8 runtime</violation>
</file>

<file name="src/agentmail/threads/types/__init__.py">

<violation number="1" location="src/agentmail/threads/types/__init__.py:69">
P1: Using `list[str]` breaks Python 3.8 runtime compatibility because PEP 585 built-in generics are not subscriptable at runtime before Python 3.9. The project declares `python = "^3.8"` in pyproject.toml and does not use `from __future__ import annotations` to defer annotation evaluation.</violation>
</file>

<file name="src/agentmail/core/__init__.py">

<violation number="1" location="src/agentmail/core/__init__.py:95">
P1: Runtime compatibility regression: `list[str]` is not valid on Python 3.8</violation>
</file>

<file name="src/agentmail/metrics/__init__.py">

<violation number="1" location="src/agentmail/metrics/__init__.py:49">
P1: Using `list[str]` as a runtime-evaluated type annotation breaks Python 3.8 compatibility. Built-in generics are only subscriptable at runtime starting from Python 3.9+ (PEP 585). The project supports `python = "^3.8"` and the file doesn't have `from __future__ import annotations`, so this annotation will raise a `TypeError` on Python 3.8. Use `typing.List[str]` instead, consistent with the existing `typing.Dict[str, str]` annotation in this file.</violation>
</file>

<file name="src/agentmail/inbox_events/__init__.py">

<violation number="1" location="src/agentmail/inbox_events/__init__.py:34">
P1: `list[str]` annotation causes an import-time crash on Python 3.8, which is a declared supported version.</violation>
</file>

Tip: instead of fixing issues one by one fix them all with cubic

Re-trigger cubic



def __dir__():
def __dir__() -> list[str]:
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0: list[str] annotation breaks Python 3.8 compatibility at import time

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/agentmail/pods/__init__.py, line 44:

<comment>`list[str]` annotation breaks Python 3.8 compatibility at import time</comment>

<file context>
@@ -41,7 +41,7 @@ def __getattr__(attr_name: str) -> typing.Any:
 
 
-def __dir__():
+def __dir__() -> list[str]:
     lazy_attrs = list(_dynamic_imports.keys())
     return sorted(lazy_attrs)
</file context>
Suggested change
def __dir__() -> list[str]:
def __dir__() -> typing.List[str]:
Fix with Cubic



def __dir__():
def __dir__() -> list[str]:
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: list[str] return type annotation breaks Python 3.8 runtime compatibility

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/agentmail/webhooks/__init__.py, line 51:

<comment>`list[str]` return type annotation breaks Python 3.8 runtime compatibility</comment>

<file context>
@@ -48,7 +48,7 @@ def __getattr__(attr_name: str) -> typing.Any:
 
 
-def __dir__():
+def __dir__() -> list[str]:
     lazy_attrs = list(_dynamic_imports.keys())
     return sorted(lazy_attrs)
</file context>
Suggested change
def __dir__() -> list[str]:
def __dir__() -> typing.List[str]:
Fix with Cubic

Comment thread src/agentmail/__init__.py


def __dir__():
def __dir__() -> list[str]:
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Python 3.8 compatibility regression: list[str] is only valid at runtime in Python 3.9+. Use typing.List[str] instead.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/agentmail/__init__.py, line 441:

<comment>Python 3.8 compatibility regression: `list[str]` is only valid at runtime in Python 3.9+. Use `typing.List[str]` instead.</comment>

<file context>
@@ -438,7 +438,7 @@ def __getattr__(attr_name: str) -> typing.Any:
 
 
-def __dir__():
+def __dir__() -> list[str]:
     lazy_attrs = list(_dynamic_imports.keys())
     return sorted(lazy_attrs)
</file context>
Suggested change
def __dir__() -> list[str]:
def __dir__() -> typing.List[str]:
Fix with Cubic



def __dir__():
def __dir__() -> list[str]:
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: list[str] breaks Python 3.8 compatibility at runtime

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/agentmail/messages/__init__.py, line 109:

<comment>`list[str]` breaks Python 3.8 compatibility at runtime</comment>

<file context>
@@ -106,7 +106,7 @@ def __getattr__(attr_name: str) -> typing.Any:
 
 
-def __dir__():
+def __dir__() -> list[str]:
     lazy_attrs = list(_dynamic_imports.keys())
     return sorted(lazy_attrs)
</file context>
Suggested change
def __dir__() -> list[str]:
def __dir__() -> typing.List[str]:
Fix with Cubic



def __dir__():
def __dir__() -> list[str]:
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: list[str] return annotation breaks Python 3.8 compatibility

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/agentmail/agent/__init__.py, line 34:

<comment>`list[str]` return annotation breaks Python 3.8 compatibility</comment>

<file context>
@@ -31,7 +31,7 @@ def __getattr__(attr_name: str) -> typing.Any:
 
 
-def __dir__():
+def __dir__() -> list[str]:
     lazy_attrs = list(_dynamic_imports.keys())
     return sorted(lazy_attrs)
</file context>
Suggested change
def __dir__() -> list[str]:
def __dir__() -> typing.List[str]:
Fix with Cubic



def __dir__():
def __dir__() -> list[str]:
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: list[str] annotation is not compatible with Python 3.8 runtime

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/agentmail/websockets/types/__init__.py, line 31:

<comment>`list[str]` annotation is not compatible with Python 3.8 runtime</comment>

<file context>
@@ -28,7 +28,7 @@ def __getattr__(attr_name: str) -> typing.Any:
 
 
-def __dir__():
+def __dir__() -> list[str]:
     lazy_attrs = list(_dynamic_imports.keys())
     return sorted(lazy_attrs)
</file context>
Suggested change
def __dir__() -> list[str]:
def __dir__() -> typing.List[str]:
Fix with Cubic



def __dir__():
def __dir__() -> list[str]:
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Using list[str] breaks Python 3.8 runtime compatibility because PEP 585 built-in generics are not subscriptable at runtime before Python 3.9. The project declares python = "^3.8" in pyproject.toml and does not use from __future__ import annotations to defer annotation evaluation.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/agentmail/threads/types/__init__.py, line 69:

<comment>Using `list[str]` breaks Python 3.8 runtime compatibility because PEP 585 built-in generics are not subscriptable at runtime before Python 3.9. The project declares `python = "^3.8"` in pyproject.toml and does not use `from __future__ import annotations` to defer annotation evaluation.</comment>

<file context>
@@ -66,7 +66,7 @@ def __getattr__(attr_name: str) -> typing.Any:
 
 
-def __dir__():
+def __dir__() -> list[str]:
     lazy_attrs = list(_dynamic_imports.keys())
     return sorted(lazy_attrs)
</file context>
Suggested change
def __dir__() -> list[str]:
def __dir__() -> typing.List[str]:
Fix with Cubic



def __dir__():
def __dir__() -> list[str]:
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Runtime compatibility regression: list[str] is not valid on Python 3.8

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/agentmail/core/__init__.py, line 95:

<comment>Runtime compatibility regression: `list[str]` is not valid on Python 3.8</comment>

<file context>
@@ -92,7 +92,7 @@ def __getattr__(attr_name: str) -> typing.Any:
 
 
-def __dir__():
+def __dir__() -> list[str]:
     lazy_attrs = list(_dynamic_imports.keys())
     return sorted(lazy_attrs)
</file context>
Suggested change
def __dir__() -> list[str]:
def __dir__() -> typing.List[str]:
Fix with Cubic



def __dir__():
def __dir__() -> list[str]:
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Using list[str] as a runtime-evaluated type annotation breaks Python 3.8 compatibility. Built-in generics are only subscriptable at runtime starting from Python 3.9+ (PEP 585). The project supports python = "^3.8" and the file doesn't have from __future__ import annotations, so this annotation will raise a TypeError on Python 3.8. Use typing.List[str] instead, consistent with the existing typing.Dict[str, str] annotation in this file.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/agentmail/metrics/__init__.py, line 49:

<comment>Using `list[str]` as a runtime-evaluated type annotation breaks Python 3.8 compatibility. Built-in generics are only subscriptable at runtime starting from Python 3.9+ (PEP 585). The project supports `python = "^3.8"` and the file doesn't have `from __future__ import annotations`, so this annotation will raise a `TypeError` on Python 3.8. Use `typing.List[str]` instead, consistent with the existing `typing.Dict[str, str]` annotation in this file.</comment>

<file context>
@@ -46,7 +46,7 @@ def __getattr__(attr_name: str) -> typing.Any:
 
 
-def __dir__():
+def __dir__() -> list[str]:
     lazy_attrs = list(_dynamic_imports.keys())
     return sorted(lazy_attrs)
</file context>
Suggested change
def __dir__() -> list[str]:
def __dir__() -> typing.List[str]:
Fix with Cubic



def __dir__():
def __dir__() -> list[str]:
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: list[str] annotation causes an import-time crash on Python 3.8, which is a declared supported version.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/agentmail/inbox_events/__init__.py, line 34:

<comment>`list[str]` annotation causes an import-time crash on Python 3.8, which is a declared supported version.</comment>

<file context>
@@ -31,7 +31,7 @@ def __getattr__(attr_name: str) -> typing.Any:
 
 
-def __dir__():
+def __dir__() -> list[str]:
     lazy_attrs = list(_dynamic_imports.keys())
     return sorted(lazy_attrs)
</file context>
Suggested change
def __dir__() -> list[str]:
def __dir__() -> typing.List[str]:
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant