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

Cleanup @property stuff on BaseRemoteEndpoint #136

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lahja/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,15 @@ async def wait_ready(self) -> None:
async def wait_stopped(self) -> None:
await self._stopped.wait()

@property
def is_running(self) -> bool:
return not self.is_stopped and self.running.is_set()
return not self.is_stopped and self._running.is_set()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm really confused by this. How is it possible that neither mypy nor flake8 caught this?

Copy link
Member Author

Choose a reason for hiding this comment

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

In my local env. just pushed something to see if CI catches it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it seems it catches it after this change but not on current master which is really weird. Also, the @property decorators also need to be applied on the RemoteEndpointAPI.

Copy link
Contributor

Choose a reason for hiding this comment

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

In fact, as soon as you remove the @property from is_stopped it won't catch this error anymore. This feels like a weird mypy bug to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's very odd.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, here is a minimal test case.

class TestCase:

    def foo(self) -> bool:
        return False and self.meh()

This is not caught by mypy. Do you think this is expected behavior?

Copy link
Contributor

Choose a reason for hiding this comment

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

I opened an issue against mypy python/mypy#6990


@property
def is_ready(self) -> bool:
return self.is_running and self._ready.is_set()

@property
def is_stopped(self) -> bool:
return self._stopped.is_set()

Expand Down