Skip to content
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

type annotate the tests (using monkeytype and manual fixes) #301

Merged
merged 12 commits into from
Jun 5, 2021

Conversation

graingert
Copy link
Collaborator

@graingert graingert commented May 26, 2021

  • Fixed the type annotation of open_signal_receiver() as a synchronous context manager
  • Fixed the type annotations of AsyncFile.__aiter__, readline, write to also accept/return str
    and also fixed AsyncFile.writelines to take an Iterable[str|bytes] rather than bytes.
  • Fixed DeprecatedAwaitable(|List|Float).__await__ to match the typing.Awaitable protocol

Copy link
Collaborator Author

@graingert graingert left a comment

Choose a reason for hiding this comment

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

this will need a history with the user facing type changes

@agronholm
Copy link
Owner

Do we really need that many annotation changes in the library itself? Did the typed tests reveal that many issues?

@graingert
Copy link
Collaborator Author

graingert commented May 27, 2021

Do we really need that many annotation changes in the library itself? Did the typed tests reveal that many issues?

Technically the backends didn't need changes to _SignalReciever because the type information gets destroyed by get_asynclib.

Also fileio only needed __aiter__ changing but I fixed the other bytes only methods

But other than that everything came from mypy errors

@graingert graingert changed the title type annotate some tests (using monkeytype and manual fixes) type annotate the tests (using monkeytype and manual fixes) May 27, 2021
@@ -483,9 +527,9 @@ async def test_extra_attributes(self, server_sock, socket_path):
pytest.raises(TypedAttributeLookupError, stream.extra, SocketAttribute.local_port)
pytest.raises(TypedAttributeLookupError, stream.extra, SocketAttribute.remote_port)

@pytest.mark.parametrize('as_path', [False, True], ids=['str', 'path'])
async def test_send_receive(self, server_sock, socket_path, as_path):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this as_path was unused

Copy link
Owner

Choose a reason for hiding this comment

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

Then perhaps we should add this?

        if not as_path:
            socket_path = str(socket_path)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I fixed it at runtime by making a Union[str, Path] fixture

Copy link
Collaborator Author

@graingert graingert Jun 5, 2021

Choose a reason for hiding this comment

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

Because you can't reassign a Path to a str, in refactoring it to a fixture I noticed the bug in the test

Copy link
Owner

@agronholm agronholm left a comment

Choose a reason for hiding this comment

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

Comments, questions and a few change requests.

tests/conftest.py Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
tests/streams/test_file.py Show resolved Hide resolved
tests/streams/test_file.py Outdated Show resolved Hide resolved
tests/streams/test_memory.py Show resolved Hide resolved
tests/test_sockets.py Show resolved Hide resolved
tests/test_sockets.py Show resolved Hide resolved
tests/test_sockets.py Outdated Show resolved Hide resolved
tox.ini Outdated Show resolved Hide resolved
tox.ini Outdated Show resolved Hide resolved
@graingert graingert requested a review from agronholm June 5, 2021 11:33
@agronholm agronholm merged commit 792dda7 into agronholm:master Jun 5, 2021
@agronholm
Copy link
Owner

Thanks!

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