Skip to content

Fix mypy/pyright errors in tests#654

Merged
yukinarit merged 1 commit into
mainfrom
fix-mypy-pyright-errors-in-tests
Aug 10, 2025
Merged

Fix mypy/pyright errors in tests#654
yukinarit merged 1 commit into
mainfrom
fix-mypy-pyright-errors-in-tests

Conversation

@yukinarit

Copy link
Copy Markdown
Owner

Closes #400

@yukinarit yukinarit requested a review from Copilot August 10, 2025 12:46
@yukinarit yukinarit added the test Change in tests label Aug 10, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes mypy and pyright type checker errors in test files to resolve issue #400. The changes focus on adding appropriate type ignore comments, fixing type annotations, and resolving naming conflicts.

  • Adds type ignore comments for version-specific redefinitions and type checker limitations
  • Fixes variable naming conflicts by using unique class and variable names
  • Updates function signatures with proper type annotations

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/test_union.py Fixes class redeclaration warnings, variable naming conflicts, and type annotations
tests/test_type_check.py Adds pyright ignore comment for invalid type form
tests/test_sqlalchemy.py Adds type ignore comment for entire file and fixes function signatures
tests/test_se.py Adds pyright ignore comments for unhashable type issues
tests/test_numpy.py Adds type ignore comment for entire file and fixes type annotations
tests/test_literal.py Fixes function signatures with proper type annotations
tests/test_legacy_custom.py Fixes function signatures and resolves class naming conflicts
tests/test_core.py Resolves class naming conflicts by using unique names
tests/test_compat.py Fixes comparison operators and removes extra whitespace
tests/test_basics.py Adds pyright configuration and fixes numerous type annotations
tests/common.py Fixes type annotation for generic type parameters
pyproject.toml Removes test files from exclude lists and adds pyright configuration

Comment thread tests/test_union.py
assert a == from_tuple(A, to_tuple(a))

a = A(Foo[str]("foo"))
a = A(Bar[str]("foo"))

Copilot AI Aug 10, 2025

Copy link

Choose a reason for hiding this comment

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

This line creates an instance of Bar[str] but the test context suggests this should be Foo[str] based on the pattern of the surrounding code and the fact that Bar doesn't appear to be a generic type in this context.

Copilot uses AI. Check for mistakes.
Comment thread tests/test_union.py
# Untagged can't differenciate the dataclass with similar fields
with pytest.raises(AssertionError):
assert to_dict(from_dict(Foo, d)) == f
assert to_dict(from_dict(FooUntagged, d)) == f_untagged # type: ignore[comparison-overlap]

Copilot AI Aug 10, 2025

Copy link

Choose a reason for hiding this comment

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

The variable d is not defined in this scope. This appears to be a copy-paste error where d should likely be the serialized form of f_untagged.

Suggested change
assert to_dict(from_dict(FooUntagged, d)) == f_untagged # type: ignore[comparison-overlap]
assert to_dict(from_dict(FooUntagged, to_dict(f_untagged))) == f_untagged # type: ignore[comparison-overlap]

Copilot uses AI. Check for mistakes.
Comment thread tests/test_union.py
f_listdict = FooListDict({10: "bar"})
with pytest.raises(SerdeError):
assert to_dict(from_dict(Foo, d)) == f
assert to_dict(from_dict(FooListDict, d)) == f_listdict # type: ignore[comparison-overlap]

Copilot AI Aug 10, 2025

Copy link

Choose a reason for hiding this comment

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

The variable d is not defined in this scope for this test case. This appears to be a copy-paste error where d should likely be the serialized form of f_listdict.

Suggested change
assert to_dict(from_dict(FooListDict, d)) == f_listdict # type: ignore[comparison-overlap]
assert to_dict(from_dict(FooListDict, to_dict(f_listdict))) == f_listdict # type: ignore[comparison-overlap]

Copilot uses AI. Check for mistakes.
@yukinarit yukinarit force-pushed the fix-mypy-pyright-errors-in-tests branch from 55429ec to ad031bb Compare August 10, 2025 16:08
@yukinarit yukinarit merged commit f531785 into main Aug 10, 2025
7 checks passed
@yukinarit yukinarit deleted the fix-mypy-pyright-errors-in-tests branch August 10, 2025 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Change in tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix mypy/pyright errors in tests

2 participants