-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added type hints to additional tests #8093
Conversation
@@ -209,13 +209,13 @@ def test_exceptions() -> None: | |||
ImageCms.buildTransform("foo", "bar", "RGB", "RGB") | |||
|
|||
with pytest.raises(ImageCms.PyCMSError, match="Invalid type for Profile"): | |||
ImageCms.getProfileName(None) | |||
ImageCms.getProfileName(None) # type: ignore[arg-type] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this warning look like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests/test_imagecms.py:212: error: Argument 1 to "getProfileName" has incompatible type "None"; expected
"Union[str, SupportsRead[bytes], CmsProfile, ImageCmsProfile]" [arg-type]
ImageCms.getProfileName(None)
^~~~
The test's intention is to go through
Line 807 in c757439
def getProfileName(profile: _CmsProfileCompatible) -> str: |
where
Lines 369 to 371 in c757439
_CmsProfileCompatible = Union[ | |
str, SupportsRead[bytes], core.CmsProfile, ImageCmsProfile | |
] |
and then
Lines 239 to 240 in c757439
class ImageCmsProfile: | |
def __init__(self, profile: str | SupportsRead[bytes] | core.CmsProfile) -> None: |
to reach
Line 263 in c757439
msg = "Invalid type for Profile" # type: ignore[unreachable] |
The type is deliberately incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
|
||
if not is_pypy(): | ||
# core profile should not be directly instantiable | ||
with pytest.raises(TypeError): | ||
ImageCms.core.CmsProfile() | ||
with pytest.raises(TypeError): | ||
ImageCms.core.CmsProfile(0) | ||
ImageCms.core.CmsProfile(0) # type: ignore[call-arg] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests/test_imagecms.py:532: error: Too many arguments for "CmsProfile" [call-arg]
ImageCms.core.CmsProfile(0)
^~~~~~~~~~~~~~~~~~~~~~~~~~~
No description provided.