Fix mypy/pyright errors in tests#654
Conversation
There was a problem hiding this comment.
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 |
| assert a == from_tuple(A, to_tuple(a)) | ||
|
|
||
| a = A(Foo[str]("foo")) | ||
| a = A(Bar[str]("foo")) |
There was a problem hiding this comment.
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.
| # 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] |
There was a problem hiding this comment.
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.
| 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] |
| 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] |
There was a problem hiding this comment.
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.
| 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] |
55429ec to
ad031bb
Compare
Closes #400