Skip to content

[ACEM] mypy x llteacher#16

Closed
automaticcodeevolutionmanagement[bot] wants to merge 1 commit intomainfrom
acem/mypy-1.19.1-20260316-023446
Closed

[ACEM] mypy x llteacher#16
automaticcodeevolutionmanagement[bot] wants to merge 1 commit intomainfrom
acem/mypy-1.19.1-20260316-023446

Conversation

@automaticcodeevolutionmanagement
Copy link
Copy Markdown

mypy x llteacher

What This PR Does

Mypy identified incompatible type assignments where Django's formset_factory returned a generic BaseFormSet instead of the expected SectionFormSet, along with unhandled optional types and UUID-to-string mismatches. Left unresolved, these type ambiguities compromise strict type safety and could cause unpredictable runtime errors when accessing specialized attributes or processing form data. To fix these errors, we removed incorrect type hints on formset factories, introduced explicit isinstance and null assertions to validate types at runtime, and properly casted the course ID to a string.

Details

  • Policy: Mypy 1.19.1
  • Initiative ID: 18
  • Fixes Applied: 7 violations
  • Files Modified: 2

Original Violations

src/homeworks/views.py
src/homeworks/views.py:373: error: Incompatible types in assignment (expression has type "type[BaseFormSet[Any]]", variable has type "type[SectionFormSet]")  [assignment]
src/homeworks/views.py:398: error: Incompatible types in assignment (expression has type "type[BaseFormSet[Any]]", variable has type "type[SectionFormSet]")  [assignment]
src/courses/views.py
src/courses/views.py:467: error: Incompatible types in assignment (expression has type "UUID", target has type "str | bytes")  [assignment]
---

This pull request was automatically created by ACEM.

Policy: Mypy 1.19.1
Fixed: 7 violations

Original Violations:

src/homeworks/views.py:
src/homeworks/views.py:373: error: Incompatible types in assignment (expression has type "type[BaseFormSet[Any]]", variable has type "type[SectionFormSet]")  [assignment]
src/homeworks/views.py:398: error: Incompatible types in assignment (expression has type "type[BaseFormSet[Any]]", variable has type "type[SectionFormSet]")  [assignment]

src/courses/views.py:
src/courses/views.py:467: error: Incompatible types in assignment (expression has type "UUID", target has type "str | bytes")  [assignment]

Automated by ACEM - Initiative #18
@siscia siscia closed this Mar 16, 2026
automaticcodeevolutionmanagement bot pushed a commit that referenced this pull request Mar 17, 2026
Policy: Mypy 1.19.1
Fixed: 6 violations

Original Violations:

src/homeworks/views.py:
src/homeworks/views.py:373: error: Incompatible types in assignment (expression has type "type[BaseFormSet[Any]]", variable has type "type[SectionFormSet]")  [assignment]
src/homeworks/views.py:398: error: Incompatible types in assignment (expression has type "type[BaseFormSet[Any]]", variable has type "type[SectionFormSet]")  [assignment]

src/courses/views.py:
src/courses/views.py:467: error: Incompatible types in assignment (expression has type "UUID", target has type "str | bytes")  [assignment]

Automated by ACEM - Initiative #16
automaticcodeevolutionmanagement bot pushed a commit that referenced this pull request Mar 17, 2026
Policy: Mypy 1.19.1
Fixed: 5 violations

Original Violations:

src/llm/services.py:
src/llm/services.py:389: error: Item "ChatCompletionMessageCustomToolCall" of "ChatCompletionMessageFunctionToolCall | ChatCompletionMessageCustomToolCall" has no attribute "function"  [union-attr]
src/llm/services.py:393: error: Item "ChatCompletionMessageCustomToolCall" of "ChatCompletionMessageFunctionToolCall | ChatCompletionMessageCustomToolCall" has no attribute "function"  [union-attr]
src/llm/services.py:399: error: Item "ChatCompletionMessageCustomToolCall" of "ChatCompletionMessageFunctionToolCall | ChatCompletionMessageCustomToolCall" has no attribute "function"  [union-attr]
src/llm/services.py:881: error: Item "tuple[str | Any, ...]" of "tuple[str, Any] | ChatCompletionChunk" has no attribute "choices"  [union-attr]
src/llm/services.py:882: error: Item "tuple[str | Any, ...]" of "tuple[str, Any] | ChatCompletionChunk" has no attribute "choices"  [union-attr]

Automated by ACEM - Initiative #16
automaticcodeevolutionmanagement bot pushed a commit that referenced this pull request Mar 18, 2026
Policy: Mypy 1.19.1
Fixed: 6 violations

Original Violations:

src/homeworks/views.py:
src/homeworks/views.py:373: error: Incompatible types in assignment (expression has type "type[BaseFormSet[Any]]", variable has type "type[SectionFormSet]")  [assignment]
src/homeworks/views.py:398: error: Incompatible types in assignment (expression has type "type[BaseFormSet[Any]]", variable has type "type[SectionFormSet]")  [assignment]

src/courses/views.py:
src/courses/views.py:467: error: Incompatible types in assignment (expression has type "UUID", target has type "str | bytes")  [assignment]

Automated by ACEM - Initiative #16
automaticcodeevolutionmanagement bot pushed a commit that referenced this pull request Mar 18, 2026
Policy: Mypy 1.19.1
Fixed: 5 violations

Original Violations:

src/llm/services.py:
src/llm/services.py:389: error: Item "ChatCompletionMessageCustomToolCall" of "ChatCompletionMessageFunctionToolCall | ChatCompletionMessageCustomToolCall" has no attribute "function"  [union-attr]
src/llm/services.py:393: error: Item "ChatCompletionMessageCustomToolCall" of "ChatCompletionMessageFunctionToolCall | ChatCompletionMessageCustomToolCall" has no attribute "function"  [union-attr]
src/llm/services.py:399: error: Item "ChatCompletionMessageCustomToolCall" of "ChatCompletionMessageFunctionToolCall | ChatCompletionMessageCustomToolCall" has no attribute "function"  [union-attr]
src/llm/services.py:881: error: Item "tuple[str | Any, ...]" of "tuple[str, Any] | ChatCompletionChunk" has no attribute "choices"  [union-attr]
src/llm/services.py:882: error: Item "tuple[str | Any, ...]" of "tuple[str, Any] | ChatCompletionChunk" has no attribute "choices"  [union-attr]

Automated by ACEM - Initiative #16
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