Skip to content

Changed the annotated type of data parameter in the encode and decode method#204

Open
subhajitsaha01 wants to merge 2 commits intokjd:masterfrom
subhajitsaha01:type_mismatch_branch
Open

Changed the annotated type of data parameter in the encode and decode method#204
subhajitsaha01 wants to merge 2 commits intokjd:masterfrom
subhajitsaha01:type_mismatch_branch

Conversation

@subhajitsaha01
Copy link
Copy Markdown

In the test_idna.py file, for the data parameter of the decode method of the Codec class, a string value has been passed and accepted but the annotated type is only bytes. I have changed the static annotated type to str|bytes.

Links for the test file line, where the string values are passed to the data parameter of the decode method of the Codec class :

self.assertEqual(

self.assertEqual(

self.assertEqual(decode("abc.abc"), "abc.abc")

In the test_idna.py file, for the data parameter of the encode method of the Codec class, a bytes value has been passed and accepted but the annotated type is only str. I have changed the static annotated type to str|bytes.

Link for the test file line, where the bytes values are passed to the data parameter of the encode method of the Codec class :

self.assertRaises(idna.IDNAError, encode, b"\x0a\x33\x81")

@subhajitsaha01
Copy link
Copy Markdown
Author

Hi @kjd is there anything I could do to get this PR resolved

@kjd
Copy link
Copy Markdown
Owner

kjd commented Oct 28, 2025

Hi @kjd is there anything I could do to get this PR resolved

Well, passing the build tests would be a good start. The PR didn't look like it was written by a human so did not spend further time on it.

@subhajitsaha01
Copy link
Copy Markdown
Author

subhajitsaha01 commented Oct 28, 2025

Hi @kjd is there anything I could do to get this PR resolved

Well, passing the build tests would be a good start. The PR didn't look like it was written by a human so did not spend further time on it.

The Build tests are failing because the union of types are allowed after python version 3.10 and thus are failing for python versions 3.8 and 3.9.

I need to change the format of type data: str | bytes to data : Union[str, bytes] to make it universally compatible.

Do tell me if I should proceed with the same?

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.

2 participants