-
Notifications
You must be signed in to change notification settings - Fork 16
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
sambacc: complete type annotations #47
sambacc: complete type annotations #47
Conversation
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.
Two minor comments. Overall, LGTM.
sambacc/container_dns.py
Outdated
self.ref = ref | ||
self.items = items | ||
self.items = items or [] |
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.
Consider having (align with other member-initialization in this PR):
self.ref: str = ref
self.items: list[HostInfo] = items or []
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.
updated.
@@ -85,7 +85,7 @@ def _get_events(self): | |||
and ((event.mask & _inotify.flags.CLOSE_WRITE) != 0) | |||
] | |||
|
|||
def _wait(self): | |||
def _wait(self) -> typing.Iterator[None]: |
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.
Why no just have a single wait
function? What is the advantage of using next(typing.Iterator[None])
?
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.
At the time I must have felt implementing the function in terms of an iterator was easier or clearer. This PR only adds the proper type annotation to the function, it doesn't change the runtime behavior. Let's leave that for another time.
Wow. Somehow I managed to forget about this PR. I will need to revisit this soon! |
Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
This includes a small change to the signature of the watch function to only accept a print_func callable and never none. This required a small update to the test code. The real code always passed a function and the ability to pass none never really could have worked right anyway. Signed-off-by: John Mulligan <[email protected]>
The sambacc dir is basically a library and we want to ensure high quality and good documentation so configure mypy to require type annotations on functions defined in sambacc. The sambacc.commands on the other hand are mean to be only run as part of our CLI tools so we'll be a bit less strict there. Signed-off-by: John Mulligan <[email protected]>
586dd18
to
6aec8fd
Compare
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.
LGTM
def smbd_foreground() -> SambaCommand: | ||
return smbd[ | ||
"--foreground", _daemon_stdout_opt("smbd"), "--no-process-group" | ||
] |
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.
IMHO, now that we have explicit return type, those lines look a bit enigmatic. I would consider (in a separate PR) to have more explicit code (also in other places below):
def smbd_foreground() -> SambaCommand:
return SambaCommand("/usr/sbin/smbd",
[ "--foreground", _daemon_stdout_opt("smbd"), "--no-process-group" ])
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.
I'll think about it. On the other hand, the square-braces after a SambaCommand object gives you a new SambaCommand object with additional arguments was there from the beginning as a convenient, don't need to repeat yourself, construct.
The sambacc dir is basically a library and we want to ensure high quality and good documentation so configure mypy to require
type annotations on functions defined in sambacc. Update code in sambacc to add type annotations to any functions lacking them.
The sambacc.commands on the other hand are mean to be only run as part of our CLI tools so we'll be a bit less strict there.