-
Notifications
You must be signed in to change notification settings - Fork 0
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
Refactoring/#221 fixed mypy warnings #225
base: main
Are you sure you want to change the base?
Conversation
Some still need to be clarified
in RegisterPeerForwarder RegisterPeerForwarderBuilderParameter RegisterPeerForwarderFactory
predecessor=message.source, | ||
predecessor_send_socket_factory=predecessor_send_socket_factory, | ||
successor=message.peer, | ||
successor_send_socket_factory=successor_send_socket_factory, | ||
my_connection_info=self._my_connection_info, | ||
) | ||
|
||
@property |
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.
Property method register_peer_connection
checks the private attribute _register_peer_connection
and raises an exception when it is None
to avoid code duplication.
Questions:
- Q1) The names of the private attribute and the property differ on in the prefix
_
and potentially could be mixed up. Should we use different names that can easier be distinguished? - Q2) The property is public. Should it be private?
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.
See last push
raise RuntimeError("No current query handler set.") | ||
return value | ||
|
||
@property |
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.
Property method current_query_handler_context
checks the private attribute _current_query_handler_context
and raises an exception when it is None
to avoid code duplication.
Questions:
- Q1) The names of the private attribute and the property differ on in the prefix
_
and potentially could be mixed up. Should we use different names that can easier be distinguished? - Q2) The property is public. Should it be private?
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.
If the original is private, the new one needs to be private, too. This means it needs another name. Good question, what the name should be. The same is true for current_stage property. Thinking about a prefix like _checked_*
.
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 like the proposal _checked_*
.
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 now used
@property
_checked_current_qh_context(self)
- attribute
self._current_qh_context
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.
See last push
@@ -37,6 +39,8 @@ def with_table_like_name( | |||
return self | |||
|
|||
def build(self) -> ColumnName: | |||
if self._name is None: | |||
raise TypeCheckError("Name must not be 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.
Is it OK to raise a TypeCheckError
here (same as typeguard does)?
Raising a different Error such as ValueError
would require to update the unit tests.
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.
it is not a typeguard typecheck, so I would create my own TypeCheckError. However, we can do this also in another PR.
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.
See #227
@@ -54,8 +55,15 @@ def _receive_from_localhost_leader(self) -> bytes: | |||
self._check_sequence_number(specific_message_obj=specific_message_obj) | |||
return frames[1].to_bytes() | |||
|
|||
@property |
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.
Property method multi_node_communicator
checks the private attribute _multi_node_communicator
and raises an exception when it is None
to avoid code duplication.
Questions:
- Q1) The names of the private attribute and the property differ on in the prefix
_
and potentially could be mixed up. Should we use different names that can easier be distinguished? - Q2) The property is public. Should it be private?
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.
See last push
@@ -94,18 +109,25 @@ def _send_local_leader_message_to_multi_node_leader(self): | |||
local_position=local_position, value_frame=value_frame | |||
) | |||
|
|||
@property |
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.
Property method multi_node_communicator
checks the private attribute _multi_node_communicator
and raises an exception when it is None
to avoid code duplication.
Questions:
- Q1) The names of the private attribute and the property differ on in the prefix
_
and potentially could be mixed up. Should we use different names that can easier be distinguished? - Q2) The property is public. Should it be private?
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.
See last push
@@ -1,6 +1,6 @@ | |||
import logging | |||
|
|||
import exasol.bucketfs as bfs | |||
import exasol.bucketfs as bfs # type: ignore[import-untyped] |
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 think, we can do this in the pyproject.toml for all imports, but we probably should add py.typed to bucketfs-python
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.
Ah, yes.
I created a ticket for adding file py.typed
to bucketfs-python here: exasol/bucketfs-python#173
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 to @Nicoretti for helping: We can ignore importing untyped modules in pyproject.toml like this:
[[tool.mypy.overrides]]
module = "exasol.analytics.*"
disable_error_code = ["import-untyped"]
Additionally type check can be disabled in tests by
[[tool.mypy.overrides]]
module = [
"tests.*",
"noxfile",
]
ignore_errors = true
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.
See last push
@@ -72,8 +73,8 @@ def _handle_continue(self, result: Continue) -> Union[Continue, Finish[ResultTyp | |||
self._cleanup_query_handler_context() | |||
self._execute_queries(result.query_list) | |||
input_query_result = self._run_input_query(result) | |||
result = self._state.query_handler.handle_query_result(input_query_result) | |||
return result | |||
_result = self._state.query_handler.handle_query_result(input_query_result) |
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 this rename?
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.
Because result
was already a parameter of the method and mypy complained about potentially different types being assigned to the same variable.
return self._bucketfs_location | ||
|
||
@property | ||
def parameter(self) -> UDFParameter: |
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.
these should be private, too
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.
OK
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.
See last push
self._parameter = None | ||
|
||
@property | ||
def bucketfs_location(self) -> bfs.path.PathLike: |
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.
these should be private, too
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.
OK
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.
See last push
@@ -187,10 +211,10 @@ def release_and_create_query_handler_context_if_input_query( | |||
current_state.top_level_query_handler_context.get_child_query_handler_context() | |||
) | |||
|
|||
def _get_parameter(self, ctx): | |||
def _get_parameter(self, ctx) -> UDFParameter: | |||
iter_num = ctx[0] |
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.
in another PR, we probably should replace the numbers with named constants
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.
See #228
) -> UDFQueryResult: | ||
colum_start_ix = 8 if self.parameter.iter_num == 0 else 4 | ||
if query_columns is 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.
questionable, needs more investigation
@@ -116,24 +117,28 @@ def _release_and_create_query_handler_context_of_input_query(self): | |||
def _wrap_return_query( | |||
self, input_query: SelectQueryWithColumnDefinition | |||
) -> Tuple[str, str]: | |||
if self._state.input_query_query_handler_context is 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.
needs investigation
exasol/analytics/udf/communication/peer_communicator/background_listener_interface.py
Show resolved
Hide resolved
exasol/analytics/udf/communication/peer_communicator/background_listener_thread.py
Show resolved
Hide resolved
exasol/analytics/udf/communication/socket_factory/fault_injection.py
Outdated
Show resolved
Hide resolved
exasol/analytics/udf/communication/socket_factory/zmq_wrapper.py
Outdated
Show resolved
Hide resolved
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.
Don't forget to activate the type checker in the CI !!! Otherwise all the work is in vain ;)
Co-authored-by: Thomas Ubensee <[email protected]>
I assume the type checker was activated all the time in checks.yml:
but mypy was told to ignore all package of the project in pyproject.toml. The latter I updated. |
Closes #221
Closes #222
Closes #223