Fix "Code is unreachable Pylance" warning for NumberPlane #1709
+17
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
NumberPlane
object, the code area below will be marked as "unreachable" by Pylance(When I was writing the code)
(In the source code)
Meanwhile, when clicking "show definition" for
get_x_axis()
orget_y_axis
, it will jumps to abstract methods underCoordinateSystem
How to disable "code is not reachable" warning and greying out the code? I find this feature to be unreliable quite often. microsoft/pylance-release#248 (Reference)
This warning was due to
however without adding an abstract class decorator
(Jumping was due to the fact that
get_x_axis()
andget_y_axis
are not overrode again underAxes
class)This pull request aims to improve the structure and make it convenient especially for Pylance user writing and tracking codes
Proposed changes
@abstractclass
for two abstract methodsget_axis
,get_x_axis
,get_y_axis
,get_z_axis
so that when using these/writing these methods, Pylance and users can track back to re-implemented methods underAxes
class instead ofCoordinateSystem
where they will find nothing but a raise ExceptionTest
Tested by initializing a Numberline object and no error occurred.